summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-12-12 11:24:29 +0100
committerSven Gothel <[email protected]>2020-12-12 11:24:29 +0100
commit4b8e48998989c07ea075f3aa9d9478c8046fae47 (patch)
tree5cb31358137ab2b0b12ce3e62f024445905e208a /api
parentbc9d1c0d2942ce24019b432198f2d4c0d00aee19 (diff)
Adopt new BDAddressAndType key value across project
See commit bc9d1c0d2942ce24019b432198f2d4c0d00aee19
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/DBTAdapter.hpp18
-rw-r--r--api/direct_bt/DBTDevice.hpp31
-rw-r--r--api/direct_bt/DBTManager.hpp27
-rw-r--r--api/direct_bt/HCIHandler.hpp65
-rw-r--r--api/direct_bt/L2CAPComm.hpp4
-rw-r--r--api/direct_bt/MgmtTypes.hpp104
6 files changed, 122 insertions, 127 deletions
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/DBTAdapter.hpp
index 3508a98d..66ec6d2d 100644
--- a/api/direct_bt/DBTAdapter.hpp
+++ b/api/direct_bt/DBTAdapter.hpp
@@ -231,9 +231,7 @@ namespace direct_bt {
bool validateDevInfo() noexcept;
- /** Returns index >= 0 if found, otherwise -1 */
- static int findDeviceIdx(std::vector<std::shared_ptr<DBTDevice>> & devices, EUI48 const & mac, const BDAddressType macType) noexcept;
- static std::shared_ptr<DBTDevice> findDevice(std::vector<std::shared_ptr<DBTDevice>> & devices, EUI48 const & mac, const BDAddressType macType) noexcept;
+ static std::shared_ptr<DBTDevice> findDevice(std::vector<std::shared_ptr<DBTDevice>> & devices, const EUI48 & address, const BDAddressType addressType) noexcept;
std::shared_ptr<DBTDevice> findDevice(std::vector<std::shared_ptr<DBTDevice>> & devices, DBTDevice const & device) noexcept;
/**
@@ -265,7 +263,7 @@ namespace direct_bt {
bool addConnectedDevice(const std::shared_ptr<DBTDevice> & device) noexcept;
bool removeConnectedDevice(const DBTDevice & device) noexcept;
int disconnectAllDevices(const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ) noexcept;
- std::shared_ptr<DBTDevice> findConnectedDevice (EUI48 const & mac, const BDAddressType macType) noexcept;
+ std::shared_ptr<DBTDevice> findConnectedDevice (const EUI48 & address, const BDAddressType & addressType) noexcept;
bool addDiscoveredDevice(std::shared_ptr<DBTDevice> const &device) noexcept;
bool removeDiscoveredDevice(const DBTDevice & device) noexcept;
@@ -275,7 +273,7 @@ namespace direct_bt {
bool addSharedDevice(std::shared_ptr<DBTDevice> const &device) noexcept;
std::shared_ptr<DBTDevice> getSharedDevice(const DBTDevice & device) noexcept;
void removeSharedDevice(const DBTDevice & device) noexcept;
- std::shared_ptr<DBTDevice> findSharedDevice (EUI48 const & mac, const BDAddressType macType) noexcept;
+ std::shared_ptr<DBTDevice> findSharedDevice (const EUI48 & address, const BDAddressType addressType) noexcept;
bool mgmtEvNewSettingsMgmt(std::shared_ptr<MgmtEvent> e) noexcept;
bool mgmtEvDeviceDiscoveringMgmt(std::shared_ptr<MgmtEvent> e) noexcept;
@@ -302,7 +300,7 @@ namespace direct_bt {
bool mgmtEvAuthFailedMgmt(std::shared_ptr<MgmtEvent> e) noexcept;
bool mgmtEvDeviceUnpairedMgmt(std::shared_ptr<MgmtEvent> e) noexcept;
- bool hciSMPMsgCallback(const EUI48& address, BDAddressType addressType,
+ bool hciSMPMsgCallback(const BDAddressAndType & addressAndType,
std::shared_ptr<const SMPPDUMsg> msg, const HCIACLData::l2cap_frame& source) noexcept;
void sendDevicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept;
void sendDeviceReady(std::shared_ptr<DBTDevice> device, uint64_t timestamp) noexcept;
@@ -482,7 +480,7 @@ namespace direct_bt {
/**
* Returns true, if the adapter's device is already whitelisted.
*/
- bool isDeviceWhitelisted(const EUI48 &address) noexcept;
+ bool isDeviceWhitelisted(const BDAddressAndType & addressAndType) noexcept;
/**
* Add the given device to the adapter's autoconnect whitelist.
@@ -502,14 +500,14 @@ namespace direct_bt {
* @param supervision_timeout in units of 10ms, default value >= 10 x conn_interval_max, we use HCIConstInt::LE_CONN_MIN_TIMEOUT_MS minimum; Value range [0xA-0x0C80] for [100ms - 32s].
* @return true if the device was already added or has been newly added to the adapter's whitelist.
*/
- bool addDeviceToWhitelist(const EUI48 &address, const BDAddressType address_type,
+ bool addDeviceToWhitelist(const BDAddressAndType & addressAndType,
const HCIWhitelistConnectType ctype,
const uint16_t conn_interval_min=12, const uint16_t conn_interval_max=12,
const uint16_t conn_latency=0, const uint16_t supervision_timeout=getHCIConnSupervisorTimeout(0, 15));
/** Remove the given device from the adapter's autoconnect whitelist. */
- bool removeDeviceFromWhitelist(const EUI48 &address, const BDAddressType address_type);
+ bool removeDeviceFromWhitelist(const BDAddressAndType & addressAndType);
// device discovery aka device scanning
@@ -658,7 +656,7 @@ namespace direct_bt {
int removeDiscoveredDevices() noexcept;
/** Returns shared DBTDevice if found, otherwise nullptr */
- std::shared_ptr<DBTDevice> findDiscoveredDevice (EUI48 const & mac, const BDAddressType macType) noexcept;
+ std::shared_ptr<DBTDevice> findDiscoveredDevice (const EUI48 & address, const BDAddressType addressType) noexcept;
std::string toString() const noexcept override { return toString(true); }
std::string toString(bool includeDiscoveredDevices) const noexcept;
diff --git a/api/direct_bt/DBTDevice.hpp b/api/direct_bt/DBTDevice.hpp
index ae363599..4b504c56 100644
--- a/api/direct_bt/DBTDevice.hpp
+++ b/api/direct_bt/DBTDevice.hpp
@@ -206,10 +206,8 @@ namespace direct_bt {
public:
const uint64_t ts_creation;
- /** Device mac address */
- const EUI48 address; // FIXME: Mutable for resolvable -> identity during pairing?
- const BDAddressType addressType;
- const BLERandomAddressType leRandomAddressType;
+ /** Device's unique mac address and type tuple. */
+ const BDAddressAndType addressAndType; // FIXME: Mutable for resolvable -> identity during pairing?
DBTDevice(const DBTDevice&) = delete;
void operator=(const DBTDevice&) = delete;
@@ -258,25 +256,11 @@ namespace direct_bt {
*/
uint64_t getLastUpdateAge(const uint64_t ts_now) const noexcept { return ts_now - ts_last_update; }
- EUI48 const & getAddress() const noexcept { return address; }
- std::string getAddressString() const noexcept { return address.toString(); }
- constexpr BDAddressType getAddressType() const noexcept { return addressType; }
- constexpr bool isLEAddressType() const noexcept { return direct_bt::isLEAddressType(addressType); }
- constexpr bool isBREDRAddressType() const noexcept { return direct_bt::isBREDRAddressType(addressType); }
-
/**
- * Returns the {@link BLERandomAddressType}.
- * <p>
- * If {@link #getAddressType()} is {@link BDAddressType::BDADDR_LE_RANDOM},
- * method shall return a valid value other than {@link BLERandomAddressType::UNDEFINED}.
- * </p>
- * <p>
- * If {@link #getAddressType()} is not {@link BDAddressType::BDADDR_LE_RANDOM},
- * method shall return {@link BLERandomAddressType::UNDEFINED}.
- * </p>
- * @since 2.0.0
+ * Returns the unique device EUI48 address and BDAddressType type.
+ * @since 2.2.0
*/
- constexpr BLERandomAddressType getBLERandomAddressType() const noexcept { return leRandomAddressType; }
+ constexpr BDAddressAndType const & getAddressAndType() const noexcept { return addressAndType; }
/** Return RSSI of device as recognized at discovery and connect. */
int8_t getRSSI() const noexcept { return rssi; }
@@ -827,11 +811,8 @@ namespace direct_bt {
int removeAllCharacteristicListener() noexcept;
};
- inline bool operator<(const DBTDevice& lhs, const DBTDevice& rhs) noexcept
- { return lhs.getAddress() < rhs.getAddress(); }
-
inline bool operator==(const DBTDevice& lhs, const DBTDevice& rhs) noexcept
- { return lhs.getAddress() == rhs.getAddress() && lhs.getAddressType() == rhs.getAddressType(); }
+ { return lhs.getAddressAndType() == rhs.getAddressAndType(); }
inline bool operator!=(const DBTDevice& lhs, const DBTDevice& rhs) noexcept
{ return !(lhs == rhs); }
diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp
index 1697146e..8bea2eef 100644
--- a/api/direct_bt/DBTManager.hpp
+++ b/api/direct_bt/DBTManager.hpp
@@ -202,8 +202,7 @@ namespace direct_bt {
struct WhitelistElem {
uint16_t dev_id;
- EUI48 address;
- BDAddressType address_type;
+ BDAddressAndType address_and_type;
HCIWhitelistConnectType ctype;
};
std::vector<std::shared_ptr<WhitelistElem>> whitelist;
@@ -403,14 +402,14 @@ namespace direct_bt {
* @param supervision_timeout in units of 10ms, default value >= 10 x conn_interval_max, we use HCIConstInt::LE_CONN_MIN_TIMEOUT_MS minimum; Value range [0xA-0x0C80] for [100ms - 32s].
* @return
*/
- bool uploadConnParam(const uint16_t dev_id, const EUI48 &address, const BDAddressType address_type,
+ bool uploadConnParam(const uint16_t dev_id, const BDAddressAndType & addressAndType,
const uint16_t conn_interval_min=12, const uint16_t conn_interval_max=12,
const uint16_t conn_latency=0, const uint16_t supervision_timeout=getHCIConnSupervisorTimeout(0, 15)) noexcept;
/**
* Returns true, if the adapter's device is already whitelisted.
*/
- bool isDeviceWhitelisted(const uint16_t dev_id, const EUI48 &address) noexcept;
+ bool isDeviceWhitelisted(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept;
/**
* Add the given device to the adapter's autoconnect whitelist.
@@ -421,19 +420,19 @@ namespace direct_bt {
* Method will reject duplicate devices, in which case it should be removed first.
* </p>
*/
- bool addDeviceToWhitelist(const uint16_t dev_id, const EUI48 &address, const BDAddressType address_type, const HCIWhitelistConnectType ctype) noexcept;
+ bool addDeviceToWhitelist(const uint16_t dev_id, const BDAddressAndType & addressAndType, const HCIWhitelistConnectType ctype) noexcept;
/** Remove the given device from the adapter's autoconnect whitelist. */
- bool removeDeviceFromWhitelist(const uint16_t dev_id, const EUI48 &address, const BDAddressType address_type) noexcept;
+ bool removeDeviceFromWhitelist(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept;
/** Remove all previously added devices from the autoconnect whitelist. Returns number of removed devices. */
int removeAllDevicesFromWhitelist() noexcept;
bool disconnect(const bool ioErrorCause,
- const uint16_t dev_id, const EUI48 &peer_bdaddr, const BDAddressType peer_mac_type,
+ const uint16_t dev_id, const BDAddressAndType & addressAndType,
const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ) noexcept;
- std::shared_ptr<ConnectionInfo> getConnectionInfo(const uint16_t dev_id, const EUI48 &address, const BDAddressType address_type) noexcept;
+ std::shared_ptr<ConnectionInfo> getConnectionInfo(const uint16_t dev_id, const BDAddressAndType& addressAndType) noexcept;
std::shared_ptr<NameAndShortName> setLocalName(const uint16_t dev_id, const std::string & name, const std::string & short_name) noexcept;
/** Security commands */
@@ -441,14 +440,14 @@ namespace direct_bt {
MgmtStatus uploadLinkKey(const uint16_t dev_id, const bool debug_keys, const MgmtLinkKeyInfo &key) noexcept;
HCIStatusCode uploadLongTermKey(const uint16_t dev_id, const MgmtLongTermKeyInfo &key) noexcept;
- HCIStatusCode uploadLongTermKeyInfo(const uint16_t dev_id, const EUI48& address, BDAddressType address_type, const SMPLongTermKeyInfo& ltk) noexcept;
+ HCIStatusCode uploadLongTermKeyInfo(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPLongTermKeyInfo& ltk) noexcept;
- MgmtStatus userPasskeyReply(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const uint32_t passkey) noexcept;
- MgmtStatus userPasskeyNegativeReply(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType) noexcept;
- MgmtStatus userConfirmReply(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const bool positive) noexcept;
+ MgmtStatus userPasskeyReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const uint32_t passkey) noexcept;
+ MgmtStatus userPasskeyNegativeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept;
+ MgmtStatus userConfirmReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool positive) noexcept;
- bool pairDevice(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const SMPIOCapability iocap) noexcept;
- MgmtStatus unpairDevice(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const bool disconnect) noexcept;
+ bool pairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPIOCapability iocap) noexcept;
+ MgmtStatus unpairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool disconnect) noexcept;
/** MgmtEventCallback handling */
diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp
index ae37f0b6..e07b6350 100644
--- a/api/direct_bt/HCIHandler.hpp
+++ b/api/direct_bt/HCIHandler.hpp
@@ -147,7 +147,7 @@ namespace direct_bt {
}
};
- typedef jau::FunctionDef<bool, const EUI48& /* address */, BDAddressType /* addressType */,
+ typedef jau::FunctionDef<bool, const BDAddressAndType& /* addressAndType */,
std::shared_ptr<const SMPPDUMsg>, const HCIACLData::l2cap_frame& /* source */> HCISMPMsgCallback;
typedef jau::cow_vector<HCISMPMsgCallback> HCISMPMsgCallbackList;
@@ -171,37 +171,43 @@ namespace direct_bt {
private:
class HCIConnection {
private:
- EUI48 address; // immutable
- BDAddressType addressType; // immutable
+ BDAddressAndType addressAndType; // immutable
uint16_t handle; // mutable
public:
- HCIConnection(const EUI48 &address_, const BDAddressType addressType_, const uint16_t handle_)
- : address(address_), addressType(addressType_), handle(handle_) {}
+ HCIConnection(const BDAddressAndType& addressAndType_, const uint16_t handle_)
+ : addressAndType(addressAndType_), handle(handle_) {}
HCIConnection(const HCIConnection &o) = default;
HCIConnection(HCIConnection &&o) = default;
HCIConnection& operator=(const HCIConnection &o) = default;
HCIConnection& operator=(HCIConnection &&o) = default;
- const EUI48 & getAddress() const { return address; }
- BDAddressType getAddressType() const { return addressType; }
+ const BDAddressAndType & getAddressAndType() const { return addressAndType; }
uint16_t getHandle() const { return handle; }
void setHandle(uint16_t newHandle) { handle = newHandle; }
- bool equals(const EUI48 & otherAddress, const BDAddressType otherAddressType) const
- { return address == otherAddress && addressType == otherAddressType; }
+ bool equals(const BDAddressAndType & other) const
+ { return addressAndType == other; }
- bool operator==(const HCIConnection& rhs) const
- { return address == rhs.address && addressType == rhs.addressType; }
+ bool operator==(const HCIConnection& rhs) const {
+ if( this == &rhs ) {
+ return true;
+ }
+ return addressAndType == rhs.addressAndType;
+ }
bool operator!=(const HCIConnection& rhs) const
{ return !(*this == rhs); }
+ std::size_t hash_code() const noexcept {
+ return addressAndType.hash_code();
+ }
+
std::string toString() const {
return "HCIConnection[handle "+jau::uint16HexString(handle)+
- ", address="+address.toString()+", addressType "+getBDAddressTypeString(addressType)+"]";
+ ", address "+addressAndType.toString()+"]";
}
};
typedef std::shared_ptr<HCIConnection> HCIConnectionRef;
@@ -265,20 +271,20 @@ namespace direct_bt {
* @param handle ignored for existing tracker _if_ invalid, i.e. zero.
*/
HCIConnectionRef addOrUpdateHCIConnection(std::vector<HCIConnectionRef> &list,
- const EUI48 & address, BDAddressType addrType, const uint16_t handle) noexcept;
- HCIConnectionRef addOrUpdateTrackerConnection(const EUI48 & address, BDAddressType addrType, const uint16_t handle) noexcept {
- return addOrUpdateHCIConnection(connectionList, address, addrType, handle);
+ const BDAddressAndType& addressAndType, const uint16_t handle) noexcept;
+ HCIConnectionRef addOrUpdateTrackerConnection(const BDAddressAndType& addressAndType, const uint16_t handle) noexcept {
+ return addOrUpdateHCIConnection(connectionList, addressAndType, handle);
}
- HCIConnectionRef addOrUpdateDisconnectCmd(const EUI48 & address, BDAddressType addrType, const uint16_t handle) noexcept {
- return addOrUpdateHCIConnection(disconnectCmdList, address, addrType, handle);
+ HCIConnectionRef addOrUpdateDisconnectCmd(const BDAddressAndType& addressAndType, const uint16_t handle) noexcept {
+ return addOrUpdateHCIConnection(disconnectCmdList, addressAndType, handle);
}
- HCIConnectionRef findHCIConnection(std::vector<HCIConnectionRef> &list, const EUI48 & address, BDAddressType addrType) noexcept;
- HCIConnectionRef findTrackerConnection(const EUI48 & address, BDAddressType addrType) noexcept {
- return findHCIConnection(connectionList, address, addrType);
+ HCIConnectionRef findHCIConnection(std::vector<HCIConnectionRef> &list, const BDAddressAndType& addressAndType) noexcept;
+ HCIConnectionRef findTrackerConnection(const BDAddressAndType& addressAndType) noexcept {
+ return findHCIConnection(connectionList, addressAndType);
}
- HCIConnectionRef findDisconnectCmd(const EUI48 & address, BDAddressType addrType) noexcept {
- return findHCIConnection(disconnectCmdList, address, addrType);
+ HCIConnectionRef findDisconnectCmd(const BDAddressAndType& addressAndType) noexcept {
+ return findHCIConnection(disconnectCmdList, addressAndType);
}
HCIConnectionRef findTrackerConnection(const uint16_t handle) noexcept;
@@ -526,7 +532,7 @@ namespace direct_bt {
* BT Core Spec v5.2: Vol 4, Part E HCI: 7.1.6 Disconnect command
* </p>
*/
- HCIStatusCode disconnect(const uint16_t conn_handle, const EUI48 &peer_bdaddr, const BDAddressType peer_mac_type,
+ HCIStatusCode disconnect(const uint16_t conn_handle, const BDAddressAndType& addressAndType,
const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION) noexcept;
/**
@@ -602,5 +608,18 @@ namespace direct_bt {
} // namespace direct_bt
+#if 0
+// Injecting specialization of std::hash to namespace std of our types above
+// Would need to make direct_bt::HCIHandler::HCIConnection accessible
+namespace std
+{
+ template<> struct hash<direct_bt::HCIHandler::HCIConnection> {
+ std::size_t operator()(direct_bt::HCIHandler::HCIConnection const& a) const noexcept {
+ return a.hash_code();
+ }
+ };
+}
+#endif
+
#endif /* DBT_HANDLER_HPP_ */
diff --git a/api/direct_bt/L2CAPComm.hpp b/api/direct_bt/L2CAPComm.hpp
index d16235ff..64979acf 100644
--- a/api/direct_bt/L2CAPComm.hpp
+++ b/api/direct_bt/L2CAPComm.hpp
@@ -132,9 +132,7 @@ namespace direct_bt {
const uint16_t cid;
std::recursive_mutex mtx_write;
- std::string deviceString;
- EUI48 deviceAddress;
- BDAddressType deviceAddressType;
+ BDAddressAndType deviceAddressAndType;
std::atomic<int> socket_descriptor; // the l2cap socket
std::atomic<bool> is_open; // reflects state
std::atomic<bool> has_ioerror; // reflects state
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index e0ed1f84..1bec74f4 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -680,11 +680,11 @@ namespace direct_bt {
}
public:
- MgmtCmdAdressInfoMeta(const Opcode opc, const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
+ MgmtCmdAdressInfoMeta(const Opcode opc, const uint16_t dev_id, const BDAddressAndType& addressAndType)
: MgmtCommand(opc, dev_id, 6+1)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
}
virtual ~MgmtCmdAdressInfoMeta() noexcept override {}
@@ -699,8 +699,8 @@ namespace direct_bt {
class MgmtDisconnectCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtDisconnectCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::DISCONNECT, dev_id, address, addressType)
+ MgmtDisconnectCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::DISCONNECT, dev_id, addressAndType)
{ }
};
@@ -764,8 +764,8 @@ namespace direct_bt {
class MgmtGetConnectionInfoCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtGetConnectionInfoCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::GET_CONN_INFO, dev_id, address, addressType)
+ MgmtGetConnectionInfoCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::GET_CONN_INFO, dev_id, addressAndType)
{ }
};
@@ -784,12 +784,12 @@ namespace direct_bt {
}
public:
- MgmtPinCodeReplyCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType,
+ MgmtPinCodeReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType,
const uint8_t pin_len, const TROOctets &pin_code)
: MgmtCommand(Opcode::PIN_CODE_REPLY, dev_id, 6+1+1+16)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+7, pin_len);
pdu.put_octets_nc(MGMT_HEADER_SIZE+8, pin_code);
}
@@ -805,8 +805,8 @@ namespace direct_bt {
class MgmtPinCodeNegativeReplyCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtPinCodeNegativeReplyCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::PIN_CODE_NEG_REPLY, dev_id, address, addressType)
+ MgmtPinCodeNegativeReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::PIN_CODE_NEG_REPLY, dev_id, addressAndType)
{ }
};
@@ -824,11 +824,11 @@ namespace direct_bt {
}
public:
- MgmtPairDeviceCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const SMPIOCapability iocap)
+ MgmtPairDeviceCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType, const SMPIOCapability iocap)
: MgmtCommand(Opcode::PAIR_DEVICE, dev_id, 6+1+1)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, direct_bt::number(iocap));
}
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 0) ); } // mgmt_addr_info
@@ -842,8 +842,8 @@ namespace direct_bt {
class MgmtCancelPairDevice : public MgmtCmdAdressInfoMeta
{
public:
- MgmtCancelPairDevice(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::CANCEL_PAIR_DEVICE, dev_id, address, addressType)
+ MgmtCancelPairDevice(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::CANCEL_PAIR_DEVICE, dev_id, addressAndType)
{ }
};
@@ -862,11 +862,11 @@ namespace direct_bt {
}
public:
- MgmtUnpairDeviceCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const bool disconnect)
+ MgmtUnpairDeviceCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType, const bool disconnect)
: MgmtCommand(Opcode::UNPAIR_DEVICE, dev_id, 6+1+1)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, disconnect ? 0x01 : 0x00);
}
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 0) ); } // mgmt_addr_info
@@ -880,8 +880,8 @@ namespace direct_bt {
class MgmtUserConfirmReplyCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtUserConfirmReplyCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::USER_CONFIRM_REPLY, dev_id, address, addressType)
+ MgmtUserConfirmReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::USER_CONFIRM_REPLY, dev_id, addressAndType)
{ }
};
@@ -891,8 +891,8 @@ namespace direct_bt {
class MgmtUserConfirmNegativeReplyCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtUserConfirmNegativeReplyCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::USER_CONFIRM_NEG_REPLY, dev_id, address, addressType)
+ MgmtUserConfirmNegativeReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::USER_CONFIRM_NEG_REPLY, dev_id, addressAndType)
{ }
};
@@ -910,11 +910,11 @@ namespace direct_bt {
}
public:
- MgmtUserPasskeyReplyCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const uint32_t passkey)
+ MgmtUserPasskeyReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType, const uint32_t passkey)
: MgmtCommand(Opcode::USER_PASSKEY_REPLY, dev_id, 6+1+4)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint32_nc(MGMT_HEADER_SIZE+6+1, passkey);
}
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 0) ); } // mgmt_addr_info
@@ -928,8 +928,8 @@ namespace direct_bt {
class MgmtUserPasskeyNegativeReplyCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtUserPasskeyNegativeReplyCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::USER_PASSKEY_NEG_REPLY, dev_id, address, addressType)
+ MgmtUserPasskeyNegativeReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::USER_PASSKEY_NEG_REPLY, dev_id, addressAndType)
{ }
};
@@ -951,11 +951,11 @@ namespace direct_bt {
}
public:
- MgmtAddDeviceToWhitelistCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const HCIWhitelistConnectType ctype)
+ MgmtAddDeviceToWhitelistCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType, const HCIWhitelistConnectType ctype)
: MgmtCommand(Opcode::ADD_DEVICE_WHITELIST, dev_id, 6+1+1)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, direct_bt::number(ctype));
}
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 0) ); } // mgmt_addr_info
@@ -969,8 +969,8 @@ namespace direct_bt {
class MgmtRemoveDeviceFromWhitelistCmd : public MgmtCmdAdressInfoMeta
{
public:
- MgmtRemoveDeviceFromWhitelistCmd(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType)
- : MgmtCmdAdressInfoMeta(Opcode::REMOVE_DEVICE_WHITELIST, dev_id, address, addressType)
+ MgmtRemoveDeviceFromWhitelistCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType)
+ : MgmtCmdAdressInfoMeta(Opcode::REMOVE_DEVICE_WHITELIST, dev_id, addressAndType)
{ }
};
@@ -1491,11 +1491,11 @@ namespace direct_bt {
{
checkOpcode(getOpcode(), Opcode::DEVICE_CONNECTED);
}
- MgmtEvtDeviceConnected(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const uint16_t hci_conn_handle_)
+ MgmtEvtDeviceConnected(const uint16_t dev_id, const BDAddressAndType& addressAndType, const uint16_t hci_conn_handle_)
: MgmtEvent(Opcode::DEVICE_CONNECTED, dev_id, 6+1+4+2), hci_conn_handle(hci_conn_handle_)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint32_nc(MGMT_HEADER_SIZE+6+1, 0); // flags
pdu.put_uint16_nc(MGMT_HEADER_SIZE+6+1+4, 0); // eir-len
}
@@ -1565,13 +1565,13 @@ namespace direct_bt {
{
checkOpcode(getOpcode(), Opcode::DEVICE_DISCONNECTED);
}
- MgmtEvtDeviceDisconnected(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType,
+ MgmtEvtDeviceDisconnected(const uint16_t dev_id, const BDAddressAndType& addressAndType,
HCIStatusCode hciReason_, const uint16_t hci_conn_handle_)
: MgmtEvent(Opcode::DEVICE_DISCONNECTED, dev_id, 6+1+1), hciReason(hciReason_), hci_conn_handle(hci_conn_handle_)
{
DisconnectReason disconnectReason = getDisconnectReason(hciReason_);
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, static_cast<uint8_t>(disconnectReason));
}
@@ -1619,11 +1619,11 @@ namespace direct_bt {
{
checkOpcode(getOpcode(), Opcode::CONNECT_FAILED);
}
- MgmtEvtDeviceConnectFailed(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const HCIStatusCode status)
+ MgmtEvtDeviceConnectFailed(const uint16_t dev_id, const BDAddressAndType& addressAndType, const HCIStatusCode status)
: MgmtEvent(Opcode::CONNECT_FAILED, dev_id, 6+1+1), hciStatus(status)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, static_cast<uint8_t>(MgmtStatus::CONNECT_FAILED));
}
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 0) ); } // mgmt_addr_info
@@ -2089,11 +2089,11 @@ namespace direct_bt {
}
public:
- MgmtEvtHCIEncryptionChanged(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const HCIStatusCode hci_status, uint8_t hci_enc_enabled)
+ MgmtEvtHCIEncryptionChanged(const uint16_t dev_id, const BDAddressAndType& addressAndType, const HCIStatusCode hci_status, uint8_t hci_enc_enabled)
: MgmtEvent(Opcode::HCI_ENC_CHANGED, dev_id, 6+1+1+1)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, direct_bt::number(hci_status));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1+1, hci_enc_enabled);
}
@@ -2128,11 +2128,11 @@ namespace direct_bt {
}
public:
- MgmtEvtHCIEncryptionKeyRefreshComplete(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const HCIStatusCode hci_status)
+ MgmtEvtHCIEncryptionKeyRefreshComplete(const uint16_t dev_id, const BDAddressAndType& addressAndType, const HCIStatusCode hci_status)
: MgmtEvent(Opcode::HCI_ENC_KEY_REFRESH_COMPLETE, dev_id, 6+1+1)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6+1, direct_bt::number(hci_status));
}
@@ -2162,11 +2162,11 @@ namespace direct_bt {
}
public:
- MgmtEvtHCILERemoteUserFeatures(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, const LEFeatures features_)
+ MgmtEvtHCILERemoteUserFeatures(const uint16_t dev_id, const BDAddressAndType& addressAndType, const LEFeatures features_)
: MgmtEvent(Opcode::HCI_LE_REMOTE_USR_FEATURES, dev_id, 6+1+8)
{
- pdu.put_eui48_nc(MGMT_HEADER_SIZE, address);
- pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressType));
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint64_nc(MGMT_HEADER_SIZE+6+1, direct_bt::number(features_));
}