Peripheral¶
Peripheral represents the device you want to connect to. Peripherals can be found through either searching for a local name or searching for a vector of uuids it contains. A peripheral can have many services.
Currently, if your peripheral has a local name and you search for a peripheral by its uuids,
then it will not automatically find its name. To fix this, call the set_name()
method after
successfully connecting to your peripheral. If you search by name, you’re good.
-
class
bluetooth
::
Peripheral
¶ represents a peripheral device.
Public Functions
-
std::shared_ptr<Service>
find_service
(const std::string &service_uuid)¶ Find advertised service given the service_uuid. Return the service if found, otherwise returns nullptr.
- Return
the service or nullptr.
- Parameters
service_uuid
: service uuid.
-
std::shared_ptr<Service>
service
(const std::string &service_uuid)¶ Returns the discovered service. If the service has not been found and connected via find_service() yet, then this will return nullptr.
- Return
service matching the service_uuid or nullptr.
- Parameters
service_uuid
: service uuid.
-
void
disconnect
()¶ Disconnect the peripheral.
- Note
not blocking.
-
std::string
name
()¶ Get the name of your peripheral. Will return empty if you discovered your peripheral via UUID.
- Return
the name of your peripheral.
-
std::shared_ptr<Service>