Add isRpa method to NimBLEAddress.

This provides and easy way to check if the peer address is a Resolvable Private Address.
This commit is contained in:
h2zero 2024-06-12 09:30:16 -06:00 committed by h2zero
parent ef90a8aa95
commit c156b0202c
2 changed files with 10 additions and 0 deletions

View file

@ -138,6 +138,15 @@ uint8_t NimBLEAddress::getType() const {
} // getType
/**
* @brief Determine if this address is a Resolvable Private Address.
* @return True if the address is a RPA.
*/
bool NimBLEAddress::isRpa() const {
return (m_addrType && ((m_address[5] & 0xc0) == 0x40));
} // isRpa
/**
* @brief Convert a BLE address to a string.
*

View file

@ -43,6 +43,7 @@ public:
NimBLEAddress(uint8_t address[6], uint8_t type = BLE_ADDR_PUBLIC);
NimBLEAddress(const std::string &stringAddress, uint8_t type = BLE_ADDR_PUBLIC);
NimBLEAddress(const uint64_t &address, uint8_t type = BLE_ADDR_PUBLIC);
bool isRpa() const;
bool equals(const NimBLEAddress &otherAddress) const;
const uint8_t* getNative() const;
std::string toString() const;