summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/BTAddress.hpp18
-rw-r--r--src/direct_bt/BTTypes.cpp33
-rw-r--r--src/direct_bt/DBTDevice.cpp20
3 files changed, 57 insertions, 14 deletions
diff --git a/api/direct_bt/BTAddress.hpp b/api/direct_bt/BTAddress.hpp
index b2702a7f..80d13408 100644
--- a/api/direct_bt/BTAddress.hpp
+++ b/api/direct_bt/BTAddress.hpp
@@ -57,7 +57,7 @@ namespace direct_bt {
BDADDR_UNDEFINED = 0xff
};
- std::string getBDAddressTypeString(const BDAddressType op);
+ std::string getBDAddressTypeString(const BDAddressType type);
/**
* BT Core Spec v5.2: Vol 6 LE, Part B Link Layer Specification: 1.3 Device Address
@@ -88,7 +88,7 @@ namespace direct_bt {
/** Undefined */
UNDEFINED = 0xff
};
- std::string getBLERandomAddressTypeString(const BLERandomAddressType op);
+ std::string getBLERandomAddressTypeString(const BLERandomAddressType type);
/**
* HCI LE Address-Type is PUBLIC: 0x00, RANDOM: 0x01
@@ -107,24 +107,34 @@ namespace direct_bt {
* </p>
*/
enum class HCILEPeerAddressType : uint8_t {
- PUBLIC = 0x00,/**< HCIADDR_LE_PUBLIC */
- RANDOM = 0x01,/**< HCIADDR_LE_RANDOM */
+ /** Public Device Address */
+ PUBLIC = 0x00,
+ /** Random Device Address */
+ RANDOM = 0x01,
+ /** Public Resolved Identity Address */
PUBLIC_IDENTITY = 0x02,
+ /** Resolved Random (Static) Identity Address */
RANDOM_STATIC_IDENTITY = 0x03,
UNDEFINED = 0xff /**< HCIADDR_UNDEFINED */
};
BDAddressType getBDAddressType(const HCILEPeerAddressType hciPeerAddrType);
+ std::string getHCILEPeerAddressTypeString(const HCILEPeerAddressType type);
enum class HCILEOwnAddressType : uint8_t {
+ /** Public Device Address */
PUBLIC = 0x00,
+ /** Random Device Address */
RANDOM = 0x01,
+ /** Controller Resolved Private Address or Public Address */
RESOLVABLE_OR_PUBLIC = 0x02,
+ /** Controller Resolved Private Address or Random Address */
RESOLVABLE_OR_RANDOM = 0x03,
UNDEFINED = 0xff
};
BDAddressType getBDAddressType(const HCILEOwnAddressType hciOwnAddrType);
+ std::string getHCILEOwnAddressTypeString(const HCILEOwnAddressType type);
/**
* A packed 48 bit EUI-48 identifier, formerly known as MAC-48
diff --git a/src/direct_bt/BTTypes.cpp b/src/direct_bt/BTTypes.cpp
index 6f61a853..64b321ce 100644
--- a/src/direct_bt/BTTypes.cpp
+++ b/src/direct_bt/BTTypes.cpp
@@ -55,6 +55,21 @@ BDAddressType direct_bt::getBDAddressType(const HCILEPeerAddressType hciPeerAddr
}
}
+#define CHAR_DECL_HCILEPeerAddressType_ENUM(X) \
+ X(HCILEPeerAddressType,PUBLIC) \
+ X(HCILEPeerAddressType,RANDOM) \
+ X(HCILEPeerAddressType,PUBLIC_IDENTITY) \
+ X(HCILEPeerAddressType,RANDOM_STATIC_IDENTITY) \
+ X(HCILEPeerAddressType,UNDEFINED)
+
+std::string direct_bt::getHCILEPeerAddressTypeString(const HCILEPeerAddressType type) {
+ switch(type) {
+ CHAR_DECL_HCILEPeerAddressType_ENUM(CASE2_TO_STRING)
+ default: ; // fall through intended
+ }
+ return "Unknown HCILEPeerAddressType";
+}
+
BDAddressType direct_bt::getBDAddressType(const HCILEOwnAddressType hciOwnAddrType) {
switch(hciOwnAddrType) {
case HCILEOwnAddressType::PUBLIC:
@@ -70,6 +85,22 @@ BDAddressType direct_bt::getBDAddressType(const HCILEOwnAddressType hciOwnAddrTy
}
}
+#define CHAR_DECL_HCILEOwnAddressType_ENUM(X) \
+ X(HCILEOwnAddressType,PUBLIC) \
+ X(HCILEOwnAddressType,RANDOM) \
+ X(HCILEOwnAddressType,RESOLVABLE_OR_PUBLIC) \
+ X(HCILEOwnAddressType,RESOLVABLE_OR_RANDOM) \
+ X(HCILEOwnAddressType,UNDEFINED)
+
+std::string direct_bt::getHCILEOwnAddressTypeString(const HCILEOwnAddressType type) {
+ switch(type) {
+ CHAR_DECL_HCILEOwnAddressType_ENUM(CASE2_TO_STRING)
+ default: ; // fall through intended
+ }
+ return "Unknown HCILEOwnAddressType";
+}
+
+
#define CHAR_DECL_BDADDRESSTYPE_ENUM(X) \
X(BDADDR_BREDR) \
X(BDADDR_LE_PUBLIC) \
@@ -96,7 +127,7 @@ std::string direct_bt::getBLERandomAddressTypeString(const BLERandomAddressType
CHAR_DECL_LERANDOMADDRESSTYPE_ENUM(CASE2_TO_STRING)
default: ; // fall through intended
}
- return "Unknown BLERandomAddressType type";
+ return "Unknown BLERandomAddressType";
}
std::string direct_bt::getBLERandomAddressTypeString(const EUI48 &a) {
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp
index aa50024d..3dc1ac91 100644
--- a/src/direct_bt/DBTDevice.cpp
+++ b/src/direct_bt/DBTDevice.cpp
@@ -286,7 +286,7 @@ bool DBTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_window,
}
} break;
default: {
- ERR_PRINT("Can't connectLE to '%s' address type: %s", getBDAddressTypeString(addressType).c_str(), toString().c_str());
+ ERR_PRINT("Can't connectLE to address type '%s': %s", getBDAddressTypeString(addressType).c_str(), toString().c_str());
return false;
}
}
@@ -302,10 +302,6 @@ bool DBTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_window,
ERR_PRINT("DBTDevice::connectLE: Opening adapter's HCI failed: %s", toString().c_str());
return false;
}
- if( !isLEAddressType() ) {
- ERR_PRINT("DBTDevice::connectLE: Not a BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM address: %s", toString().c_str());
- return false;
- }
HCIStatusCode status = hci->le_create_conn(address,
hci_peer_mac_type, hci_own_mac_type,
@@ -325,13 +321,19 @@ bool DBTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_window,
}
#endif
if( HCIStatusCode::COMMAND_DISALLOWED == status ) {
- WARN_PRINT("DBTDevice::connectLE: Could not yet create connection: status 0x%2.2X (%s), errno %d %s on %s",
- static_cast<uint8_t>(status), getHCIStatusCodeString(status).c_str(), errno, strerror(errno), toString().c_str());
+ WARN_PRINT("DBTDevice::connectLE: Could not yet create connection: status 0x%2.2X (%s), errno %d, hci-atype[peer %s, own %s] %s on %s",
+ static_cast<uint8_t>(status), getHCIStatusCodeString(status).c_str(), errno, strerror(errno),
+ getHCILEPeerAddressTypeString(hci_peer_mac_type).c_str(),
+ getHCILEOwnAddressTypeString(hci_own_mac_type).c_str(),
+ toString().c_str());
return false;
}
if ( HCIStatusCode::SUCCESS != status ) {
- ERR_PRINT("DBTDevice::connectLE: Could not create connection: status 0x%2.2X (%s), errno %d %s on %s",
- static_cast<uint8_t>(status), getHCIStatusCodeString(status).c_str(), errno, strerror(errno), toString().c_str());
+ ERR_PRINT("DBTDevice::connectLE: Could not create connection: status 0x%2.2X (%s), errno %d %s, hci-atype[peer %s, own %s] on %s",
+ static_cast<uint8_t>(status), getHCIStatusCodeString(status).c_str(), errno, strerror(errno),
+ getHCILEPeerAddressTypeString(hci_peer_mac_type).c_str(),
+ getHCILEOwnAddressTypeString(hci_own_mac_type).c_str(),
+ toString().c_str());
return false;
}
return true;