/*
* Author: Sven Gothel
* BT Core Spec v5.2: Vol 6 LE, Part B Link Layer Specification: 1.3.2 Random device Address
*
* Table 1.2, address bits [47:46]
*
* If {@link BDAddressType} is {@link BDAddressType::BDADDR_LE_RANDOM},
* its value shall be different than {@link BLERandomAddressType::UNDEFINED}.
*
* If {@link BDAddressType} is not {@link BDAddressType::BDADDR_LE_RANDOM},
* its value shall be {@link BLERandomAddressType::UNDEFINED}.
*
* BT Core Spec v5.2: Vol 4, Part E Host Controller Interface (HCI) Functionality:
*
* 1) BT public address used as BD_ADDR for BR/EDR physical channel is defined in Vol 2, Part B 1.2
* - EUI-48 or MAC (6 octets)
*
* 2) BT public address used as BD_ADDR for the LE physical channel is defined in Vol 6, Part B 1.3
* BT Core Spec v5.2: Vol 3, Part C Generic Access Profile (GAP): 15.1.1.2 Random Bluetooth address
*
* 3) BT random address used as BD_ADDR on the LE physical channel is defined in Vol 3, Part C 10.8
*
*/
enum BDAddressType : uint8_t {
/** Bluetooth BREDR address */
BDADDR_BREDR = 0x00,
/** Bluetooth LE public address */
BDADDR_LE_PUBLIC = 0x01,
/** Bluetooth LE random address, see {@link BLERandomAddressType} */
BDADDR_LE_RANDOM = 0x02,
/** Undefined */
BDADDR_UNDEFINED = 0xff
};
std::string getBDAddressTypeString(const BDAddressType type);
/**
* BT Core Spec v5.2: Vol 6 LE, Part B Link Layer Specification: 1.3 Device Address
*
* > 7.8.5: LE Set Advertising Parameters command
* -- Own_Address_Type: public: 0x00 (default), random: 0x01, resolvable-1: 0x02, resolvable-2: 0x03
* > 7.8.10: LE Set Scan Parameters command
* -- Own_Address_Type: public: 0x00 (default), random: 0x01, resolvable-1: 0x02, resolvable-2: 0x03
* > 7.8.12: LE Create Connection command
* -- Own_Address_Type: public: 0x00 (default), random: 0x01,
* Public Identity Address (resolvable-1, any not supporting LE_Set_Privacy_Mode command): 0x02,
* Random (static) Identity Address (resolvable-2, any not supporting LE_Set_Privacy_Mode command): 0x03
*
*
* Since we utilize this type within *ioctl* _and_ our high-level *types*, * declaration is not within our *direct_bt* namespace. *
*/ struct __attribute__((packed)) EUI48 { uint8_t b[6]; // == sizeof(EUI48) EUI48() { bzero(b, sizeof(EUI48)); } EUI48(const uint8_t * b); EUI48(const std::string mac); EUI48(const EUI48 &o) noexcept = default; EUI48(EUI48 &&o) noexcept = default; EUI48& operator=(const EUI48 &o) noexcept = default; EUI48& operator=(EUI48 &&o) noexcept = default; BLERandomAddressType getBLERandomAddressType(const BDAddressType addressType) const; std::string toString() const; }; inline bool operator<(const EUI48& lhs, const EUI48& rhs) { return memcmp(&lhs, &rhs, sizeof(EUI48))<0; } inline bool operator==(const EUI48& lhs, const EUI48& rhs) { return !memcmp(&lhs, &rhs, sizeof(EUI48)); } inline bool operator!=(const EUI48& lhs, const EUI48& rhs) { return !(lhs == rhs); } /** EUI48 MAC address matching any device, i.e. '0:0:0:0:0:0'. */ extern const EUI48 EUI48_ANY_DEVICE; /** EUI48 MAC address matching all device, i.e. 'ff:ff:ff:ff:ff:ff'. */ extern const EUI48 EUI48_ALL_DEVICE; /** EUI48 MAC address matching local device, i.e. '0:0:0:ff:ff:ff'. */ extern const EUI48 EUI48_LOCAL_DEVICE; } // namespace direct_bt #endif /* BT_ADDRESS_HPP_ */