Central

The central represents your computer. The central is used to start up bluetooth on your computer and also look for peripherals to connect to and manage one once connected. You can only connect one peripheral per central. If you want to have multiple peripherals, just spawn more instances of central.

class bluetooth::Central

Represents a central manager.

Public Functions

void start_bluetooth()

Start bluetooth on your computer.

std::shared_ptr<Peripheral> find_peripheral(const std::vector<std::string> &uuids)

Find and connect to the peripheral_mac given the service UUIDs advertised by the peripheral_mac. If the peripheral is not found, return nullptr.

Parameters
  • uuids: uuids advertised by the peripheral.

std::shared_ptr<Peripheral> find_peripheral(const std::string &name)

Find and connect to a peripheral_mac given the name of it. If the peripheral is not found, return nullptr.

Parameters
  • name: the name advertised by the peripheral_mac.

std::shared_ptr<Peripheral> peripheral(const std::string &uuid)

Return the discovered peripheral. If the peripheral hasn’t been discovered and connected yet then return nullptr.

Return

the peripheral or nullptr.

Parameters
  • uuid: uuid of the peripheral.