ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::ble_device_base::AdvPayload Class Reference

A 31 byte advertising or scan response payload, packed in the order and with the fit rules of Bluedroid's btm_ble_build_adv_data, so the raw bytes match what the esp_ble_adv_data_t API put on air. More...

#include <adv_payload.h>

Public Member Functions

const uint8_t * data () const
 
size_t size () const
 
void add_flags (uint8_t flags)
 
void add_appearance (uint16_t appearance)
 
void add_name (const char *name, size_t len)
 Complete name, or the shortened name type with what fits.
 
void add_manufacturer_data (std::span< const uint8_t > data)
 Truncated to what fits.
 
void add_tx_power (int8_t dbm)
 
void add_uuids (std::span< const ESPBTUUID > uuids, const ESPBTUUID &skip={})
 16 and 32-bit lists (partial when they do not all fit), then the first 128-bit UUID; skip is left out.
 
void add_service_data (std::span< const uint8_t > data)
 Raw service data element (its first bytes are the UUID); dropped whole when it does not fit.
 

Static Public Member Functions

static size_t uuid_size (const ESPBTUUID &uuid, uint32_t *value=nullptr)
 Bluedroid's width for uuid: 2 or 4 (and its value) when it has a 16 or 32-bit form, else 16.
 

Static Public Attributes

static constexpr size_t MAX_LEN = 31
 

Protected Member Functions

size_t left_ () const
 
void add_ (uint8_t type, const uint8_t *value, size_t len)
 
void add_short_uuids_ (std::span< const ESPBTUUID > uuids, const ESPBTUUID &skip, size_t size, uint8_t partial_type)
 

Protected Attributes

std::array< uint8_t, MAX_LEN > buf_ {}
 
uint8_t len_ {0}
 

Detailed Description

A 31 byte advertising or scan response payload, packed in the order and with the fit rules of Bluedroid's btm_ble_build_adv_data, so the raw bytes match what the esp_ble_adv_data_t API put on air.

Definition at line 17 of file adv_payload.h.

Member Function Documentation

◆ add_()

void esphome::ble_device_base::AdvPayload::add_ ( uint8_t type,
const uint8_t * value,
size_t len )
inlineprotected

Definition at line 91 of file adv_payload.h.

◆ add_appearance()

void esphome::ble_device_base::AdvPayload::add_appearance ( uint16_t appearance)
inline

Definition at line 28 of file adv_payload.h.

◆ add_flags()

void esphome::ble_device_base::AdvPayload::add_flags ( uint8_t flags)
inline

Definition at line 24 of file adv_payload.h.

◆ add_manufacturer_data()

void esphome::ble_device_base::AdvPayload::add_manufacturer_data ( std::span< const uint8_t > data)
inline

Truncated to what fits.

Definition at line 43 of file adv_payload.h.

◆ add_name()

void esphome::ble_device_base::AdvPayload::add_name ( const char * name,
size_t len )
inline

Complete name, or the shortened name type with what fits.

Definition at line 36 of file adv_payload.h.

◆ add_service_data()

void esphome::ble_device_base::AdvPayload::add_service_data ( std::span< const uint8_t > data)
inline

Raw service data element (its first bytes are the UUID); dropped whole when it does not fit.

Definition at line 65 of file adv_payload.h.

◆ add_short_uuids_()

void esphome::ble_device_base::AdvPayload::add_short_uuids_ ( std::span< const ESPBTUUID > uuids,
const ESPBTUUID & skip,
size_t size,
uint8_t partial_type )
inlineprotected

Definition at line 97 of file adv_payload.h.

◆ add_tx_power()

void esphome::ble_device_base::AdvPayload::add_tx_power ( int8_t dbm)
inline

Definition at line 47 of file adv_payload.h.

◆ add_uuids()

void esphome::ble_device_base::AdvPayload::add_uuids ( std::span< const ESPBTUUID > uuids,
const ESPBTUUID & skip = {} )
inline

16 and 32-bit lists (partial when they do not all fit), then the first 128-bit UUID; skip is left out.

Definition at line 52 of file adv_payload.h.

◆ data()

const uint8_t * esphome::ble_device_base::AdvPayload::data ( ) const
inline

Definition at line 21 of file adv_payload.h.

◆ left_()

size_t esphome::ble_device_base::AdvPayload::left_ ( ) const
inlineprotected

Definition at line 90 of file adv_payload.h.

◆ size()

size_t esphome::ble_device_base::AdvPayload::size ( ) const
inline

Definition at line 22 of file adv_payload.h.

◆ uuid_size()

static size_t esphome::ble_device_base::AdvPayload::uuid_size ( const ESPBTUUID & uuid,
uint32_t * value = nullptr )
inlinestatic

Bluedroid's width for uuid: 2 or 4 (and its value) when it has a 16 or 32-bit form, else 16.

Definition at line 71 of file adv_payload.h.

Field Documentation

◆ buf_

std::array<uint8_t, MAX_LEN> esphome::ble_device_base::AdvPayload::buf_ {}
protected

Definition at line 121 of file adv_payload.h.

◆ len_

uint8_t esphome::ble_device_base::AdvPayload::len_ {0}
protected

Definition at line 122 of file adv_payload.h.

◆ MAX_LEN

size_t esphome::ble_device_base::AdvPayload::MAX_LEN = 31
staticconstexpr

Definition at line 19 of file adv_payload.h.


The documentation for this class was generated from the following file: