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

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

问题描述

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

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,并记下其相应的'char value handle'.

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是您之前记下的char值句柄.您应该能够在该句柄上看到几个特征描述符.记下带有uuid 2902的char句柄.

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. 通过使用

  1. Enable indications by writing '0200' at that handle using

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属性= 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:-

  • How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez?
  • Bluetooth Low Energy: listening for notifications/indications in linux
  • Using Bluetooth low energy in linux command line

我希望这会有所帮助.

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

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