低功耗蓝牙:在 linux 中监听通知/指示 [英] Bluetooth Low Energy: listening for notifications/indications in linux

查看:41
本文介绍了低功耗蓝牙:在 linux 中监听通知/指示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 Linux 机器与 BLE 模块通信(该模块正在运行心率配置文件).到目前为止,除了收听通知和指示(例如收听心率测量通知)之外,我已经能够做我需要的一切.我使用的是内核版本 3.5 和 bluez-5.3.

I'm trying to communicate with a BLE module through a Linux machine (the module is running a heart rate profile). So far, I've been able to do everything I need except listening for Notifications and indications (e.g. listening for the Heart Rate Measurement Notification). I'm using kernel version 3.5 and bluez-5.3.

目前使用的成功命令:

hcitool lescan
hcitool lecc
gatttool -b <Mac Address> --primary
gatttool -b <MAC Address> --characteristics
gatttool -b <MAC Address> --char-read
gatttool -b <MAC Address> --char-desc
gatttool -b <MAC Address> --interactive

失败的命令:

gatttool -b <MAC Address> --listen

非常感谢任何帮助.

推荐答案

试试这个...

运行 gatttool -b --interactive 就像你以前做的那样.你会得到一个提示,然后你输入 connect.您应该会在提示中看到一个 CON,表明您已连接到设备.然后输入char-read-uuid 2902.您应该获得设备上所有 CCC(客户端特征配置)属性的列表.您可以尝试将它们全部设置为 0100 以获取通知,0200 表示指示,0300 表示两者,或 0000 表示所有关闭. 键入 help 以查看所有命令及其参数.

Run gatttool -b <MAC Address> --interactive like you did before. You'll get a prompt and then you type connect. You should see a CON in the prompt indicating that you've connected to the device. Then type char-read-uuid 2902. You should get a list of all CCC (Client Characteristic Configuration) attributes on the device. You can try setting them all to 0100 to get notifications, 0200 for indications, 0300 for both, or 0000 for everything off. Type help to see all the commands and their arguments.

--listen 参数的使用要求您将其与其他命令结合使用以打开通知和/或指示.下面是一个适用于 Bluez 4.101 的示例:

The use of the --listen argument requires you to couple it with other commands to turn on the notifications and/or indications. So here's an example that works in Bluez 4.101:

gatttool -b <MAC Address> --char-write-req --handle=0x0031 --value=0100 --listen

显然,您需要将句柄更改为要为其打开通知的 CCC 的句柄.但是,我仍然发现仅使用交互模式更容易.

Obviously you need to change the handle to the handle of the CCC that you want to turn on notifications for. However, I still find it way easier to just use the interactive mode.

这篇关于低功耗蓝牙:在 linux 中监听通知/指示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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