ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
esphome::ble_device_base::ESPBTDevice Class Reference

#include <ble_device.h>

Public Member Functions

void from_scan_result (const uint8_t *mac, int rssi, uint8_t addr_type, const uint8_t *data, uint16_t data_len)
 Populate from a raw scan result delivered by a BLE tracker backend.
 
std::string address_str () const
 Return MAC as "XX:XX:XX:XX:XX:XX" string.
 
const char * address_str_to (char *buf) const
 Buffer overload: writes "XX:XX:XX:XX:XX:XX\0" into buf (>= 18 bytes), returns buf.
 
const char * address_str_to (std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf) const
 
uint64_t address_uint64 () const
 Return MAC as packed uint64 (byte 0 in LSB — matches esp32's address_uint64).
 
const uint8_t * address () const
 Raw MAC bytes in printable (MSB-first) order — matches the historical esp32 layout (ESP-IDF bda order).
 
esp_ble_addr_type_t get_address_type () const
 
void parse_scan_rst (const esp32_ble::BLEScanResult &scan_result)
 Historical esp32 ingest (esp32 builds only): parse an ESP-IDF scan result.
 
const esp32_ble::BLEScanResult & get_scan_result () const
 
uint8_t get_address_type () const
 
int get_rssi () const
 
const std::string & get_name () const
 
const std::vector< ESPBTUUID > & get_service_uuids () const
 
const std::vector< ServiceData > & get_manufacturer_datas () const
 
const std::vector< ServiceData > & get_service_datas () const
 
const std::vector< int8_t > & get_tx_powers () const
 
const optional< uint16_t > & get_appearance () const
 
const optional< uint8_t > & get_ad_flag () const
 
bool resolve_irk (const uint8_t *irk) const
 Resolve a Resolvable Private Address against a 16-byte IRK (Bluetooth "ah" function, AES-128).
 
optional< ESPBLEiBeaconget_ibeacon () const
 

Static Public Attributes

static constexpr size_t MAC_ADDRESS_PRETTY_BUFFER_SIZE = esphome::MAC_ADDRESS_PRETTY_BUFFER_SIZE
 

Protected Member Functions

void parse_adv_ (const uint8_t *payload, uint16_t len)
 

Protected Attributes

uint8_t address_ [6] {0}
 
uint8_t address_type_ {0}
 
int rssi_ {0}
 
std::string name_ {}
 
std::vector< ESPBTUUIDservice_uuids_ {}
 
std::vector< ServiceDatamanufacturer_datas_ {}
 
std::vector< ServiceDataservice_datas_ {}
 
const esp32_ble::BLEScanResult * scan_result_ {nullptr}
 
std::vector< int8_t > tx_powers_ {}
 
optional< uint16_t > appearance_ {}
 
optional< uint8_t > ad_flag_ {}
 

Detailed Description

Definition at line 151 of file ble_device.h.

Member Function Documentation

◆ address()

const uint8_t * esphome::ble_device_base::ESPBTDevice::address ( ) const
inline

Raw MAC bytes in printable (MSB-first) order — matches the historical esp32 layout (ESP-IDF bda order).

Definition at line 173 of file ble_device.h.

◆ address_str()

std::string esphome::ble_device_base::ESPBTDevice::address_str ( ) const

Return MAC as "XX:XX:XX:XX:XX:XX" string.

Definition at line 344 of file ble_device.cpp.

◆ address_str_to() [1/2]

const char * esphome::ble_device_base::ESPBTDevice::address_str_to ( char * buf) const

Buffer overload: writes "XX:XX:XX:XX:XX:XX\0" into buf (>= 18 bytes), returns buf.

Definition at line 349 of file ble_device.cpp.

◆ address_str_to() [2/2]

const char * esphome::ble_device_base::ESPBTDevice::address_str_to ( std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf) const
inline

Definition at line 165 of file ble_device.h.

◆ address_uint64()

uint64_t esphome::ble_device_base::ESPBTDevice::address_uint64 ( ) const

Return MAC as packed uint64 (byte 0 in LSB — matches esp32's address_uint64).

Definition at line 355 of file ble_device.cpp.

◆ from_scan_result()

void esphome::ble_device_base::ESPBTDevice::from_scan_result ( const uint8_t * mac,
int rssi,
uint8_t addr_type,
const uint8_t * data,
uint16_t data_len )

Populate from a raw scan result delivered by a BLE tracker backend.

mac is least-significant octet first (BLE controller convention).

Definition at line 267 of file ble_device.cpp.

◆ get_ad_flag()

const optional< uint8_t > & esphome::ble_device_base::ESPBTDevice::get_ad_flag ( ) const
inline

Definition at line 193 of file ble_device.h.

◆ get_address_type() [1/2]

esp_ble_addr_type_t esphome::ble_device_base::ESPBTDevice::get_address_type ( ) const
inline

Definition at line 176 of file ble_device.h.

◆ get_address_type() [2/2]

uint8_t esphome::ble_device_base::ESPBTDevice::get_address_type ( ) const
inline

Definition at line 182 of file ble_device.h.

◆ get_appearance()

const optional< uint16_t > & esphome::ble_device_base::ESPBTDevice::get_appearance ( ) const
inline

Definition at line 192 of file ble_device.h.

◆ get_ibeacon()

optional< ESPBLEiBeacon > esphome::ble_device_base::ESPBTDevice::get_ibeacon ( ) const
inline

Definition at line 200 of file ble_device.h.

◆ get_manufacturer_datas()

const std::vector< ServiceData > & esphome::ble_device_base::ESPBTDevice::get_manufacturer_datas ( ) const
inline

Definition at line 189 of file ble_device.h.

◆ get_name()

const std::string & esphome::ble_device_base::ESPBTDevice::get_name ( ) const
inline

Definition at line 186 of file ble_device.h.

◆ get_rssi()

int esphome::ble_device_base::ESPBTDevice::get_rssi ( ) const
inline

Definition at line 185 of file ble_device.h.

◆ get_scan_result()

const esp32_ble::BLEScanResult & esphome::ble_device_base::ESPBTDevice::get_scan_result ( ) const
inline

Definition at line 180 of file ble_device.h.

◆ get_service_datas()

const std::vector< ServiceData > & esphome::ble_device_base::ESPBTDevice::get_service_datas ( ) const
inline

Definition at line 190 of file ble_device.h.

◆ get_service_uuids()

const std::vector< ESPBTUUID > & esphome::ble_device_base::ESPBTDevice::get_service_uuids ( ) const
inline

Definition at line 188 of file ble_device.h.

◆ get_tx_powers()

const std::vector< int8_t > & esphome::ble_device_base::ESPBTDevice::get_tx_powers ( ) const
inline

Definition at line 191 of file ble_device.h.

◆ parse_adv_()

void esphome::ble_device_base::ESPBTDevice::parse_adv_ ( const uint8_t * payload,
uint16_t len )
protected

Definition at line 386 of file ble_device.cpp.

◆ parse_scan_rst()

void esphome::ble_device_base::ESPBTDevice::parse_scan_rst ( const esp32_ble::BLEScanResult & scan_result)

Historical esp32 ingest (esp32 builds only): parse an ESP-IDF scan result.

Definition at line 128 of file ble_device.cpp.

◆ resolve_irk()

bool esphome::ble_device_base::ESPBTDevice::resolve_irk ( const uint8_t * irk) const

Resolve a Resolvable Private Address against a 16-byte IRK (Bluetooth "ah" function, AES-128).

Uses the portable software AES shared with the CCM decryptor; compiled only when a sensor configures irk: (request_irk_support).

Definition at line 363 of file ble_device.cpp.

Field Documentation

◆ ad_flag_

optional<uint8_t> esphome::ble_device_base::ESPBTDevice::ad_flag_ {}
protected

Definition at line 224 of file ble_device.h.

◆ address_

uint8_t esphome::ble_device_base::ESPBTDevice::address_[6] {0}
protected

Definition at line 212 of file ble_device.h.

◆ address_type_

uint8_t esphome::ble_device_base::ESPBTDevice::address_type_ {0}
protected

Definition at line 213 of file ble_device.h.

◆ appearance_

optional<uint16_t> esphome::ble_device_base::ESPBTDevice::appearance_ {}
protected

Definition at line 223 of file ble_device.h.

◆ MAC_ADDRESS_PRETTY_BUFFER_SIZE

size_t esphome::ble_device_base::ESPBTDevice::MAC_ADDRESS_PRETTY_BUFFER_SIZE = esphome::MAC_ADDRESS_PRETTY_BUFFER_SIZE
staticconstexpr

Definition at line 158 of file ble_device.h.

◆ manufacturer_datas_

std::vector<ServiceData> esphome::ble_device_base::ESPBTDevice::manufacturer_datas_ {}
protected

Definition at line 217 of file ble_device.h.

◆ name_

std::string esphome::ble_device_base::ESPBTDevice::name_ {}
protected

Definition at line 215 of file ble_device.h.

◆ rssi_

int esphome::ble_device_base::ESPBTDevice::rssi_ {0}
protected

Definition at line 214 of file ble_device.h.

◆ scan_result_

const esp32_ble::BLEScanResult* esphome::ble_device_base::ESPBTDevice::scan_result_ {nullptr}
protected

Definition at line 220 of file ble_device.h.

◆ service_datas_

std::vector<ServiceData> esphome::ble_device_base::ESPBTDevice::service_datas_ {}
protected

Definition at line 218 of file ble_device.h.

◆ service_uuids_

std::vector<ESPBTUUID> esphome::ble_device_base::ESPBTDevice::service_uuids_ {}
protected

Definition at line 216 of file ble_device.h.

◆ tx_powers_

std::vector<int8_t> esphome::ble_device_base::ESPBTDevice::tx_powers_ {}
protected

Definition at line 222 of file ble_device.h.


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