我使用以下说明和示例连接到蓝牙 LE 设备: https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#getService(java.util.UUID)
https://github.com/googlesamples/android-BluetoothLeGatt
但我不知道如何将数据(十六进制代码)发送到 BLE 设备, 谁能帮我? 下面的代码是否将数据发送到设备:
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
int hexaCode =Integer.parseInt("7c",16);
descriptor.setValue(
ByteBuffer.allocate(4).putInt(hexaCode).array());
mBluetoothGatt.writeDescriptor(descriptor);
最佳答案
BLE 仅接收服务数据。服务可以是自定义的或 BLE 标准。ON 设备连接发现所有 Ble 服务并找出该设备上的所有可用服务(具有 UUID 和功能)。您可以下载 Nordic Semiconductors nRF connect 应用程序以更好地使用BLE读写的理解
关于java - 如何将数据传输到连接的蓝牙 LE 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47880718/