【问题标题】:How to write data to BLE device in android如何在android中将数据写入BLE设备
【发布时间】:2015-02-11 12:25:24
【问题描述】:

在此之后,我可以从我的 android 应用程序扫描 ble 设备,我想将数据发送到该扫描设备。怎么做?如果有人有,请分享我的示例代码。

我提到在这里回答了一些人问同样的问题 [Working with BLE Android 4.3 how to write characteristics?

但没有低于代码段

 BluetoothGattService Service = mBluetoothGatt.getService(your Services);

Here what is `your seervice`

BluetoothGattCharacteristic charac = Service
            .getCharacteristic(your characteristic);

  Here what is `your characteristic`  

请解释一下上面的代码

谢谢

【问题讨论】:

  • 您是否尝试过来自 github 的可用示例?如果还没有,请通过 gihub,它将为您提供大量示例!
  • 谢谢你的回复,你能分享我的链接@JiteshUpadhyay

标签: android bluetooth


【解决方案1】:

要了解服务和特性,请ddl并运行官方BLE项目:https://android.googlesource.com/platform/development/+/cefd49aae65dc85161d08419494071d74ffb982f/samples/BluetoothLeGatt

您的设备包含许多描述它可以为您提供什么的服务。使用官方项目,您可以访问它们。请注意,每个服务都类似于: 0000XXXX-0000-1000-8000-00805f9b34f 你可以在这里找到XXXX:https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx 特性也是一样

例如,如果您想查找设备的名称 服务 UUID 代码为 00001800-0000-1000-8000-00805f9b34f,特征为设备名称。 UUID 00002A00-0000-1000-8000-00805f9b34f.

回答你,你的服务是一个 UUID。

【讨论】:

    猜你喜欢
    • 2020-01-18
    • 1970-01-01
    • 2017-08-12
    • 1970-01-01
    • 2021-05-25
    • 2017-04-23
    • 1970-01-01
    • 2020-10-15
    • 1970-01-01
    相关资源
    最近更新 更多