繁体   English   中英

如何将数据传输到连接的蓝牙LE设备

[英]how transferring data to connected bluetooth LE device

我已按照以下说明和示例连接到蓝牙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和功能)。您可以下载北欧半导体nRF connect应用程序以更好地了解BLE读写

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM