Java Code Examples for android.bluetooth.BluetoothGattCharacteristic#getInstanceId()

The following examples show how to use android.bluetooth.BluetoothGattCharacteristic#getInstanceId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BluetoothLeService.java    From OpenFit with MIT License 5 votes vote down vote up
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(LOG_TAG, "onServicesDiscovered: "+status);
    if(status == BluetoothGatt.GATT_SUCCESS) {    
        // loops through available GATT Services.
        for(BluetoothGattService gattService : gatt.getServices()) {
            String uuid = gattService.getUuid().toString();
            String type = gattServiceType[gattService.getType()];

            Log.d(LOG_TAG, "onServicesDiscovered type: "+type);
            Log.d(LOG_TAG, "onServicesDiscovered uuid: "+uuid);
            //Log.d(LOG_TAG, "onServicesDiscovered: getCharacteristic: "+mWriteCharacteristic);
            for(BluetoothGattCharacteristic gattCharacteristic : gattService.getCharacteristics()) {
                String cUuid = gattCharacteristic.getUuid().toString();
                int cInstanceId = gattCharacteristic.getInstanceId();
                int cPermissions = gattCharacteristic.getPermissions();
                int cProperties = gattCharacteristic.getProperties();
                byte[] cValue = gattCharacteristic.getValue();
                int cWriteType = gattCharacteristic.getWriteType();

                Log.d(LOG_TAG, "onServicesDiscovered cUuid: "+cUuid);
                Log.d(LOG_TAG, "onServicesDiscovered cInstanceId: "+cInstanceId);
                Log.d(LOG_TAG, "onServicesDiscovered cPermissions: "+cPermissions);
                Log.d(LOG_TAG, "onServicesDiscovered cProperties: "+cProperties);
                Log.d(LOG_TAG, "onServicesDiscovered cValue: "+cValue);
                Log.d(LOG_TAG, "onServicesDiscovered cWriteType: "+cWriteType);
            }
        }
        Log.d(LOG_TAG, "BluetoothLe Service discovered: "+status);
        broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
    }
    else {
        Log.d(LOG_TAG, "BluetoothLe onServicesDiscovered received: "+status);
    }
}
 
Example 2
Source File: Peripheral.java    From react-native-ble-manager with Apache License 2.0 4 votes vote down vote up
private String generateHashKey(UUID serviceUUID, BluetoothGattCharacteristic characteristic) {
	return String.valueOf(serviceUUID) + "|" + characteristic.getUuid() + "|" + characteristic.getInstanceId();
}