Reputation: 39
I need send value like 0x0001 , 0x0002 in BLE setValue() ,
Does anyone know how to transmit ?
for Example :
private void command () {
ongoing.setValue(0x0001); //error
mBluetoothLeService.writeCharacteristic(ongoing);
BluetoothLeService.setCharacteristicNotification(ongoing, true);
...
...
...
mBluetoothLeService.readCharacteristic(ongoing);
}
Thanks.
in DeviceControlActivity.java :
private void displayGattServices(List<BluetoothGattService> gattServices){
UUID UBI_COMMAND = UUID.fromString(SampleGattAttributes.UBI_ONGOING_INFO_SERVICE_UUID);
...
...
if (uuid.equals(SampleGattAttributes.UBI_ONGOING_INFO_SERVICE_UUID)){
ongoing = gattService.getCharacteristic(UBI_ONGOING);
}
}
Upvotes: 0
Views: 289
Reputation: 320
First define your input format(byte) then set the value of characterstics. Please check below snippet. "writeCharacterstics" function is available in the BluetoothGatt. If you have not a method in your service defined by you then also change the "mBluetoothLeService" object to "gatt" object to write the value.
byte[] value = {(byte) 0x01};
characteristic.setValue(value);
mBluetoothLeService.writeCharacteristic(characteristic);
Upvotes: 3