|
ESPHome 2026.8.0b4
|
#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. | |
| ESPDEPRECATED("Use address_str_to() instead. Removed in 2027.2.0.", "2026.8.0") std const char * | address_str_to (char *buf) const |
| Return MAC as "XX:XX:XX:XX:XX:XX" string. | |
| 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 |
| const char * | address_type_str () const |
| Human-readable address type ("PUBLIC", "RANDOM", "RPA_PUBLIC", "RPA_RANDOM" or "UNKNOWN"), backed by the shared BLE_ADDR_TYPE_* constants above. | |
| int | get_rssi () const |
| StringRef | get_name () const |
| Advertised name as a view into the fixed buffer (always NUL-terminated, so c_str() is safe); converts implicitly to std::string where needed. | |
| 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< ESPBLEiBeacon > | get_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_ [MAC_ADDRESS_SIZE] {0} |
| uint8_t | address_type_ {0} |
| int | rssi_ {0} |
| char | name_ [MAX_ADV_NAME_LEN+1] {} |
| uint8_t | name_len_ {0} |
| std::vector< ESPBTUUID > | service_uuids_ {} |
| std::vector< ServiceData > | manufacturer_datas_ {} |
| std::vector< ServiceData > | service_datas_ {} |
| const esp32_ble::BLEScanResult * | scan_result_ {nullptr} |
| std::vector< int8_t > | tx_powers_ {} |
| optional< uint16_t > | appearance_ {} |
| optional< uint8_t > | ad_flag_ {} |
Static Protected Attributes | |
| static constexpr uint8_t | MAX_ADV_NAME_LEN = 29 |
Definition at line 178 of file ble_device.h.
|
inline |
Raw MAC bytes in printable (MSB-first) order — matches the historical esp32 layout (ESP-IDF bda order).
Definition at line 201 of file ble_device.h.
| const char * esphome::ble_device_base::ESPBTDevice::address_str_to | ( | char * | buf | ) | const |
Return MAC as "XX:XX:XX:XX:XX:XX" string.
Writes "XX:XX:XX:XX:XX:XX\0" into buf (>= MAC_ADDRESS_PRETTY_BUFFER_SIZE bytes), returns buf.
Definition at line 418 of file ble_device.cpp.
|
inline |
Definition at line 193 of file ble_device.h.
| const char * esphome::ble_device_base::ESPBTDevice::address_type_str | ( | ) | const |
Human-readable address type ("PUBLIC", "RANDOM", "RPA_PUBLIC", "RPA_RANDOM" or "UNKNOWN"), backed by the shared BLE_ADDR_TYPE_* constants above.
Definition at line 329 of file ble_device.cpp.
| 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 424 of file ble_device.cpp.
| 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 344 of file ble_device.cpp.
|
inline |
Definition at line 228 of file ble_device.h.
|
inline |
Definition at line 204 of file ble_device.h.
|
inline |
Definition at line 212 of file ble_device.h.
|
inline |
Definition at line 227 of file ble_device.h.
| optional< ESPBLEiBeacon > esphome::ble_device_base::ESPBTDevice::get_ibeacon | ( | ) | const |
Definition at line 291 of file ble_device.cpp.
|
inline |
Definition at line 224 of file ble_device.h.
|
inline |
Advertised name as a view into the fixed buffer (always NUL-terminated, so c_str() is safe); converts implicitly to std::string where needed.
Definition at line 221 of file ble_device.h.
|
inline |
Definition at line 218 of file ble_device.h.
|
inline |
Definition at line 210 of file ble_device.h.
|
inline |
Definition at line 225 of file ble_device.h.
|
inline |
Definition at line 223 of file ble_device.h.
|
inline |
Definition at line 226 of file ble_device.h.
|
protected |
Definition at line 455 of file ble_device.cpp.
| 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.
Prefer ESPBTDevice::from_scan_result(); deprecation is a follow-up pending consumer feedback on the raw scan-result fields.
Definition at line 135 of file ble_device.cpp.
| 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 432 of file ble_device.cpp.
|
protected |
Definition at line 259 of file ble_device.h.
|
protected |
Definition at line 244 of file ble_device.h.
|
protected |
Definition at line 245 of file ble_device.h.
|
protected |
Definition at line 258 of file ble_device.h.
|
staticconstexpr |
Definition at line 185 of file ble_device.h.
|
protected |
Definition at line 252 of file ble_device.h.
|
staticconstexprprotected |
Definition at line 242 of file ble_device.h.
|
protected |
Definition at line 249 of file ble_device.h.
|
protected |
Definition at line 250 of file ble_device.h.
|
protected |
Definition at line 246 of file ble_device.h.
|
protected |
Definition at line 255 of file ble_device.h.
|
protected |
Definition at line 253 of file ble_device.h.
|
protected |
Definition at line 251 of file ble_device.h.
|
protected |
Definition at line 257 of file ble_device.h.