4

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.

Ruslan Osmanov
  • 20,486
  • 7
  • 46
  • 60
Fiuwe
  • 61
  • 1
  • 4
  • I have the exact same problem. Interactive mode works, but non-interactive mode doesn't. I can send a write-request in non-interactive mode, but I can't send a write-command in non-interactive mode. I've looked at the source code for gatttool and I can't see any obvious error. Were you able to get it working? – Mr Stinky Feb 06 '17 at 13:23

1 Answers1

5

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.

Community
  • 1
  • 1
Al Badokhon
  • 51
  • 1
  • 3
  • I still do not think it is best to control or get values from a BLE device-- Why ? pyGATT uses gatttool CLI approach in its internal implementation.If you don't like use CLI approach, What I recommend is to implement Native Library using BlueZ Libs. – ABHIJITH KINI Nov 04 '17 at 08:51