我已经实现了找到心率监测器并连接到它的 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 许可协议
Bluetooth SIG 维护一个“ 分配编号”列表,其中包括在示例应用程序中找到的那些 UUID : https ://www.bluetooth.com/specifications/assigned-numbers/
尽管 UUID 的长度为 128 位,但蓝牙 LE 的分配编号被列为 16 位十六进制值,因为较低的 96 位在一类属性中是一致的。
例如,所有 BLE 特征 UUID 的形式为:
心率测量特征 UUID 的分配编号列为
0x2A37
,这是示例代码的开发人员可以得出的结果: