找出 Android 蓝牙 LE GATT 配置文件

新手上路,请多包涵

我已经实现了找到心率监测器并连接到它的 Android LE 蓝牙示例。但是,此示例有一个定义 GATT 配置文件的类,如下所示:

  private static HashMap<String, String> attributes = new HashMap();
public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";

static {
    // Sample Services.
    attributes.put("0000180d-0000-1000-8000-00805f9b34fb", "Heart Rate Service");
    attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service");
    // Sample Characteristics.
    attributes.put(HEART_RATE_MEASUREMENT, "Heart Rate Measurement");
    attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
}

public static String lookup(String uuid, String defaultName) {
    String name = attributes.get(uuid);
    return name == null ? defaultName : name;
}

现在,我想做的是更改它,以便该程序找到任何带有蓝牙文件的设备,但我不知道谷歌如何获得客户端特征配置的心率测量信息。

原文由 N0xus 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 281
1 个回答

Bluetooth SIG 维护一个“ 分配编号”列表,其中包括在示例应用程序中找到的那些 UUIDhttps ://www.bluetooth.com/specifications/assigned-numbers/

尽管 UUID 的长度为 128 位,但蓝牙 LE 的分配编号被列为 16 位十六进制值,因为较低的 96 位在一类属性中是一致的。

例如,所有 BLE 特征 UUID 的形式为:

 0000XXXX-0000-1000-8000-00805f9b34fb

心率测量特征 UUID 的分配编号列为 0x2A37 ,这是示例代码的开发人员可以得出的结果:

 00002a37-0000-1000-8000-00805f9b34fb

原文由 Godfrey Duke 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题