使用 Bluez 低功耗蓝牙读取温度计数据 [英] Reading Thermometer Data with Bluez Bluetooth Low Energy

查看:23
本文介绍了使用 Bluez 低功耗蓝牙读取温度计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人愿意指导我一点.我正在尝试使用 gatttool 读取蓝牙温度计的温度,但我不知道如何使用指示属性.

I was wondering if there anyone willing to guide me a bit. I am trying to read the temperature of a Bluetooth thermometer using gatttool, but I don't know how to work with the indicate property.

我能够连接到设备、获取设备名称等,但事实证明,获取实际温度数据更具挑战性.

I am able to connect to the device, get the device name, etc., but it has proven to be more challenging to get the actual temperature data.

有人有想法吗?另外,如果您有更多问题要问我,请告诉我.

Does any one have an idea? Also if you have more questions for me, let me know.

推荐答案

假设您的设备使用采用的温度计配置文件,那么您希望启用温度指示 测量特性.为此,有几个步骤:-

Assuming that your device uses the adopted thermometer profile, then you want to enable indications on the temperature measurement characteristic. To do this, there are several steps:-

  1. 使用找到温度特性的句柄:-

  1. Find the handle of the temperature characteristic using:-

gatttool -b 00:11:22:33:44:55 --characteristics

将 00:11:22:33:44:55 替换为您设备的蓝牙地址.您基本上想找到包含 2a1c 的 uuid 并记下其对应的字符值句柄".

Replace 00:11:22:33:44:55 with the Bluetooth address of your device. You basically want to find the uuid that contains 2a1c and note down its corresponding 'char value handle'.

  1. 使用

gatttool -b 00:11:22:33:44:55 char-desc --handle=0xXX

其中 XX 是您之前记下的字符值句柄.您应该能够在该句柄上看到几个特征描述符.用 uuid 2902 记下字符句柄.

Where XX is the char value handle that you noted down earlier. You should be able to see a couple of characteristic descriptors at that handle. Note down the char handle with uuid 2902.

  1. 使用

gatttool -b 00:11:22:33:44:55 --sec-level=high --char-write --handle=0xYYYY --value=0200

其中 0xYYYY 是您在第 2 步中记下的 CCCD 描述符的句柄.一旦发生这种情况,您应该开始获取指示数据,您可以使用找到的温度数据结构对其进行解密 此处.

Where 0xYYYY is the handle of the CCCD descriptor that you noted in step 2. Once this happens, you should start getting indication data, which you can decipher using the temperature data structure found here.

如果您的设备不使用采用的温度计配置文件,那么您需要重复上述三个步骤,但在步骤 1 中,不是查找 uuid 2a1c 的特征,而是查找具有 'char properties = 0x20 的特征' 因为这意味着该特性是可指示的.

If your device does not use the adopted thermometer profile, then you need to repeat the above three steps, but at step 1, instead of looking for a characteristic with uuid 2a1c, look for a characteristic which has 'char properties = 0x20' as this means that the characteristic can be indicatable.

您可以在以下链接中找到有关使用 BlueZ 命令的更多信息:-

You can find more information about using the BlueZ commands at the following links:-

我希望这会有所帮助.

这篇关于使用 Bluez 低功耗蓝牙读取温度计数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆