0
我需要BLE的setValue()發送類似爲0x0001,爲0x0002值,的Android BLE的setValue像×0001
有誰知道如何傳輸?
例如:
private void command() {
ongoing.setValue(0x0001); //error
mBluetoothLeService.writeCharacteristic(ongoing);
BluetoothLeService.setCharacteristicNotification(ongoing, true);
...
...
...
mBluetoothLeService.readCharacteristic(ongoing);
}
Thanks.
在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);
}
}
「進行中」的類型是什麼? – Sweeper
它應該是BluetoothGattCharacteristic,因爲它被傳遞給需要它的方法? – CmosBattery
我只讀過,但看到這裏寫作:https://stackoverflow.com/questions/36163998/writing-data-to-bluetooth-le-characteristic-in-android ...值得注意的是,你可以使用像@Override的實際方法public void onCharacteristicWrite(BluetoothGatt gatt,....寫入數據,但你可能沒有按照鏈接正確寫入。 – CmosBattery