MyoLinux
|
Class for communication using the GATT protocol. More...
#include <gattclient.h>
Public Member Functions | |
Client (const bled112::Client &) | |
Creates from an instance of lower level protocol client. More... | |
void | discover (std::function< bool(std::int8_t, Address, Buffer)>) |
Discover the devices supporting the GATT protocol. More... | |
Characteristics | characteristics () |
Discover the characteristics of the device. More... | |
void | connect (const Address &) |
Connect to the device with the specified address. More... | |
void | connect (const std::string &) |
Connect to the device with the specified address in string form. More... | |
bool | connected () |
Checks whether the client is connected. More... | |
Address | address () |
Returns the address of the connected device. More... | |
void | disconnect () |
Disconnect the client. | |
void | disconnectAll () |
Disconnect all devices connected to the dongle. More... | |
void | writeAttribute (const std::uint16_t, const Buffer &) |
Write GATT attribute. More... | |
Buffer | readAttribute (const std::uint16_t) |
Read GATT attribute. More... | |
void | listen (const std::function< void(std::uint16_t, Buffer)> &) |
Listen to GATT notifications. More... | |
Class for communication using the GATT protocol.
Client | ( | const bled112::Client & | client | ) |
Creates from an instance of lower level protocol client.
client | instance of the bled112::Client |
auto address | ( | ) |
Returns the address of the connected device.
If the client is not connected an exception is thrown.
auto characteristics | ( | ) |
Discover the characteristics of the device.
void connect | ( | const Address & | address | ) |
Connect to the device with the specified address.
address | address of the device |
void connect | ( | const std::string & | str | ) |
Connect to the device with the specified address in string form.
The address is represented as six hexadecimal digis separated with colons. This is also the format used by the bluetoothctl tool.
Example: 01:23:E2:D4:4D:66
str | string form of the address |
bool connected | ( | ) |
Checks whether the client is connected.
void disconnectAll | ( | ) |
Disconnect all devices connected to the dongle.
The supplied dongle supports only three.
Discover the devices supporting the GATT protocol.
The callback is called for each found device. As long as it returns true the scanning continues, otherwise the function returns.
callback | the callback called for each device, the parameters are: RSSI, the address and the device specific data included in the advertisment. |
void listen | ( | const std::function< void(std::uint16_t, Buffer)> & | callback | ) |
Listen to GATT notifications.
callback | callback to call when an notification arrives |
DisconnectedException |
Buffer readAttribute | ( | const std::uint16_t | handle | ) |
Read GATT attribute.
handle | handle of the attribute |
void writeAttribute | ( | const std::uint16_t | handle, |
const Buffer & | payload | ||
) |
Write GATT attribute.
handle | handle of the attribute |
payload | payload to send |