【问题标题】:implementing BLE app without knowing UUIDS在不知道 UUIDS 的情况下实现 BLE 应用程序
【发布时间】:2014-09-22 21:42:06
【问题描述】:

我正在使用 BLE 技术实现一个 android 应用程序。蓝牙设备设计用于测量温度。它使用 TI 的 cc2541。使用 BTool 蓝牙低功耗 PC 应用程序 v1.40.5 的硬件测试与设备交互良好:我们写入特征值 0x2f 和启动命令 0100 并输入下游命令(23 53 54 00 6e 00 00 。 .. FE) 我们将其用作特征值 0x2b。问题是如何在我的 android 应用程序中实现相同的测试。我能够连接到 ble 设计,读取可用的服务和特性,不知道在哪里编写命令或读取特性。

【问题讨论】:

    标签: bluetooth-lowenergy uuid android-bluetooth characteristics


    【解决方案1】:

    要使用 Android BLE API 向特征写入新值,您需要先在本地更新特征值,然后将该特征写入远程设备,然后等待回调 onCharacteristicRead 被调用。

    例如, 将值写入远程 BLE 设备的特征:


    1) 连接到远程 BLE 设备
    2) 发现服务和特征
    3) 从BluetoothGatt 中找到您正在寻找的BluetoothGattservice
    4) 从 BluetoothGattservice 中找到您要更新其值的BluetoothGattCharacteristic
    5) 使用mCurrentCharacteristic.setValue(value) 方法在本地将新值设置为BluetoothGattCharacteristic
    6) 使用mBluetoothGatt.writeCharacteristic(mCurrentCharacteristic)方法将更新后的特征写入远程BLE设备
    7) 然后等待回调onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)被调用,确认特征是否成功写入远程BLE设备

    从远程 BLE 设备读取特征值:


    1) 连接到远程 BLE 设备
    2) 发现服务和特征
    3) 从BluetoothGatt 中找到您正在寻找的BluetoothGattservice
    4) 从 BluetoothGattservice 中找到您要读取其值的BluetoothGattCharacteristic
    5) 调用readCharacteristic(BluetoothGattCharacteristic characteristic) 方法
    6) 然后等待回调 onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) 被调用以从远程 BLE 设备中检索特征
    7) 使用characteristic.getValue() 从特征中获取数据

    Also have a look at the following link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-18
      • 1970-01-01
      • 2018-03-22
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      相关资源
      最近更新 更多