aboutsummaryrefslogtreecommitdiffstats
path: root/api/direct_bt/BTAddress.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'api/direct_bt/BTAddress.hpp')
-rw-r--r--api/direct_bt/BTAddress.hpp176
1 files changed, 116 insertions, 60 deletions
diff --git a/api/direct_bt/BTAddress.hpp b/api/direct_bt/BTAddress.hpp
index 1c13ad71..b2702a7f 100644
--- a/api/direct_bt/BTAddress.hpp
+++ b/api/direct_bt/BTAddress.hpp
@@ -30,86 +30,142 @@
#include <string>
#include <cstdint>
-/**
- * A packed 48 bit EUI-48 identifier, formerly known as MAC-48
- * or simply network device MAC address (Media Access Control address).
- * <p>
- * Since we utilize this type within *ioctl* _and_ our high-level *types*,
- * declaration is not within our *direct_bt* namespace.
- * </p>
- */
-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;
-
- 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 {
/**
* BT Core Spec v5.2: Vol 3, Part C Generic Access Profile (GAP): 15.1.1.1 Public Bluetooth address
+ * <pre>
* 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
- *
+ * </pre>
+ * <p>
* BT Core Spec v5.2: Vol 3, Part C Generic Access Profile (GAP): 15.1.1.2 Random Bluetooth address
+ * <pre>
* 3) BT random address used as BD_ADDR on the LE physical channel is defined in Vol 3, Part C 10.8
- *
- * +++
- *
- * For HCI LE Address-Type it is: PUBLIC: 0x00, RANDOM: 0x01
- *
- * BT Core Spec v5.2: Vol 4, Part E Host Controller Interface (HCI) Functionality:
- *
- * > 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
- *
- * +++
- *
- * Couldn't yet find a reference to the BDADDR/L2CAP Address Type, which differs from HCI Address Type!
+ * </pre>
*/
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
};
- enum HCIAddressType : uint8_t {
- HCIADDR_LE_PUBLIC = 0x00,
- HCIADDR_LE_RANDOM = 0x01,
- HCIADDR_UNDEFINED = 0xff
+ std::string getBDAddressTypeString(const BDAddressType op);
+
+ /**
+ * BT Core Spec v5.2: Vol 6 LE, Part B Link Layer Specification: 1.3 Device Address
+ * <p>
+ * BT Core Spec v5.2: Vol 6 LE, Part B Link Layer Specification: 1.3.2 Random device Address
+ * </p>
+ * <p>
+ * Table 1.2, address bits [47:46]
+ * </p>
+ * <p>
+ * If {@link BDAddressType} is {@link BDAddressType::BDADDR_LE_RANDOM},
+ * its value shall be different than {@link BLERandomAddressType::UNDEFINED}.
+ * </p>
+ * <p>
+ * If {@link BDAddressType} is not {@link BDAddressType::BDADDR_LE_RANDOM},
+ * its value shall be {@link BLERandomAddressType::UNDEFINED}.
+ * </p>
+ */
+ enum class BLERandomAddressType : uint8_t {
+ /** Non-resolvable private random device address 0b00 */
+ UNRESOLVABLE_PRIVAT = 0x00,
+ /** Resolvable private random device address 0b01 */
+ RESOLVABLE_PRIVAT = 0x01,
+ /** Reserved for future use 0b10 */
+ RESERVED = 0x02,
+ /** Static public 'random' device address 0b11 */
+ STATIC_PUBLIC = 0x03,
+ /** Undefined */
+ UNDEFINED = 0xff
+ };
+ std::string getBLERandomAddressTypeString(const BLERandomAddressType op);
+
+ /**
+ * HCI LE Address-Type is PUBLIC: 0x00, RANDOM: 0x01
+ * <p>
+ * BT Core Spec v5.2: Vol 4, Part E Host Controller Interface (HCI) Functionality:
+ * <pre>
+ * > 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
+ * </pre>
+ * </p>
+ */
+ enum class HCILEPeerAddressType : uint8_t {
+ PUBLIC = 0x00,/**< HCIADDR_LE_PUBLIC */
+ RANDOM = 0x01,/**< HCIADDR_LE_RANDOM */
+ PUBLIC_IDENTITY = 0x02,
+ RANDOM_STATIC_IDENTITY = 0x03,
+ UNDEFINED = 0xff /**< HCIADDR_UNDEFINED */
};
- BDAddressType getBDAddressType(const HCIAddressType hciAddrType);
- std::string getBDAddressTypeString(const BDAddressType op);
+ BDAddressType getBDAddressType(const HCILEPeerAddressType hciPeerAddrType);
+
+ enum class HCILEOwnAddressType : uint8_t {
+ PUBLIC = 0x00,
+ RANDOM = 0x01,
+ RESOLVABLE_OR_PUBLIC = 0x02,
+ RESOLVABLE_OR_RANDOM = 0x03,
+ UNDEFINED = 0xff
+ };
+
+ BDAddressType getBDAddressType(const HCILEOwnAddressType hciOwnAddrType);
+
+ /**
+ * A packed 48 bit EUI-48 identifier, formerly known as MAC-48
+ * or simply network device MAC address (Media Access Control address).
+ * <p>
+ * Since we utilize this type within *ioctl* _and_ our high-level *types*,
+ * declaration is not within our *direct_bt* namespace.
+ * </p>
+ */
+ 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;
+ 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); }
+
+ std::string getBLERandomAddressTypeString(const EUI48 &a);
+
+ /** 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