Gatttool non-interactive mode --char-write

风格不统一 提交于 2020-01-05 03:07:27

问题


Still asking about BLE devices and gatttool.

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

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


回答1:


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

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

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

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

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 This API has been proven to work with Raspberry Pi Jessie destro.



来源:https://stackoverflow.com/questions/40303153/gatttool-non-interactive-mode-char-write

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!