NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLEAddress Class Reference

A BLE device address. More...

#include <NimBLEAddress.h>

Inherits ble_addr_t.

Public Member Functions

 NimBLEAddress ()=default
 Create a blank address, i.e. 00:00:00:00:00:00, type 0.
 
 NimBLEAddress (const ble_addr_t address)
 Create an address from the native NimBLE representation.
 
 NimBLEAddress (const uint8_t address[BLE_DEV_ADDR_LEN], uint8_t type)
 Constructor for compatibility with bluedroid esp library using native ESP representation.
 
 NimBLEAddress (const std::string &stringAddress, uint8_t type)
 Create an address from a hex string.
 
 NimBLEAddress (const uint64_t &address, uint8_t type)
 Constructor for address using a hex value.
Use the same byte order, so use 0xa4c1385def16 for "a4:c1:38:5d:ef:16".
 
bool isRpa () const
 Determine if this address is a Resolvable Private Address.
 
bool isNrpa () const
 Determine if this address is a Non-Resolvable Private Address.
 
bool isStatic () const
 Determine if this address is a Static Address.
 
bool isPublic () const
 Determine if this address is a Public Address.
 
bool isNull () const
 Determine if this address is a NULL Address.
 
bool equals (const NimBLEAddress &otherAddress) const
 Determine if this address equals another.
 
const ble_addr_t * getBase () const
 Get the NimBLE base struct of the address.
 
std::string toString () const
 Convert a BLE address to a string.
 
uint8_t getType () const
 Get the address type.
 
const uint8_t * getVal () const
 Get the address value.
 
const NimBLEAddressreverseByteOrder ()
 Reverse the byte order of the address.
 
bool operator== (const NimBLEAddress &rhs) const
 Convenience operator to check if this address is equal to another.
 
bool operator!= (const NimBLEAddress &rhs) const
 Convenience operator to check if this address is not equal to another.
 
 operator std::string () const
 Convenience operator to convert this address to string representation.
 
 operator uint64_t () const
 Convenience operator to convert the native address representation to uint_64.
 

Detailed Description

A BLE device address.

Every BLE device has a unique address which can be used to identify it and form connections.

Constructor & Destructor Documentation

◆ NimBLEAddress() [1/4]

NimBLEAddress::NimBLEAddress ( const ble_addr_t  address)

Create an address from the native NimBLE representation.

Parameters
[in]addressThe native NimBLE address.

◆ NimBLEAddress() [2/4]

NimBLEAddress::NimBLEAddress ( const uint8_t  address[BLE_DEV_ADDR_LEN],
uint8_t  type 
)

Constructor for compatibility with bluedroid esp library using native ESP representation.

Parameters
[in]addressA uint8_t[6] or esp_bd_addr_t containing the address.
[in]typeThe type of the address should be one of:
  • BLE_ADDR_PUBLIC (0)
  • BLE_ADDR_RANDOM (1)

◆ NimBLEAddress() [3/4]

NimBLEAddress::NimBLEAddress ( const std::string &  addr,
uint8_t  type 
)

Create an address from a hex string.

A hex string is of the format:

00:00:00:00:00:00

which is 17 characters in length.

Parameters
[in]addrThe hex string representation of the address.
[in]typeThe type of the address, should be one of:
  • BLE_ADDR_PUBLIC (0)
  • BLE_ADDR_RANDOM (1)

◆ NimBLEAddress() [4/4]

NimBLEAddress::NimBLEAddress ( const uint64_t &  address,
uint8_t  type 
)

Constructor for address using a hex value.
Use the same byte order, so use 0xa4c1385def16 for "a4:c1:38:5d:ef:16".

Parameters
[in]addressuint64_t containing the address.
[in]typeThe type of the address should be one of:
  • BLE_ADDR_PUBLIC (0)
  • BLE_ADDR_RANDOM (1)

Member Function Documentation

◆ equals()

bool NimBLEAddress::equals ( const NimBLEAddress otherAddress) const

Determine if this address equals another.

Parameters
[in]otherAddressThe other address to compare against.
Returns
True if the addresses are equal.

◆ getBase()

const ble_addr_t * NimBLEAddress::getBase ( ) const

Get the NimBLE base struct of the address.

Returns
A read only reference to the NimBLE base struct of the address.

◆ getType()

uint8_t NimBLEAddress::getType ( ) const

Get the address type.

Returns
The address type.

◆ getVal()

const uint8_t * NimBLEAddress::getVal ( ) const

Get the address value.

Returns
A read only reference to the address value.

◆ isNrpa()

bool NimBLEAddress::isNrpa ( ) const

Determine if this address is a Non-Resolvable Private Address.

Returns
True if the address is a NRPA.

◆ isNull()

bool NimBLEAddress::isNull ( ) const

Determine if this address is a NULL Address.

Returns
True if the address is a NULL Address.

◆ isPublic()

bool NimBLEAddress::isPublic ( ) const

Determine if this address is a Public Address.

Returns
True if the address is a Public Address.

◆ isRpa()

bool NimBLEAddress::isRpa ( ) const

Determine if this address is a Resolvable Private Address.

Returns
True if the address is a RPA.

◆ isStatic()

bool NimBLEAddress::isStatic ( ) const

Determine if this address is a Static Address.

Returns
True if the address is a Static Address.

◆ operator std::string()

NimBLEAddress::operator std::string ( ) const

Convenience operator to convert this address to string representation.

This allows passing NimBLEAddress to functions that accept std::string and/or it's methods as a parameter.

◆ reverseByteOrder()

const NimBLEAddress & NimBLEAddress::reverseByteOrder ( )

Reverse the byte order of the address.

Returns
A reference to this address.

◆ toString()

std::string NimBLEAddress::toString ( ) const

Convert a BLE address to a string.

Returns
The string representation of the address.
Deprecated:
Use std::string() operator instead.