简体   繁体   English

如何在Android中将数据写入BLE设备

[英]How to write data to BLE device in android

I am able to scan a ble device from my android application after this I want to send data to that scanned device. 在此之后,我想从我的Android应用程序扫描一个ble设备,我想将数据发送到该扫描设备。 How to do? 怎么做? Kindly share me example code if any one have. 如果有人,请分享我的示例代码。

I referred to answered some one asked same question here [ Working with BLE Android 4.3 how to write characteristics? 我提到回答有人在这里问了同样的问题[ 使用BLE Android 4.3怎么写特性?

but am not getting below piace of code 但没有低于代码的代码

 BluetoothGattService Service = mBluetoothGatt.getService(your Services);

Here what is `your seervice`

BluetoothGattCharacteristic charac = Service
            .getCharacteristic(your characteristic);

  Here what is `your characteristic`  

Kindly explain above code 请解释上面的代码

Thanks 谢谢

To understand about services and characteristic, ddl and run the official BLE projet : https://android.googlesource.com/platform/development/+/cefd49aae65dc85161d08419494071d74ffb982f/samples/BluetoothLeGatt 要了解服务和特性,请使用ddl并运行官方BLE projet: https : //android.googlesource.com/platform/development/+/cefd49aae65dc85161d08419494071d74ffb982f/samples/BluetoothLeGatt

Your device contains many services which describe what it can offer to you. 您的设备包含许多服务,这些服务描述了它可以为您提供的服务。 With the official projet you can have access to them. 使用官方项目,您可以访问它们。 Note that each services is like : 0000XXXX-0000-1000-8000-00805f9b34f you can find the XXXX here : https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx And it is the same for the characteristic 请注意,每个服务都类似于:0000XXXX-0000-1000-8000-00805f9b34f,您可以在此处找到XXXX: https : //developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx这与特征相同

For example if you want to find the name of the device Service UUID code is 00001800-0000-1000-8000-00805f9b34f and the characteristic is Device name. 例如,如果要查找设备的名称,则服务UUID代码为00001800-0000-1000-8000-00805f9b34f,其特征为设备名称。 UUID 00002A00-0000-1000-8000-00805f9b34f. UUID 00002A00-0000-1000-8000-00805f9b34f。

To answer you, your services is an UUID. 要回答您,您的服务是UUID。

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

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