Gatttool非交互模式--char-write [英] Gatttool non-interactive mode --char-write

查看:297
本文介绍了Gatttool非交互模式--char-write的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仍在询问BLE设备和gatttool.

Still asking about BLE devices and gatttool.

我可以在交互模式下发送char-write-cmd,但在非交互模式下不能执行相同的操作.

I'm able to send a char-write-cmd in interactive mode, but I'm not able to do the same in non-interactive.

这是我以交互方式发送的内容:

This is what I send in interactive mode :

gatttool -I

[]> connect BTADDR

[BTADDR]> char-write-cmd 0x0040 01

[BTADDR]> exit

通过这种方式,我启动了警报服务,在我的情况下,它使蜂鸣器响起.

In this way I start the Alert service, which in my case makes the buzzer sounds.

理论上,非交互模式应为:

In theory, the non-interactive mode should be:

gatttool -b BTADDR --char-write -a 0x0040 -n 01

但这不会将request命令事件发送到开发板,我正在使用开发板进行检查.

But this do not send the request command event to the board, I'm checking it using a dev board.

推荐答案

读取或写入BLE外设的手动(非交互)方式:

The manual (non-interactive) way to read or write to your BLE peripheral:

要编写和接收答复一次:(取决于您配置BLE设备的方式)

To write and receive reply once: (depending on how you configure your BLE device)

sudo gatttool -i hci0 -b xx:xx:xx:xx:xx:xx --char-write-req -a 0x0025 -n ff

要无限期地写和接收答复:(直到断开BLE设备的连接或停止Bluetooth客户端为止)

To write and receive reply indefinitely: (Until you disconnect from BLE device or stop your Bluetooth client)

sudo gatttool -i hci0 -b xx:xx:xx:xx:xx:xx --char-write-req -a 0x0025 -n ff --listen

注意,我仅在末尾添加了--listen选项.仅当您将BLE节点(传感器或执行器)配置为读取和回复时,此机制才有效. 资料来源:: 如何使用gatttool非交互模式 蓝牙低能耗:监听linux中的通知/指示

Notice I only added the --listen option at the end. This mechanism only works if you configure your BLE node (sensor or actuator) to read and reply. sources:: How to use gatttool non-interactive mode Bluetooth Low Energy: listening for notifications/indications in linux

所有这些,我仍然认为最好不要控制或从BLE设备获取值.我的方向是继续前进,并使用API​​(也许在python中)为您完成这项工作.

All that said, I still do not think it is best to control or get values from a BLE device. My direction is to move forward and use an API (maybe in python) to do the job for you.

https://github.com/peplin/pygatt 该API已被证明可与Raspberry Pi Jessie destro一起使用.

https://github.com/peplin/pygatt This API has been proven to work with Raspberry Pi Jessie destro.

这篇关于Gatttool非交互模式--char-write的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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