Issue
how do I send a array looks like this
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 25, 255]
via bluetoothctl to my BLE device.
Here are my commands Code: Select all
sudo bluetoothctl
[bluetooth]# connect EB:01:9D:FE:27:B1
Attempting to connect to EB:01:9D:FE:27:B1
[CHG] Device EB:01:9D:FE:27:B1 Connected: yes
Connection successful
[CHG] Device EB:01:9D:FE:27:B1 ServicesResolved: yes
[Nuimo]# menu gatt
[Nuimo]# select-attribute f29b152d-cb19-40f3-be5c-7241ecb82fd2
[Nuimo:/service001b/char002f]#
[Nuimo:/service001b/char002f]# write data="[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 25, 255]"
Invalid value at index 0
Attempting to write /org/bluez/hci0/dev_EB_01_9D_FE_27_B1/service001b/char002f
[Nuimo:/service001b/char002f]#
[Nuimo:/service001b/char002f]# attribute-info f29b152d-cb19-40f3-be5c-7241ecb82fd2
Characteristic - Vendor specific
UUID: f29b152d-cb19-40f3-be5c-7241ecb82fd2
Service: /org/bluez/hci0/dev_EB_01_9D_FE_27_B1/service001b
Flags: read
Flags: write-without-response
Flags: write
But nothing happend.....
Solution
You can select and write to an attribute without going in to the gatt
menu by prepending gatt.
to the command. For example:
gatt.select-attribute f29b152d-cb19-40f3-be5c-7241ecb82fd2
To write to a characteristic use the hex values in quotes. For example:
gatt.write "0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x19 0xff"
Here a log of a session on my system connecting to a BBC micro:bit:
$ bluetoothctl
Agent registered
[bluetooth]# connect E1:4B:6C:22:56:F0
Attempting to connect to E1:4B:6C:22:56:F0
[CHG] Device E1:4B:6C:22:56:F0 Connected: yes
Connection successful
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: 0000fe59-0000-1000-8000-00805f9b34fb
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: 6e400001-b5a3-f393-e0a9-e50e24dcca9e
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: e95d6100-251d-470a-a062-fa1922dfa9a8
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: e95d93af-251d-470a-a062-fa1922dfa9a8
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: e95d9882-251d-470a-a062-fa1922dfa9a8
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: e95dd91d-251d-470a-a062-fa1922dfa9a8
[CHG] Device E1:4B:6C:22:56:F0 UUIDs: e97dd91d-251d-470a-a062-fa1922dfa9a8
[CHG] Device E1:4B:6C:22:56:F0 ServicesResolved: yes
[BBC micro:bit [toveg]]# gatt.select-attribute e95d93ee-251d-470a-a062-fa1922dfa9a8
[BBC micro:bit [toveg]:/service0035/char0038]# gatt.write "0x42 0x4C 0x45 0x23"
Attempting to write /org/bluez/hci0/dev_E1_4B_6C_22_56_F0/service0035/char0038
[BBC micro:bit [toveg]:/service0035/char0038]#
This sent the values successfully.
Answered By - ukBaz Answer Checked By - Mildred Charles (WPSolving Admin)