ESPHome 2026.9.1
Loading...
Searching...
No Matches
esphome::ble_device_base::ESPBTUUID Class Reference

#include <ble_device.h>

Public Types

enum class  Type : uint8_t { UNSET , UUID16 , UUID32 , UUID128 }
 

Public Member Functions

 ESPBTUUID ()=default
 
esp_bt_uuid_t get_uuid () const
 
ESPBTUUID as_128bit () const
 Expand to the 128-bit Bluetooth Base UUID form.
 
bool contains (uint8_t data1, uint8_t data2) const
 True if the UUID value contains the adjacent byte pair (data1, data2).
 
bool operator== (const ESPBTUUID &other) const
 
bool operator!= (const ESPBTUUID &other) const
 
const char * to_str (char *buf) const
 Write "0xABCD" / "0xABCDEF01" / the dashed 128-bit form, or "None" for an unset UUID, into buf (>= UUID_STR_LEN bytes) and return buf.
 
const char * to_str (std::span< char, UUID_STR_LEN > output) const
 
Type type () const
 
bool is_set () const
 True if a UUID has been configured (not default-constructed).
 
uint16_t uuid16 () const
 
uint32_t uuid32 () const
 
const uint8_t * uuid128 () const
 

Static Public Member Functions

static ESPBTUUID from_uint16 (uint16_t uuid)
 
static ESPBTUUID from_uint32 (uint32_t uuid)
 
static ESPBTUUID from_raw (const uint8_t *data)
 Construct from raw 16-byte little-endian UUID.
 
static ESPBTUUID from_raw_reversed (const uint8_t *data)
 Construct from raw 16-byte big-endian UUID (reversed on store).
 
static ESPBTUUID from_raw (const char *data, size_t length)
 Parse from text: 4 hex chars (16-bit), 8 hex chars (32-bit), 16 raw bytes, or the 36-char dashed UUID form.
 
static ESPBTUUID from_raw (const char *data)
 
static ESPBTUUID from_raw (const std::string &data)
 
static ESPBTUUID from_raw (std::initializer_list< uint8_t > data)
 
static ESPBTUUID from_uuid (esp_bt_uuid_t uuid)
 Source compatibility with the historical esp32_ble API (esp32 builds only).
 

Protected Member Functions

void to_128bit_ (uint8_t out[16]) const
 

Protected Attributes

Type type_ {Type::UNSET}
 
union { 
 
   uint16_t   uuid16 
 
   uint32_t   uuid32 
 
   uint8_t   uuid128 [16] 
 
} uuid_ 
 

Detailed Description

Definition at line 55 of file ble_device.h.

Member Enumeration Documentation

◆ Type

enum class esphome::ble_device_base::ESPBTUUID::Type : uint8_t
strong
Enumerator
UNSET 
UUID16 
UUID32 
UUID128 

Definition at line 96 of file ble_device.h.

Constructor & Destructor Documentation

◆ ESPBTUUID()

esphome::ble_device_base::ESPBTUUID::ESPBTUUID ( )
default

Member Function Documentation

◆ as_128bit()

ESPBTUUID esphome::ble_device_base::ESPBTUUID::as_128bit ( ) const

Expand to the 128-bit Bluetooth Base UUID form.

Definition at line 148 of file ble_device.cpp.

◆ contains()

bool esphome::ble_device_base::ESPBTUUID::contains ( uint8_t data1,
uint8_t data2 ) const

True if the UUID value contains the adjacent byte pair (data1, data2).

Definition at line 157 of file ble_device.cpp.

◆ from_raw() [1/5]

static ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_raw ( const char * data)
inlinestatic

Definition at line 68 of file ble_device.h.

◆ from_raw() [2/5]

ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_raw ( const char * data,
size_t length )
static

Parse from text: 4 hex chars (16-bit), 8 hex chars (32-bit), 16 raw bytes, or the 36-char dashed UUID form.

Same semantics as esp32_ble historically.

Definition at line 58 of file ble_device.cpp.

◆ from_raw() [3/5]

static ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_raw ( const std::string & data)
inlinestatic

Definition at line 69 of file ble_device.h.

◆ from_raw() [4/5]

ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_raw ( const uint8_t * data)
static

Construct from raw 16-byte little-endian UUID.

Definition at line 43 of file ble_device.cpp.

◆ from_raw() [5/5]

static ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_raw ( std::initializer_list< uint8_t > data)
inlinestatic

Definition at line 70 of file ble_device.h.

◆ from_raw_reversed()

ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_raw_reversed ( const uint8_t * data)
static

Construct from raw 16-byte big-endian UUID (reversed on store).

Definition at line 50 of file ble_device.cpp.

◆ from_uint16()

ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_uint16 ( uint16_t uuid)
static

Definition at line 29 of file ble_device.cpp.

◆ from_uint32()

ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_uint32 ( uint32_t uuid)
static

Definition at line 36 of file ble_device.cpp.

◆ from_uuid()

ESPBTUUID esphome::ble_device_base::ESPBTUUID::from_uuid ( esp_bt_uuid_t uuid)
static

Source compatibility with the historical esp32_ble API (esp32 builds only).

Definition at line 101 of file ble_device.cpp.

◆ get_uuid()

esp_bt_uuid_t esphome::ble_device_base::ESPBTUUID::get_uuid ( ) const

Definition at line 111 of file ble_device.cpp.

◆ is_set()

bool esphome::ble_device_base::ESPBTUUID::is_set ( ) const
inline

True if a UUID has been configured (not default-constructed).

Definition at line 99 of file ble_device.h.

◆ operator!=()

bool esphome::ble_device_base::ESPBTUUID::operator!= ( const ESPBTUUID & other) const
inline

Definition at line 87 of file ble_device.h.

◆ operator==()

bool esphome::ble_device_base::ESPBTUUID::operator== ( const ESPBTUUID & other) const

Definition at line 237 of file ble_device.cpp.

◆ to_128bit_()

void esphome::ble_device_base::ESPBTUUID::to_128bit_ ( uint8_t out[16]) const
protected

Definition at line 220 of file ble_device.cpp.

◆ to_str() [1/2]

const char * esphome::ble_device_base::ESPBTUUID::to_str ( char * buf) const

Write "0xABCD" / "0xABCDEF01" / the dashed 128-bit form, or "None" for an unset UUID, into buf (>= UUID_STR_LEN bytes) and return buf.

Definition at line 182 of file ble_device.cpp.

◆ to_str() [2/2]

const char * esphome::ble_device_base::ESPBTUUID::to_str ( std::span< char, UUID_STR_LEN > output) const
inline

Definition at line 93 of file ble_device.h.

◆ type()

Type esphome::ble_device_base::ESPBTUUID::type ( ) const
inline

Definition at line 97 of file ble_device.h.

◆ uuid128()

const uint8_t * esphome::ble_device_base::ESPBTUUID::uuid128 ( ) const
inline

Definition at line 102 of file ble_device.h.

◆ uuid16()

uint16_t esphome::ble_device_base::ESPBTUUID::uuid16 ( ) const
inline

Definition at line 100 of file ble_device.h.

◆ uuid32()

uint32_t esphome::ble_device_base::ESPBTUUID::uuid32 ( ) const
inline

Definition at line 101 of file ble_device.h.

Field Documentation

◆ type_

Type esphome::ble_device_base::ESPBTUUID::type_ {Type::UNSET}
protected

Definition at line 108 of file ble_device.h.

◆ uuid128

uint8_t esphome::ble_device_base::ESPBTUUID::uuid128[16]

Definition at line 112 of file ble_device.h.

◆ uuid16

uint16_t esphome::ble_device_base::ESPBTUUID::uuid16

Definition at line 110 of file ble_device.h.

◆ uuid32

uint32_t esphome::ble_device_base::ESPBTUUID::uuid32

Definition at line 111 of file ble_device.h.

◆ [union]

union { ... } esphome::ble_device_base::ESPBTUUID::uuid_

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