Klasse Blukii

java.lang.Object
com.blukii.sdk.config.Blukii
Bekannte direkte Unterklassen:
SmartBeacon, SmartPen

public class Blukii extends Object
This class represents a blukii device and is the main controller class for connection based communication with blukii devices.

Blukii is the single point of contact for all actions that are provided by blukii GATT profiles.

Quick start documentation

blukii types

This class contains all blukii functions that are independent of any blukii type.

For each blukii type there is a derived SmartBeacon class that contains additional type specific functions.

Get blukii device object

Initially, you need a valid blukii device (BluetoothDevice) to connect to. You have to search for BLE devices what can easily be done by the BlukiiClient class, which is part of the library's discovery package.

You can retrieve a BluetoothDevice object by calling DiscoveryData.getDevice().

Connect & Disconnect

This class provides methods to connect to a blukii device and disconnect from it. So you can call connect(ConnectionListener) to initiate the connection and you can call disconnect() if your work is done and you want to free your device.

You can keep track about the connection state via the ConnectionListener interface which is handed to the Blukii class via the connect(ConnectionListener) method.

Example snippet


 private boolean connectDevice() {
   // get blukii device object from an DiscoveryData object, that is retrieved
   // from BlukiiClient.OnDiscoveryListener
   BluetoothDevice bluetoothDevice = discoveryData.getDevice();

   // create new Blukii instance (see also BlukiiController)
   mBlukii = BlukiiController.getInstance().getNewSmartBeaconConfig(bluetoothDevice);

   // initiate connection => retrieve callback via ConnectionListener
   mBlukii.connect(mConnectionListener);
 }

 private final ConnectionListener mConnectionListener = new ConnectionListener() {
   @Override
   public void onConnected() {
     // Connection successful
   }

   @Override
   public void onDisconnected(DisconnectReason reason) {
       // Device is disconnected or connection failed
   }

   // ...

 };
 

Asynchronous requests

This class contains a large set of requests that are supported by the several blukii devices.

Important: all requests are called asynchronously. The results are returned via callbacks of ResponseListener.

Via ResponseListener.onResponse(ResponseData) you get the response value. ResponseData.getStatus() shows if the call was successful.

Example Snippet


 private void readTxPower() {
   mBlukii.readTxPower(new ResponseListener() {
     @Override
     onResponse(ResponseData response) {
       if(response.getStatus.equals(ResponseStatus.Success) {
         int txPower = response.getData().getDeviceValue();
         Log.i(TAG, "Read TxPower Success: " + txPower);
       } else {
         Log.e(TAG, "Read TxPower Error: + error.getErrorStatus());
       }
     }
   }
 }

 private void writeIBeacon(UUID uuid, int major, int minor) {
   IBeacon iBeaconData = new IBeacon();
   iBeaconData.setUUID(uuid);
   iBeaconData.setMajor(major);
   iBeaconData.setMinor(minor);

   mBlukii.writeIBeaconAdvertising(iBeaconData, new ResponseListener() {
     @Override
       if(response.getStatus.equals(ResponseStatus.Success) {
         IBeacon iBeaconData = response.getData().getDeviceValue();
         Log.i(TAG, "Write iBeacon Success");
       } else {
         Log.e(TAG, "Write iBeacon Error: + error.getErrorStatus());
       }
     onResponse(ResponseData response) {
     }
   }
 }
 

Cloud support

You can interact with blukii Manager for retrieving cloud managed data and synchronizing device data to cloud.

This sdk feature requires an authentication via the BlukiiCloud class:

See also DataManager class for managing cloud dependent data.