Reputation: 1
I am trying to read characteristic from Bluetooth:
service uuid: 00001800-0000-1000-8000-00805f9b34fb
characteristic uuid: 00002a00-0000-1000-8000-00805f9b34fb
I have no idea of how to call those methods of chr_get_value
and chr_read
. I know the key is gdbus
.
Upvotes: 0
Views: 10591
Reputation: 1066
Service UUID you mentioned is GAP (Generic Access Profile) service UUID and the characteristics UUID (00002a00-0000-1000-8000-00805f9b34fb) you are trying to read is Device name characteristics and returns the device name of the remote LE device.
bluez exposes all its functionalities over its DBus API. If you want to do this in DBus and C, you first need to understand DBus protocol and libdbus or any other DBus bindings API.
See doc/gatt-api.txt and test/example-gatt-client in bluez source directory for documentation and python example. test/example-gatt-client has good python example which helps you to understand how to scan, find and read characteristics of the device.
Otherwise if you know the BD_ADDR address(Bluetooth device address) of the device you want to connect, you can simply perform this task using bluez's gatttool tool.
For example if the address is 03:0F:45:65:43:FF and your device hci interface address is hci0 below sequence of commands reads 2a00 characteristics
[03:0F:45:65:43:FF][LE]> connect
Attempting to connect to 03:0F:45:65:43:FF
Connection successful
[03:0F:45:65:43:FF][LE]> primary
attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0006, end grp handle: 0x0009 uuid: 00001801-0000-1000-8000-00805f9b34fb
# lists all other primary services
[03:0F:45:65:43:FF][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
# lists all other characteristics as well
[03:0F:45:65:43:FF][LE]> char-read-uuid 2a00
handle: 0x0003 value: 4d 79 20 6e 61 6d 65
Upvotes: 2