Device Info Service

The DeviceInfoService implements the standard BLE device information service, providing device information from a BLE peripheral to a BLE central.

API Reference

Header File

Classes

class DeviceInfoService : public espp::BaseComponent

Device Information Service This class is responsible for creating and managing the Device Information Service.

The service is created with the following characteristics:

  • Manufacturer Name (read)

  • Model Number (read)

  • Serial Number (read)

  • Software Version (read)

  • Firmware Version (read)

  • Hardware Version (read)

  • PnP ID (read)

The Device Information Service is a standard Bluetooth service that provides information about the device. This information can be used by a client to identify the device and determine its capabilities. The Device Information Service is defined by the Bluetooth SIG and is intended to be used with any device.

Public Functions

inline explicit DeviceInfoService(espp::Logger::Verbosity log_level = espp::Logger::Verbosity::WARN)

Constructor

Parameters

log_level – The log level for the component

inline void init(NimBLEServer *server)

Initialize the Device Information Service

Parameters

server – The BLE server to add the service to

inline void deinit()

Deinitialize the Device Information Service

Note

This should only be called after NimBLEDevice::deinit(true) has been called, since that will free the memory used by the service

inline void start()

Start the service

Note

This must be called after the service has been initialized

inline NimBLEService *get_service()

Get the service object

Returns

The service object

inline NimBLEUUID uuid()

Get the UUID of the service

Returns

The service UUID

inline void set_device_info(const DeviceInfo &info)

Set the device information

Note

This will set all the characteristics of the service to the values provided in the DeviceInfo struct

Note

This must be called after the service has been initialized

Parameters

info – The device information

inline void set_pnp_id(const PnpId &pnp_id)

Set the PnP ID

Parameters

pnp_id – The PnP ID

inline void set_pnp_id(uint8_t vendor_id_source, uint16_t vendor_id, uint16_t product_id, uint16_t product_version)

Set the PnP ID

Note

The PnP ID is a standard Bluetooth characteristic that provides information about the device’s Plug and Play ID. This information can be used by a client to identify the device and determine its capabilities.

Parameters
  • vendor_id_source – The vendor ID source (0x01 for Bluetooth SIG, 0x02 for USB)

  • vendor_id – The vendor ID

  • product_id – The product ID

  • product_version – The product version

inline void set_manufacturer_name(const std::string &name)

Set the manufacturer name

Parameters

name – The manufacturer name

inline void set_model_number(const std::string &number)

Set the model number

Parameters

number – The model number

inline void set_serial_number(const std::string &number)

Set the serial number

Parameters

number – The serial number

inline void set_software_version(const std::string &version)

Set the software version

Parameters

version – The software version

inline void set_firmware_version(const std::string &version)

Set the firmware version

Parameters

version – The firmware version

inline void set_hardware_version(const std::string &version)

Set the hardware version

Parameters

version – The hardware version

inline const std::string &get_name() const

Get the name of the component

Note

This is the tag of the logger

Returns

A const reference to the name of the component

inline void set_log_tag(const std::string_view &tag)

Set the tag for the logger

Parameters

tag – The tag to use for the logger

inline espp::Logger::Verbosity get_log_level() const

Get the log level for the logger

Returns

The verbosity level of the logger

inline void set_log_level(espp::Logger::Verbosity level)

Set the log level for the logger

Parameters

level – The verbosity level to use for the logger

inline void set_log_verbosity(espp::Logger::Verbosity level)

Set the log verbosity for the logger

See also

set_log_level

Note

This is a convenience method that calls set_log_level

Parameters

level – The verbosity level to use for the logger

inline espp::Logger::Verbosity get_log_verbosity() const

Get the log verbosity for the logger

See also

get_log_level

Note

This is a convenience method that calls get_log_level

Returns

The verbosity level of the logger

inline void set_log_rate_limit(std::chrono::duration<float> rate_limit)

Set the rate limit for the logger

Note

Only calls to the logger that have _rate_limit suffix will be rate limited

Parameters

rate_limit – The rate limit to use for the logger

struct DeviceInfo

Device Information.

Public Members

std::string manufacturer_name

Manufacturer name.

std::string model_number

Model number.

std::string serial_number

Serial number.

std::string software_version

Software version.

std::string firmware_version

Firmware version.

std::string hardware_version

Hardware version.

PnpId pnp_id

Plug and Play ID.

struct PnpId

Plug and Play ID.

Public Members

uint8_t vendor_id_source = 0x01

0x01 for Bluetooth SIG, 0x02 for USB

uint16_t vendor_id

Vendor ID.

uint16_t product_id

Product ID.

uint16_t product_version

Product version.