ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
c7222::BleAddress Class Reference

BLE address container with an associated address type. More...

#include <ble_address.hpp>

Collaboration diagram for c7222::BleAddress:
Collaboration graph

Public Types

enum class  AddressType : uint8_t {
  kLePublic = 0x00 , kLeRandom = 0x01 , kLePublicIdentity = 0x02 , kLeRandomIdentity = 0x03 ,
  kSco = 0x04 , kAcl = 0x05 , kUnknown = 0xFF
}
 Bluetooth address types (BTstack-compatible values). More...
 
using RawAddress = std::array< uint8_t, kLength >
 Raw 6-byte address container.
 

Public Member Functions

 BleAddress ()=default
 Constructs an empty address with type Unknown and zero bytes.
 
 BleAddress (AddressType type, const RawAddress &address)
 Constructs from address type and raw Bluetooth address.
 
 BleAddress (AddressType type, const uint8_t address[kLength])
 Constructs from address type and a raw 6-byte buffer.
 
AddressType GetType () const
 Returns the stored address type.
 
void SetType (AddressType type)
 Sets the address type.
 
const uint8_t * GetBytes () const
 Returns a pointer to the raw address bytes.
 
const RawAddressGetRaw () const
 Returns a const reference to the raw address array.
 
void CopyTo (RawAddress &out) const
 Copies the raw address into a caller-provided buffer.
 
void CopyTo (uint8_t(&out)[kLength]) const
 Copies the raw address into a caller-provided array.
 
bool operator== (const BleAddress &other) const
 Compares both address type and address bytes.
 
bool operator!= (const BleAddress &other) const
 Compares both address type and address bytes.
 

Static Public Member Functions

static const RawAddressNullAddress ()
 Returns a zero-filled address constant.
 

Static Public Attributes

static constexpr size_t kLength = 6
 Number of bytes in a BLE device address.
 

Friends

std::ostream & operator<< (std::ostream &os, const BleAddress &addr)
 Stream output helper.
 

Detailed Description

BLE address container with an associated address type.

A BLE address is a 6-byte value plus an address type (public/random/etc).


Construction

Create an address from a raw 6-byte buffer and a type:

c7222::BleAddress::RawAddress raw = {0xC0, 0xFF, 0xEE, 0xBA, 0xBE, 0x01};
BLE address container with an associated address type.
Definition ble_address.hpp:43
@ kLeRandom
Random Device Address (Vol 3, Part C, 10.8.2).
std::array< uint8_t, kLength > RawAddress
Raw 6-byte address container.
Definition ble_address.hpp:53

Accessors and Utilities


Comparison

Equality compares both the address type and address bytes.

Member Typedef Documentation

◆ RawAddress

using c7222::BleAddress::RawAddress = std::array<uint8_t, kLength>

Raw 6-byte address container.

Member Enumeration Documentation

◆ AddressType

enum class c7222::BleAddress::AddressType : uint8_t
strong

Bluetooth address types (BTstack-compatible values).

Enumerator
kLePublic 

Public Device Address (Vol 3, Part C, 10.8.1).

kLeRandom 

Random Device Address (Vol 3, Part C, 10.8.2).

kLePublicIdentity 

Public Identity Address (resolvable via IRK).

kLeRandomIdentity 

Random (static or resolvable) Identity Address.

kSco 

BR/EDR (SCO) address type.

kAcl 

BR/EDR (ACL) address type.

kUnknown 

Unknown or not provided.

Constructor & Destructor Documentation

◆ BleAddress() [1/3]

c7222::BleAddress::BleAddress ( )
default

Constructs an empty address with type Unknown and zero bytes.

◆ BleAddress() [2/3]

c7222::BleAddress::BleAddress ( AddressType  type,
const RawAddress address 
)
inline

Constructs from address type and raw Bluetooth address.

Example:

@ kLePublic
Public Device Address (Vol 3, Part C, 10.8.1).

◆ BleAddress() [3/3]

c7222::BleAddress::BleAddress ( AddressType  type,
const uint8_t  address[kLength] 
)
inline

Constructs from address type and a raw 6-byte buffer.

Member Function Documentation

◆ CopyTo() [1/2]

void c7222::BleAddress::CopyTo ( RawAddress out) const
inline

Copies the raw address into a caller-provided buffer.

◆ CopyTo() [2/2]

void c7222::BleAddress::CopyTo ( uint8_t(&)  out[kLength]) const
inline

Copies the raw address into a caller-provided array.

◆ GetBytes()

const uint8_t * c7222::BleAddress::GetBytes ( ) const
inline

Returns a pointer to the raw address bytes.

◆ GetRaw()

const RawAddress & c7222::BleAddress::GetRaw ( ) const
inline

Returns a const reference to the raw address array.

◆ GetType()

AddressType c7222::BleAddress::GetType ( ) const
inline

Returns the stored address type.

◆ NullAddress()

static const RawAddress & c7222::BleAddress::NullAddress ( )
inlinestatic

Returns a zero-filled address constant.

◆ operator!=()

bool c7222::BleAddress::operator!= ( const BleAddress other) const
inline

Compares both address type and address bytes.

◆ operator==()

bool c7222::BleAddress::operator== ( const BleAddress other) const
inline

Compares both address type and address bytes.

◆ SetType()

void c7222::BleAddress::SetType ( AddressType  type)
inline

Sets the address type.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const BleAddress addr 
)
friend

Stream output helper.

Member Data Documentation

◆ kLength

constexpr size_t c7222::BleAddress::kLength = 6
staticconstexpr

Number of bytes in a BLE device address.


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