简体   繁体   English

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

[英]how transferring data to connected bluetooth LE device

I connected to a bluetooth LE device with below instructions and samples: https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#getService(java.util.UUID) 我已按照以下说明和示例连接到蓝牙LE设备: https : //developer.android.com/reference/android/bluetooth/BluetoothGatt.html#getService(java.util.UUID)

https://github.com/googlesamples/android-BluetoothLeGatt https://github.com/googlesamples/android-BluetoothLeGatt

but i have no idea how i can send data (hexa code) to ble device, can anyone help me? 但是我不知道如何将数据(十六进制代码)发送到ble设备,有人可以帮助我吗? does below code send data to device : 以下代码是否将数据发送到设备:

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 receive data only on services. BLE仅在服务上接收数据。 Services can be custom or BLE standers.ON device connect discover all Ble services and find-out all available service(with there UUIDs and capabilities) on that device.You can download nordic semiconductors nRF connect application for better understanding of BLE read and write 服务可以是自定义或BLE代表.ON设备连接可发现该设备上的所有Ble服务并查找所有可用服务(具有UUID和功能)。您可以下载北欧半导体nRF connect应用程序以更好地了解BLE读写

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

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