aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-05-04 15:20:37 +0200
committerSven Gothel <[email protected]>2020-05-04 15:20:37 +0200
commit640e4f15f6fd7f44b49a606515f3778574b18db7 (patch)
treeb7846e9327bbc630cd283699ac9b2665c7f4bb5f /src
parentd3e86e6a934af213f014b06f6469cfc97c0f5f83 (diff)
Extend BluetoothDeviceStatusListener -> BluetoothAdapterStatusListener; Enum bit field mask: Add AdapterSettings , fix EIRDataType -> EIRDataTypeSet
Extend Java BluetoothDeviceStatusListener -> BluetoothAdapterStatusListener and C++ DBTDeviceStatusListener -> DBTAdapterStatusListener - BluetoothAdapterStatusListener shall be (ab)used for anything adapter event related, user may utilize it (optional) - Added callback method adapterSettingsChanged(..) in DBTAdapterStatusListener - An internal listener further produces more detailed callbacks, used on the Java side. +++ Java enum bit field mask: Add AdapterSettings , fix EIRDataType -> EIRDataTypeSet - In Java, we cannot have an indivudual enum instance (like in C++) ;-) - Hence 'enum EIRDataType' -> EIRDataTypeSet.DataType and having the 'bit mask' implemented in EIRDataTypeSet. - Adding similar AdapterSettings bit field, utilized in DBTAdapter's internal BluetoothAdapterStatusListener to produce fine grained callbacks.
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/BTTypes.cpp93
-rw-r--r--src/direct_bt/DBTAdapter.cpp46
-rw-r--r--src/direct_bt/DBTManager.cpp39
-rw-r--r--src/direct_bt/MgmtTypes.cpp48
4 files changed, 104 insertions, 122 deletions
diff --git a/src/direct_bt/BTTypes.cpp b/src/direct_bt/BTTypes.cpp
index ed8b48f8..a2b770f0 100644
--- a/src/direct_bt/BTTypes.cpp
+++ b/src/direct_bt/BTTypes.cpp
@@ -44,6 +44,7 @@ using namespace direct_bt;
X(BDADDR_UNDEFINED)
#define CASE_TO_STRING(V) case V: return #V;
+#define CASE2_TO_STRING(U,V) case U::V: return #V;
std::string direct_bt::getBDAddressTypeString(const BDAddressType type) {
switch(type) {
@@ -124,67 +125,43 @@ std::string ManufactureSpecificData::toString() const {
// *************************************************
// *************************************************
+#define EIRDATATYPE_ENUM(X) \
+ X(EIRDataType,NONE) \
+ X(EIRDataType,EVT_TYPE) \
+ X(EIRDataType,BDADDR_TYPE) \
+ X(EIRDataType,BDADDR) \
+ X(EIRDataType,FLAGS) \
+ X(EIRDataType,NAME) \
+ X(EIRDataType,NAME_SHORT) \
+ X(EIRDataType,RSSI) \
+ X(EIRDataType,TX_POWER) \
+ X(EIRDataType,MANUF_DATA) \
+ X(EIRDataType,DEVICE_CLASS) \
+ X(EIRDataType,APPEARANCE) \
+ X(EIRDataType,HASH) \
+ X(EIRDataType,RANDOMIZER) \
+ X(EIRDataType,DEVICE_ID) \
+ X(EIRDataType,SERVICE_UUID)
+
+std::string direct_bt::eirDataBitToString(const EIRDataType bit) {
+ switch(bit) {
+ EIRDATATYPE_ENUM(CASE2_TO_STRING)
+ default: ; // fall through intended
+ }
+ return "Unknown EIRDataType Bit";
+}
+
std::string direct_bt::eirDataMaskToString(const EIRDataType mask) {
+ const uint32_t one = 1;
bool has_pre = false;
std::string out("[");
- if( isEIRDataTypeSet(mask, EIRDataType::EVT_TYPE) ) {
- out.append("EVT_TYPE"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::BDADDR_TYPE) ) {
- if( has_pre ) { out.append(", "); }
- out.append("BDADDR_TYPE"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::BDADDR) ) {
- if( has_pre ) { out.append(", "); }
- out.append("BDADDR"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::FLAGS) ) {
- if( has_pre ) { out.append(", "); }
- out.append("FLAGS"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::NAME) ) {
- if( has_pre ) { out.append(", "); }
- out.append("NAME"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::NAME_SHORT) ) {
- if( has_pre ) { out.append(", "); }
- out.append("NAME_SHORT"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::RSSI) ) {
- if( has_pre ) { out.append(", "); }
- out.append("RSSI"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::TX_POWER) ) {
- if( has_pre ) { out.append(", "); }
- out.append("TX_POWER"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::MANUF_DATA) ) {
- if( has_pre ) { out.append(", "); }
- out.append("MANUF_DATA"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::DEVICE_CLASS) ) {
- if( has_pre ) { out.append(", "); }
- out.append("DEVICE_CLASS"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::APPEARANCE) ) {
- if( has_pre ) { out.append(", "); }
- out.append("APPEARANCE"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::HASH) ) {
- if( has_pre ) { out.append(", "); }
- out.append("HASH"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::RANDOMIZER) ) {
- if( has_pre ) { out.append(", "); }
- out.append("RANDOMIZER"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::DEVICE_ID) ) {
- if( has_pre ) { out.append(", "); }
- out.append("DEVICE_ID"); has_pre = true;
- }
- if( isEIRDataTypeSet(mask, EIRDataType::SERVICE_UUID) ) {
- if( has_pre ) { out.append(", "); }
- out.append("SERVICE_UUID"); has_pre = true;
+ for(int i=0; i<32; i++) {
+ const EIRDataType settingBit = static_cast<EIRDataType>( one << i );
+ if( EIRDataType::NONE != ( mask & settingBit ) ) {
+ if( has_pre ) { out.append(", "); }
+ out.append(eirDataBitToString(settingBit));
+ has_pre = true;
+ }
}
out.append("]");
return out;
diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/DBTAdapter.cpp
index 38cefe6d..284f24db 100644
--- a/src/direct_bt/DBTAdapter.cpp
+++ b/src/direct_bt/DBTAdapter.cpp
@@ -160,6 +160,7 @@ bool DBTAdapter::validateDevInfo() {
adapterInfo = mgmt.getAdapterInfo(dev_id);
mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DISCOVERING, bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceDiscoveringCB));
+ mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::NEW_SETTINGS, bindMemberFunc(this, &DBTAdapter::mgmtEvNewSettingsCB));
mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_CONNECTED, bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceConnectedCB));
mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_DISCONNECTED, bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceDisconnectedCB));
mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_FOUND, bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceFoundCB));
@@ -200,11 +201,11 @@ DBTAdapter::~DBTAdapter() {
keepDiscoveringAlive = false;
{
int count;
- if( 4 != ( count = mgmt.removeMgmtEventCallback(dev_id) ) ) {
- ERR_PRINT("DBTAdapter removeMgmtEventCallback(DISCOVERING) not 4 but %d", count);
+ if( 5 != ( count = mgmt.removeMgmtEventCallback(dev_id) ) ) {
+ ERR_PRINT("DBTAdapter removeMgmtEventCallback(DISCOVERING) not 5 but %d", count);
}
}
- deviceStatusListener = nullptr;
+ statusListener = nullptr;
removeDiscoveredDevices();
@@ -231,10 +232,10 @@ std::shared_ptr<HCISession> DBTAdapter::open()
return session;
}
-std::shared_ptr<DBTDeviceStatusListener> DBTAdapter::setDeviceStatusListener(std::shared_ptr<DBTDeviceStatusListener> l)
+std::shared_ptr<DBTAdapterStatusListener> DBTAdapter::setStatusListener(std::shared_ptr<DBTAdapterStatusListener> l)
{
- std::shared_ptr<DBTDeviceStatusListener> o = deviceStatusListener;
- deviceStatusListener = l;
+ std::shared_ptr<DBTAdapterStatusListener> o = statusListener;
+ statusListener = l;
return o;
}
@@ -338,6 +339,21 @@ bool DBTAdapter::mgmtEvDeviceDiscoveringCB(std::shared_ptr<MgmtEvent> e) {
return true;
}
+bool DBTAdapter::mgmtEvNewSettingsCB(std::shared_ptr<MgmtEvent> e) {
+ DBG_PRINT("DBTAdapter::EventCB:NewSettings: %s", e->toString().c_str());
+ const MgmtEvtNewSettings &event = *static_cast<const MgmtEvtNewSettings *>(e.get());
+ AdapterSetting old_setting = adapterInfo->getCurrentSetting();
+ AdapterSetting changes = adapterInfo->setCurrentSetting(event.getSettings());
+ DBG_PRINT("DBTAdapter::EventCB:NewSettings: %s -> %s, changes %s",
+ adapterSettingsToString(old_setting).c_str(),
+ adapterSettingsToString(adapterInfo->getCurrentSetting()).c_str(),
+ adapterSettingsToString(changes).c_str() );
+ if( nullptr != statusListener ) {
+ statusListener->adapterSettingsChanged(*this, old_setting, adapterInfo->getCurrentSetting(), changes, event.getTimestamp());
+ }
+ return true;
+}
+
bool DBTAdapter::mgmtEvDeviceConnectedCB(std::shared_ptr<MgmtEvent> e) {
const MgmtEvtDeviceConnected &event = *static_cast<const MgmtEvtDeviceConnected *>(e.get());
if( nullptr == session ) {
@@ -364,11 +380,11 @@ bool DBTAdapter::mgmtEvDeviceConnectedCB(std::shared_ptr<MgmtEvent> e) {
if( new_connect ) {
session->connected(device); // track it
}
- if( nullptr != deviceStatusListener ) {
+ if( nullptr != statusListener ) {
if( EIRDataType::NONE != updateMask ) {
- deviceStatusListener->deviceUpdated(*this, device, ad_report.getTimestamp(), updateMask);
+ statusListener->deviceUpdated(*this, device, ad_report.getTimestamp(), updateMask);
}
- deviceStatusListener->deviceConnected(*this, device, event.getTimestamp());
+ statusListener->deviceConnected(*this, device, event.getTimestamp());
}
} else {
DBG_PRINT("DBTAdapter::EventCB:DeviceConnected(dev_id %d): %s,\n %s\n -> Device not tracked nor discovered",
@@ -385,8 +401,8 @@ bool DBTAdapter::mgmtEvDeviceDisconnectedCB(std::shared_ptr<MgmtEvent> e) {
if( nullptr != device ) {
DBG_PRINT("DBTAdapter::EventCB:DeviceDisconnected(dev_id %d): %s\n -> %s",
dev_id, event.toString().c_str(), device->toString().c_str());
- if( nullptr != deviceStatusListener ) {
- deviceStatusListener->deviceDisconnected(*this, device, event.getTimestamp());
+ if( nullptr != statusListener ) {
+ statusListener->deviceDisconnected(*this, device, event.getTimestamp());
}
} else {
DBG_PRINT("DBTAdapter::EventCB:DeviceDisconnected(dev_id %d): %s\n -> Device not tracked",
@@ -413,14 +429,14 @@ bool DBTAdapter::mgmtEvDeviceFoundCB(std::shared_ptr<MgmtEvent> e) {
// new device
dev = std::shared_ptr<DBTDevice>(new DBTDevice(*this, ad_report));
addDiscoveredDevice(dev);
- if( nullptr != deviceStatusListener ) {
- deviceStatusListener->deviceFound(*this, dev, ad_report.getTimestamp());
+ if( nullptr != statusListener ) {
+ statusListener->deviceFound(*this, dev, ad_report.getTimestamp());
}
} else {
// existing device
EIRDataType updateMask = dev->update(ad_report);
- if( EIRDataType::NONE != updateMask && nullptr != deviceStatusListener ) {
- deviceStatusListener->deviceUpdated(*this, dev, ad_report.getTimestamp(), updateMask);
+ if( EIRDataType::NONE != updateMask && nullptr != statusListener ) {
+ statusListener->deviceUpdated(*this, dev, ad_report.getTimestamp(), updateMask);
}
}
return true;
diff --git a/src/direct_bt/DBTManager.cpp b/src/direct_bt/DBTManager.cpp
index 5fca460c..508494ef 100644
--- a/src/direct_bt/DBTManager.cpp
+++ b/src/direct_bt/DBTManager.cpp
@@ -352,7 +352,6 @@ next1:
addMgmtEventCallback(-1, MgmtEvent::Opcode::CLASS_OF_DEV_CHANGED, bindMemberFunc(this, &DBTManager::mgmtEvClassOfDeviceChangedCB));
addMgmtEventCallback(-1, MgmtEvent::Opcode::LOCAL_NAME_CHANGED, bindMemberFunc(this, &DBTManager::mgmtEvLocalNameChangedCB));
addMgmtEventCallback(-1, MgmtEvent::Opcode::DISCOVERING, bindMemberFunc(this, &DBTManager::mgmtEvDeviceDiscoveringCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_SETTINGS, bindMemberFunc(this, &DBTManager::mgmtEvNewSettingsCB));
addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_FOUND, bindMemberFunc(this, &DBTManager::mgmtEvDeviceFoundCB));
addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_DISCONNECTED, bindMemberFunc(this, &DBTManager::mgmtEvDeviceDisconnectedCB));
addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_CONNECTED, bindMemberFunc(this, &DBTManager::mgmtEvDeviceConnectedCB));
@@ -619,11 +618,11 @@ void DBTManager::clearAllMgmtEventCallbacks() {
}
bool DBTManager::mgmtEvClassOfDeviceChangedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:ClassOfDeviceChanged: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:ClassOfDeviceChanged: %s", e->toString().c_str());
return true;
}
bool DBTManager::mgmtEvLocalNameChangedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:LocalNameChanged: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:LocalNameChanged: %s", e->toString().c_str());
const MgmtEvtLocalNameChanged &event = *static_cast<const MgmtEvtLocalNameChanged *>(e.get());
std::shared_ptr<AdapterInfo> adapterInfo = getAdapterInfo(event.getDevID());
std::string old_name = adapterInfo->getName();
@@ -636,7 +635,7 @@ bool DBTManager::mgmtEvLocalNameChangedCB(std::shared_ptr<MgmtEvent> e) {
if( shortNameChanged ) {
adapterInfo->setShortName(event.getShortName());
}
- DBG_PRINT("DBRManager::EventCB:LocalNameChanged: Name: %d: '%s' -> '%s'; ShortName: %d: '%s' -> '%s'",
+ DBG_PRINT("DBTManager::EventCB:LocalNameChanged: Name: %d: '%s' -> '%s'; ShortName: %d: '%s' -> '%s'",
nameChanged, old_name.c_str(), adapterInfo->getName().c_str(),
shortNameChanged, old_shortName.c_str(), adapterInfo->getShortName().c_str());
(void)nameChanged;
@@ -644,73 +643,61 @@ bool DBTManager::mgmtEvLocalNameChangedCB(std::shared_ptr<MgmtEvent> e) {
return true;
}
bool DBTManager::mgmtEvDeviceDiscoveringCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceDiscovering: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceDiscovering: %s", e->toString().c_str());
const MgmtEvtDiscovering &event = *static_cast<const MgmtEvtDiscovering *>(e.get());
(void)event;
return true;
}
-bool DBTManager::mgmtEvNewSettingsCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:NewSettings: %s", e->toString().c_str());
- const MgmtEvtNewSettings &event = *static_cast<const MgmtEvtNewSettings *>(e.get());
- std::shared_ptr<AdapterInfo> adapterInfo = getAdapterInfo(event.getDevID());
- MgmtSetting old_setting = adapterInfo->getCurrentSetting();
- int res = adapterInfo->setCurrentSetting(event.getSettings());
- DBG_PRINT("DBRManager::EventCB:NewSettings: %d: %s -> %s", res,
- getMgmtSettingsString(old_setting).c_str(),
- getMgmtSettingsString(adapterInfo->getCurrentSetting()).c_str());
- (void)res;
- return true;
-}
bool DBTManager::mgmtEvDeviceFoundCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceFound: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceFound: %s", e->toString().c_str());
const MgmtEvtDeviceFound &event = *static_cast<const MgmtEvtDeviceFound *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvDeviceDisconnectedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceDisconnected: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceDisconnected: %s", e->toString().c_str());
const MgmtEvtDeviceDisconnected &event = *static_cast<const MgmtEvtDeviceDisconnected *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvDeviceConnectedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceConnected: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceConnected: %s", e->toString().c_str());
const MgmtEvtDeviceConnected &event = *static_cast<const MgmtEvtDeviceConnected *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvConnectFailedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:ConnectFailed: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:ConnectFailed: %s", e->toString().c_str());
const MgmtEvtDeviceConnectFailed &event = *static_cast<const MgmtEvtDeviceConnectFailed *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvDevicePinCodeRequestCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:PinCodeRequest: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:PinCodeRequest: %s", e->toString().c_str());
const MgmtEvtPinCodeRequest &event = *static_cast<const MgmtEvtPinCodeRequest *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvDeviceUnpairedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceUnpaired: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceUnpaired: %s", e->toString().c_str());
const MgmtEvtDeviceUnpaired &event = *static_cast<const MgmtEvtDeviceUnpaired *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvNewConnectionParamCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:NewConnectionParam: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:NewConnectionParam: %s", e->toString().c_str());
const MgmtEvtNewConnectionParam &event = *static_cast<const MgmtEvtNewConnectionParam *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvDeviceWhitelistAddedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceAdded: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceAdded: %s", e->toString().c_str());
const MgmtEvtDeviceWhitelistAdded &event = *static_cast<const MgmtEvtDeviceWhitelistAdded *>(e.get());
(void)event;
return true;
}
bool DBTManager::mgmtEvDeviceWhilelistRemovedCB(std::shared_ptr<MgmtEvent> e) {
- DBG_PRINT("DBRManager::EventCB:DeviceRemoved: %s", e->toString().c_str());
+ DBG_PRINT("DBTManager::EventCB:DeviceRemoved: %s", e->toString().c_str());
const MgmtEvtDeviceWhitelistRemoved &event = *static_cast<const MgmtEvtDeviceWhitelistRemoved *>(e.get());
(void)event;
return true;
diff --git a/src/direct_bt/MgmtTypes.cpp b/src/direct_bt/MgmtTypes.cpp
index 17617762..81070e74 100644
--- a/src/direct_bt/MgmtTypes.cpp
+++ b/src/direct_bt/MgmtTypes.cpp
@@ -55,43 +55,45 @@ using namespace direct_bt;
// *************************************************
#define CASE_TO_STRING(V) case V: return #V;
+#define CASE2_TO_STRING(U,V) case U::V: return #V;
#define SETTING_ENUM(X) \
- X(MGMT_SETTING_POWERED) \
- X(MGMT_SETTING_CONNECTABLE) \
- X(MGMT_SETTING_FAST_CONNECTABLE) \
- X(MGMT_SETTING_DISCOVERABLE) \
- X(MGMT_SETTING_BONDABLE) \
- X(MGMT_SETTING_LINK_SECURITY) \
- X(MGMT_SETTING_SSP) \
- X(MGMT_SETTING_BREDR) \
- X(MGMT_SETTING_HS) \
- X(MGMT_SETTING_LE) \
- X(MGMT_SETTING_ADVERTISING) \
- X(MGMT_SETTING_SECURE_CONN) \
- X(MGMT_SETTING_DEBUG_KEYS) \
- X(MGMT_SETTING_PRIVACY) \
- X(MGMT_SETTING_CONFIGURATION) \
- X(MGMT_SETTING_STATIC_ADDRESS) \
- X(MGMT_SETTING_PHY_CONFIGURATION) \
+ X(AdapterSetting,NONE) \
+ X(AdapterSetting,POWERED) \
+ X(AdapterSetting,CONNECTABLE) \
+ X(AdapterSetting,FAST_CONNECTABLE) \
+ X(AdapterSetting,DISCOVERABLE) \
+ X(AdapterSetting,BONDABLE) \
+ X(AdapterSetting,LINK_SECURITY) \
+ X(AdapterSetting,SSP) \
+ X(AdapterSetting,BREDR) \
+ X(AdapterSetting,HS) \
+ X(AdapterSetting,LE) \
+ X(AdapterSetting,ADVERTISING) \
+ X(AdapterSetting,SECURE_CONN) \
+ X(AdapterSetting,DEBUG_KEYS) \
+ X(AdapterSetting,PRIVACY) \
+ X(AdapterSetting,CONFIGURATION) \
+ X(AdapterSetting,STATIC_ADDRESS) \
+ X(AdapterSetting,PHY_CONFIGURATION)
-std::string direct_bt::getMgmtSettingBitString(const MgmtSetting settingBit) {
+std::string direct_bt::adapterSettingBitToString(const AdapterSetting settingBit) {
switch(settingBit) {
- SETTING_ENUM(CASE_TO_STRING)
+ SETTING_ENUM(CASE2_TO_STRING)
default: ; // fall through intended
}
return "Unknown Setting Bit";
}
-std::string direct_bt::getMgmtSettingsString(const MgmtSetting settingMask) {
+std::string direct_bt::adapterSettingsToString(const AdapterSetting settingMask) {
const uint32_t one = 1;
bool has_pre = false;
std::string out("[");
for(int i=0; i<32; i++) {
- const MgmtSetting settingBit = static_cast<MgmtSetting>( one << i );
- if( 0 != ( settingMask & settingBit ) ) {
+ const AdapterSetting settingBit = static_cast<AdapterSetting>( one << i );
+ if( AdapterSetting::NONE != ( settingMask & settingBit ) ) {
if( has_pre ) { out.append(", "); }
- out.append(getMgmtSettingBitString(settingBit));
+ out.append(adapterSettingBitToString(settingBit));
has_pre = true;
}
}