diff options
-rw-r--r-- | api/direct_bt/BTAdapter.hpp | 58 | ||||
-rw-r--r-- | api/direct_bt/BTManager.hpp | 10 | ||||
-rw-r--r-- | api/direct_bt/HCIHandler.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/MgmtTypes.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/SMPHandler.hpp | 2 | ||||
-rw-r--r-- | examples/dbt_peripheral00.cpp | 3 | ||||
-rw-r--r-- | examples/dbt_repeater00.cpp | 11 | ||||
-rw-r--r-- | examples/dbt_scanner10.cpp | 3 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTManager.cxx | 7 | ||||
-rw-r--r-- | src/direct_bt/BTAdapter.cpp | 96 | ||||
-rw-r--r-- | src/direct_bt/BTManager.cpp | 6 | ||||
-rw-r--r-- | trial/direct_bt/dbt_endpoint.hpp | 7 |
12 files changed, 86 insertions, 121 deletions
diff --git a/api/direct_bt/BTAdapter.hpp b/api/direct_bt/BTAdapter.hpp index 84d6e40c..5db20498 100644 --- a/api/direct_bt/BTAdapter.hpp +++ b/api/direct_bt/BTAdapter.hpp @@ -515,45 +515,45 @@ namespace direct_bt { void l2capServerEnd(jau::service_runner& sr) noexcept; std::unique_ptr<L2CAPClient> get_l2cap_connection(std::shared_ptr<BTDevice> device); - bool mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept; + void mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept; void updateAdapterSettings(const bool off_thread, const AdapterSetting new_settings, const bool sendEvent, const uint64_t timestamp) noexcept; - bool mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept; - bool mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvNewLinkKeyMgmt(const MgmtEvent& e) noexcept; - - bool mgmtEvHCIAnyHCI(const MgmtEvent& e) noexcept; - bool mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept; - bool mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept; - - bool mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept; - bool mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept; - bool mgmtEvHCILEPhyUpdateCompleteHCI(const MgmtEvent& e) noexcept; - bool mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept; + void mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept; + void mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept; + void mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept; + void mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept; + void mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept; + void mgmtEvNewLinkKeyMgmt(const MgmtEvent& e) noexcept; + + void mgmtEvHCIAnyHCI(const MgmtEvent& e) noexcept; + void mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept; + void mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept; + + void mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept; + void mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept; + void mgmtEvHCILEPhyUpdateCompleteHCI(const MgmtEvent& e) noexcept; + void mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept; // Local BTRole::Slave - bool mgmtEvLELTKReqEventHCI(const MgmtEvent& e) noexcept; - bool mgmtEvLELTKReplyAckCmdHCI(const MgmtEvent& e) noexcept; - bool mgmtEvLELTKReplyRejCmdHCI(const MgmtEvent& e) noexcept; + void mgmtEvLELTKReqEventHCI(const MgmtEvent& e) noexcept; + void mgmtEvLELTKReplyAckCmdHCI(const MgmtEvent& e) noexcept; + void mgmtEvLELTKReplyRejCmdHCI(const MgmtEvent& e) noexcept; // Local BTRole::Master - bool mgmtEvLEEnableEncryptionCmdHCI(const MgmtEvent& e) noexcept; - bool mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept; - bool mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noexcept; + void mgmtEvLEEnableEncryptionCmdHCI(const MgmtEvent& e) noexcept; + void mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept; + void mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noexcept; void updateDeviceDiscoveringState(const ScanType eventScanType, const bool eventEnabled) noexcept; - bool mgmtEvDeviceDiscoveringAny(const ScanType eventScanType, const bool eventEnabled, const uint64_t eventTimestamp, + void mgmtEvDeviceDiscoveringAny(const ScanType eventScanType, const bool eventEnabled, const uint64_t eventTimestamp, const bool hciSourced) noexcept; - bool mgmtEvPinCodeRequestMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept; - bool mgmtEvDeviceUnpairedMgmt(const MgmtEvent& e) noexcept; + void mgmtEvPinCodeRequestMgmt(const MgmtEvent& e) noexcept; + void mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept; + void mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept; + void mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept; + void mgmtEvDeviceUnpairedMgmt(const MgmtEvent& e) noexcept; - bool hciSMPMsgCallback(const BDAddressAndType & addressAndType, + void hciSMPMsgCallback(const BDAddressAndType & addressAndType, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept; void sendDevicePairingState(BTDeviceRef device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept; void notifyPairingStageDone(BTDeviceRef device, uint64_t timestamp) noexcept; diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp index e65dc209..5ef3dc6e 100644 --- a/api/direct_bt/BTManager.hpp +++ b/api/direct_bt/BTManager.hpp @@ -157,13 +157,12 @@ namespace direct_bt { * * @param added true if adapter was newly added, otherwise removed from system * @param adapter the shared DBTAdapter reference - * @return ignored * @see ChangedAdapterSetCallback * @see BTManager::addChangedAdapterSetCallback() * @see BTManager::removeChangedAdapterSetCallback() * @see [Direct-BT Overview](namespacedirect__bt.html#details) */ - typedef bool (*ChangedAdapterSetFunc)(bool added, std::shared_ptr<BTAdapter>& adapter); + typedef void (*ChangedAdapterSetFunc)(bool added, std::shared_ptr<BTAdapter>& adapter); /** * Callback jau::function to receive change events regarding the system's adapter set, @@ -184,13 +183,12 @@ namespace direct_bt { * * @param added true if adapter was newly added, otherwise removed from system * @param adapter the shared DBTAdapter reference - * @return ignored * @see ChangedAdapterSetFunc * @see BTManager::addChangedAdapterSetCallback() * @see BTManager::removeChangedAdapterSetCallback() * @see [Direct-BT Overview](namespacedirect__bt.html#details) */ - typedef jau::function<bool(bool, std::shared_ptr<BTAdapter>&)> ChangedAdapterSetCallback; + typedef jau::function<void(bool, std::shared_ptr<BTAdapter>&)> ChangedAdapterSetCallback; typedef jau::cow_darray<ChangedAdapterSetCallback> ChangedAdapterSetCallbackList; /** @@ -302,8 +300,8 @@ namespace direct_bt { void processAdapterAdded(std::unique_ptr<MgmtEvent> e) noexcept; void processAdapterRemoved(std::unique_ptr<MgmtEvent> e) noexcept; - bool mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept; - bool mgmtEventAnyCB(const MgmtEvent& e) noexcept; + void mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept; + void mgmtEventAnyCB(const MgmtEvent& e) noexcept; std::shared_ptr<BTAdapter> addAdapter(const AdapterInfo& ai) noexcept; diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp index 4e483b4e..d08874dd 100644 --- a/api/direct_bt/HCIHandler.hpp +++ b/api/direct_bt/HCIHandler.hpp @@ -163,7 +163,7 @@ namespace direct_bt { } }; - typedef jau::function<bool(const BDAddressAndType& /* addressAndType */, + typedef jau::function<void(const BDAddressAndType& /* addressAndType */, const SMPPDUMsg&, const HCIACLData::l2cap_frame& /* source */)> HCISMPMsgCallback; typedef jau::cow_darray<HCISMPMsgCallback> HCISMPMsgCallbackList; diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp index 0fdd9e5f..78e9984a 100644 --- a/api/direct_bt/MgmtTypes.hpp +++ b/api/direct_bt/MgmtTypes.hpp @@ -2774,7 +2774,7 @@ namespace direct_bt { bool updateAdapterInfo(AdapterInfo& info) const noexcept; }; - typedef jau::function<bool(const MgmtEvent&)> MgmtEventCallback; + typedef jau::function<void(const MgmtEvent&)> MgmtEventCallback; typedef jau::cow_darray<MgmtEventCallback> MgmtEventCallbackList; class MgmtAdapterEventCallback { diff --git a/api/direct_bt/SMPHandler.hpp b/api/direct_bt/SMPHandler.hpp index bb250924..bef5138d 100644 --- a/api/direct_bt/SMPHandler.hpp +++ b/api/direct_bt/SMPHandler.hpp @@ -146,7 +146,7 @@ namespace direct_bt { }; - typedef jau::function<bool(const SMPPDUMsg&)> SMPSecurityReqCallback; + typedef jau::function<void(const SMPPDUMsg&)> SMPSecurityReqCallback; typedef jau::cow_darray<SMPSecurityReqCallback> SMPSecurityReqCallbackList; /** diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp index b5edba27..2c782747 100644 --- a/examples/dbt_peripheral00.cpp +++ b/examples/dbt_peripheral00.cpp @@ -691,7 +691,7 @@ static bool initAdapter(std::shared_ptr<BTAdapter>& adapter) { return true; } -static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) { +static void myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) { if( added ) { if( nullptr == chosenAdapter ) { if( initAdapter( adapter ) ) { @@ -712,7 +712,6 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> fprintf_td(stderr, "****** Adapter REMOVED (other): %s\n", adapter->toString().c_str()); } } - return true; } void test() { diff --git a/examples/dbt_repeater00.cpp b/examples/dbt_repeater00.cpp index 5f449081..82e0303d 100644 --- a/examples/dbt_repeater00.cpp +++ b/examples/dbt_repeater00.cpp @@ -846,20 +846,20 @@ static bool initAdapterToClient(std::shared_ptr<BTAdapter>& adapter) { // Common: To Server and Client // -static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) { +static void myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) { if( added ) { if( nullptr == adapterToServer ) { if( initAdapterToServer( adapter ) ) { adapterToServer = adapter; fprintf_td(stderr, "****** AdapterToServer ADDED__: InitOK: %s\n", adapter->toString().c_str()); - return true; + return; } } if( nullptr == adapterToClient ) { if( initAdapterToClient( adapter ) ) { adapterToClient = adapter; fprintf_td(stderr, "****** AdapterToClient ADDED__: InitOK: %s\n", adapter->toString().c_str()); - return true; + return; } } fprintf_td(stderr, "****** Adapter ADDED__: Ignored: %s\n", adapter->toString().c_str()); @@ -867,16 +867,15 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> if( nullptr != adapterToServer && adapter == adapterToServer ) { adapterToServer = nullptr; fprintf_td(stderr, "****** AdapterToServer REMOVED: %s\n", adapter->toString().c_str()); - return true; + return; } if( nullptr != adapterToClient && adapter == adapterToClient ) { adapterToClient = nullptr; fprintf_td(stderr, "****** AdapterToClient REMOVED: %s\n", adapter->toString().c_str()); - return true; + return; } fprintf_td(stderr, "****** Adapter REMOVED: Ignored %s\n", adapter->toString().c_str()); } - return true; } void test() { diff --git a/examples/dbt_scanner10.cpp b/examples/dbt_scanner10.cpp index c65b23fe..9dd479e0 100644 --- a/examples/dbt_scanner10.cpp +++ b/examples/dbt_scanner10.cpp @@ -663,7 +663,7 @@ static bool initAdapter(std::shared_ptr<BTAdapter>& adapter) { return true; } -static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) { +static void myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) { if( added ) { if( nullptr == chosenAdapter ) { if( initAdapter( adapter ) ) { @@ -683,7 +683,6 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> fprintf_td(stderr, "****** Adapter REMOVED (other): %s\n", adapter->toString().c_str()); } } - return true; } void test() { diff --git a/java/jni/direct_bt/DBTManager.cxx b/java/jni/direct_bt/DBTManager.cxx index 684cf79a..6d51c425 100644 --- a/java/jni/direct_bt/DBTManager.cxx +++ b/java/jni/direct_bt/DBTManager.cxx @@ -70,8 +70,8 @@ static void _addMgmtCBOnce(JNIEnv *env, BTManager & mgmt, JNIGlobalRef jmgmtRef, const std::string &jmethodName, const std::string &jmethodArgs) { try { - bool(*nativeCallback)(BooleanMgmtCBContextRef&, const MgmtEvent&) = - [](BooleanMgmtCBContextRef& ctx_ref, const MgmtEvent& e)->bool { + void(*nativeCallback)(BooleanMgmtCBContextRef&, const MgmtEvent&) = + [](BooleanMgmtCBContextRef& ctx_ref, const MgmtEvent& e)->void { JNIEnv *env_ = *jni_env; const int dev_id = e.getDevID(); @@ -86,7 +86,6 @@ static void _addMgmtCBOnce(JNIEnv *env, BTManager & mgmt, JNIGlobalRef jmgmtRef, env_->CallVoidMethod(*(ctx_ref->jmgmtRef), ctx_ref->mid, dev_id, ctx_ref->opc); // updated } } - return true; }; @@ -102,7 +101,7 @@ static void _addMgmtCBOnce(JNIEnv *env, BTManager & mgmt, JNIGlobalRef jmgmtRef, } // move BooleanDeviceCBContextRef into jau::func::capval_target_t and operator== includes javaCallback comparison - jau::function<bool(const MgmtEvent&)> funcDef = jau::bind_capval(std::make_shared<BooleanMgmtCBContext>(opc, jmgmtRef, mid), nativeCallback); + jau::function<void(const MgmtEvent&)> funcDef = jau::bind_capval(std::make_shared<BooleanMgmtCBContext>(opc, jmgmtRef, mid), nativeCallback); mgmt.addMgmtEventCallback(-1, opc, funcDef); } catch(...) { rethrow_and_raise_java_exception(env); diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp index 55263cda..3efca230 100644 --- a/src/direct_bt/BTAdapter.cpp +++ b/src/direct_bt/BTAdapter.cpp @@ -1630,27 +1630,26 @@ void BTAdapter::sendDeviceUpdated(std::string cause, BTDeviceRef device, uint64_ // ************************************************* -bool BTAdapter::mgmtEvHCIAnyHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvHCIAnyHCI(const MgmtEvent& e) noexcept { DBG_PRINT("BTAdapter:hci::Any: %s", e.toString().c_str()); (void)e; - return true; } -bool BTAdapter::mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept { const MgmtEvtDiscovering &event = *static_cast<const MgmtEvtDiscovering *>(&e); - return mgmtEvDeviceDiscoveringAny(event.getScanType(), event.getEnabled(), event.getTimestamp(), true /* hciSourced */); + mgmtEvDeviceDiscoveringAny(event.getScanType(), event.getEnabled(), event.getTimestamp(), true /* hciSourced */); } -bool BTAdapter::mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept { const MgmtEvtDiscovering &event = *static_cast<const MgmtEvtDiscovering *>(&e); - return mgmtEvDeviceDiscoveringAny(event.getScanType(), event.getEnabled(), event.getTimestamp(), false /* hciSourced */); + mgmtEvDeviceDiscoveringAny(event.getScanType(), event.getEnabled(), event.getTimestamp(), false /* hciSourced */); } void BTAdapter::updateDeviceDiscoveringState(const ScanType eventScanType, const bool eventEnabled) noexcept { mgmtEvDeviceDiscoveringAny(eventScanType, eventEnabled, jau::getCurrentMilliseconds(), false /* hciSourced */); } -bool BTAdapter::mgmtEvDeviceDiscoveringAny(const ScanType eventScanType, const bool eventEnabled, const uint64_t eventTimestamp, +void BTAdapter::mgmtEvDeviceDiscoveringAny(const ScanType eventScanType, const bool eventEnabled, const uint64_t eventTimestamp, const bool hciSourced) noexcept { const std::string srctkn = hciSourced ? "hci" : "mgmt"; ScanType currentNativeScanType = hci.getCurrentScanType(); @@ -1714,16 +1713,14 @@ bool BTAdapter::mgmtEvDeviceDiscoveringAny(const ScanType eventScanType, const b { discovery_service.start(); } - return true; } -bool BTAdapter::mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept { COND_PRINT(debug_event, "BTAdapter:mgmt:NewSettings: %s", e.toString().c_str()); const MgmtEvtNewSettings &event = *static_cast<const MgmtEvtNewSettings *>(&e); const AdapterSetting new_settings = adapterInfo.setCurrentSettingMask(event.getSettings()); // probably done by mgmt callback already updateAdapterSettings(true /* off_thread */, new_settings, true /* sendEvent */, event.getTimestamp()); - return true; } void BTAdapter::updateAdapterSettings(const bool off_thread, const AdapterSetting new_settings, const bool sendEvent, const uint64_t timestamp) noexcept { @@ -1767,7 +1764,7 @@ void BTAdapter::updateAdapterSettings(const bool off_thread, const AdapterSettin } } -bool BTAdapter::mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept { COND_PRINT(debug_event, "BTAdapter:mgmt:LocalNameChanged: %s", e.toString().c_str()); const MgmtEvtLocalNameChanged &event = *static_cast<const MgmtEvtLocalNameChanged *>(&e); std::string old_name = getName(); @@ -1785,7 +1782,6 @@ bool BTAdapter::mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept { shortNameChanged, old_shortName.c_str(), getShortName().c_str()); (void)nameChanged; (void)shortNameChanged; - return true; } void BTAdapter::l2capServerInit(jau::service_runner& sr0) noexcept { @@ -1894,7 +1890,7 @@ jau::fraction_i64 BTAdapter::smp_timeoutfunc(jau::simple_timer& timer) { return timer.shall_stop() ? 0_s : SMP_NEXT_EVENT_TIMEOUT_MS; // keep going until BTAdapter closes } -bool BTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept { const MgmtEvtDeviceConnected &event = *static_cast<const MgmtEvtDeviceConnected *>(&e); EInfoReport ad_report; { @@ -2023,10 +2019,9 @@ bool BTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept { // Hence .. induce it right after connect device->notifyLEFeatures(device, LE_Features::LE_Encryption); } - return true; } -bool BTAdapter::mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept { const MgmtEvtDeviceConnectFailed &event = *static_cast<const MgmtEvtDeviceConnectFailed *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2061,10 +2056,9 @@ bool BTAdapter::mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:DeviceDisconnected(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCILERemoteFeatures &event = *static_cast<const MgmtEvtHCILERemoteFeatures *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2101,10 +2095,9 @@ bool BTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:LERemoteUserFeatures(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvHCILEPhyUpdateCompleteHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvHCILEPhyUpdateCompleteHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCILEPhyUpdateComplete &event = *static_cast<const MgmtEvtHCILEPhyUpdateComplete *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2117,10 +2110,9 @@ bool BTAdapter::mgmtEvHCILEPhyUpdateCompleteHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:LEPhyUpdateComplete(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept { const MgmtEvtDeviceDisconnected &event = *static_cast<const MgmtEvtDeviceDisconnected *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2128,7 +2120,7 @@ bool BTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept { if( device->getConnectionHandle() != event.getHCIHandle() ) { WORDY_PRINT("BTAdapter::hci:DeviceDisconnected(dev_id %d): ConnHandle mismatch %s\n -> %s", dev_id, event.toString().c_str(), device->toString().c_str()); - return true; + return; } DBG_PRINT("BTAdapter::hci:DeviceDisconnected(dev_id %d): %s, handle %s -> zero,\n -> %s", dev_id, event.toString().c_str(), jau::to_hexstring(event.getHCIHandle()).c_str(), @@ -2197,11 +2189,10 @@ bool BTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept { removeDevicePausingDiscovery(*device); } } - return true; } // Local BTRole::Slave -bool BTAdapter::mgmtEvLELTKReqEventHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvLELTKReqEventHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCILELTKReq &event = *static_cast<const MgmtEvtHCILELTKReq *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2212,9 +2203,8 @@ bool BTAdapter::mgmtEvLELTKReqEventHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:LE_LTK_Request(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvLELTKReplyAckCmdHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvLELTKReplyAckCmdHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCILELTKReplyAckCmd &event = *static_cast<const MgmtEvtHCILELTKReplyAckCmd *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2225,19 +2215,17 @@ bool BTAdapter::mgmtEvLELTKReplyAckCmdHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:LE_LTK_REPLY_ACK(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvLELTKReplyRejCmdHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvLELTKReplyRejCmdHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCILELTKReplyRejCmd &event = *static_cast<const MgmtEvtHCILELTKReplyRejCmd *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); DBG_PRINT("BTAdapter::hci:LE_LTK_REPLY_REJ(dev_id %d): Ignored: %s (tracked %d)", dev_id, event.toString().c_str(), (nullptr!=device)); - return true; } // Local BTRole::Master -bool BTAdapter::mgmtEvLEEnableEncryptionCmdHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvLEEnableEncryptionCmdHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCILEEnableEncryptionCmd &event = *static_cast<const MgmtEvtHCILEEnableEncryptionCmd *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2248,10 +2236,9 @@ bool BTAdapter::mgmtEvLEEnableEncryptionCmdHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:LE_ENABLE_ENC(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } // On BTRole::Master (reply to MgmtEvtHCILEEnableEncryptionCmd) and BTRole::Slave -bool BTAdapter::mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCIEncryptionChanged &event = *static_cast<const MgmtEvtHCIEncryptionChanged *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2265,10 +2252,9 @@ bool BTAdapter::mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::hci:ENC_CHANGED(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } // On BTRole::Master (reply to MgmtEvtHCILEEnableEncryptionCmd) and BTRole::Slave -bool BTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noexcept { const MgmtEvtHCIEncryptionKeyRefreshComplete &event = *static_cast<const MgmtEvtHCIEncryptionKeyRefreshComplete *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2282,10 +2268,9 @@ bool BTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noe WORDY_PRINT("BTAdapter::hci:ENC_KEY_REFRESH_COMPLETE(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept { const MgmtEvtPairDeviceComplete &event = *static_cast<const MgmtEvtPairDeviceComplete *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2298,10 +2283,9 @@ bool BTAdapter::mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::mgmt:PairDeviceComplete(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept { const MgmtEvtNewLongTermKey& event = *static_cast<const MgmtEvtNewLongTermKey *>(&e); const MgmtLongTermKeyInfo& ltk_info = event.getLongTermKey(); BTDeviceRef device = findConnectedDevice(ltk_info.address, ltk_info.address_type); @@ -2317,10 +2301,9 @@ bool BTAdapter::mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::mgmt:NewLongTermKey(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvNewLinkKeyMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvNewLinkKeyMgmt(const MgmtEvent& e) noexcept { const MgmtEvtNewLinkKey& event = *static_cast<const MgmtEvtNewLinkKey *>(&e); const MgmtLinkKeyInfo& lk_info = event.getLinkKey(); // lk_info.address_type might be wrongly reported by mgmt, i.e. BDADDR_BREDR, use any. @@ -2337,10 +2320,9 @@ bool BTAdapter::mgmtEvNewLinkKeyMgmt(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter::mgmt:NewLinkKey(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); } - return true; } -bool BTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept { // COND_PRINT(debug_event, "BTAdapter:hci:DeviceFound(dev_id %d): %s", dev_id, e.toString().c_str()); const MgmtEvtDeviceFound &deviceFoundEvent = *static_cast<const MgmtEvtDeviceFound *>(&e); @@ -2509,20 +2491,17 @@ bool BTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept { } } } - return true; } -bool BTAdapter::mgmtEvDeviceUnpairedMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvDeviceUnpairedMgmt(const MgmtEvent& e) noexcept { const MgmtEvtDeviceUnpaired &event = *static_cast<const MgmtEvtDeviceUnpaired *>(&e); DBG_PRINT("BTAdapter:mgmt:DeviceUnpaired: %s", event.toString().c_str()); - return true; } -bool BTAdapter::mgmtEvPinCodeRequestMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvPinCodeRequestMgmt(const MgmtEvent& e) noexcept { const MgmtEvtPinCodeRequest &event = *static_cast<const MgmtEvtPinCodeRequest *>(&e); DBG_PRINT("BTAdapter:mgmt:PinCodeRequest: %s", event.toString().c_str()); - return true; } -bool BTAdapter::mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept { const MgmtEvtAuthFailed &event = *static_cast<const MgmtEvtAuthFailed *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2530,13 +2509,12 @@ bool BTAdapter::mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter:hci:SMP: dev_id %d: Device not tracked: address[%s, %s], %s", dev_id, event.getAddress().toString().c_str(), to_string(event.getAddressType()).c_str(), event.toString().c_str()); - return true; + return; } const HCIStatusCode evtStatus = to_HCIStatusCode( event.getStatus() ); device->updatePairingState(device, e, evtStatus, SMPPairingState::FAILED); - return true; } -bool BTAdapter::mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept { const MgmtEvtUserConfirmRequest &event = *static_cast<const MgmtEvtUserConfirmRequest *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2544,13 +2522,12 @@ bool BTAdapter::mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter:hci:SMP: dev_id %d: Device not tracked: address[%s, %s], %s", dev_id, event.getAddress().toString().c_str(), to_string(event.getAddressType()).c_str(), event.toString().c_str()); - return true; + return; } // FIXME: Pass confirm_hint and value? device->updatePairingState(device, e, HCIStatusCode::SUCCESS, SMPPairingState::NUMERIC_COMPARE_EXPECTED); - return true; } -bool BTAdapter::mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept { +void BTAdapter::mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept { const MgmtEvtUserPasskeyRequest &event = *static_cast<const MgmtEvtUserPasskeyRequest *>(&e); BTDeviceRef device = findConnectedDevice(event.getAddress(), event.getAddressType()); @@ -2558,31 +2535,28 @@ bool BTAdapter::mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept { WORDY_PRINT("BTAdapter:hci:SMP: dev_id %d: Device not tracked: address[%s, %s], %s", dev_id, event.getAddress().toString().c_str(), to_string(event.getAddressType()).c_str(), event.toString().c_str()); - return true; + return; } device->updatePairingState(device, e, HCIStatusCode::SUCCESS, SMPPairingState::PASSKEY_EXPECTED); - return true; } -bool BTAdapter::hciSMPMsgCallback(const BDAddressAndType & addressAndType, +void BTAdapter::hciSMPMsgCallback(const BDAddressAndType & addressAndType, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept { BTDeviceRef device = findConnectedDevice(addressAndType.address, addressAndType.type); if( nullptr == device ) { WORDY_PRINT("BTAdapter:hci:SMP: dev_id %d: Device not tracked: address%s: %s, %s", dev_id, addressAndType.toString().c_str(), msg.toString().c_str(), source.toString().c_str()); - return true; + return; } if( device->getConnectionHandle() != source.handle ) { WORDY_PRINT("BTAdapter:hci:SMP: dev_id %d: ConnHandle mismatch address%s: %s, %s\n -> %s", dev_id, addressAndType.toString().c_str(), msg.toString().c_str(), source.toString().c_str(), device->toString().c_str()); - return true; + return; } device->hciSMPMsgCallback(device, msg, source); - - return true; } void BTAdapter::sendDevicePairingState(BTDeviceRef device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept diff --git a/src/direct_bt/BTManager.cpp b/src/direct_bt/BTManager.cpp index 33ef6df5..e20e67ac 100644 --- a/src/direct_bt/BTManager.cpp +++ b/src/direct_bt/BTManager.cpp @@ -1145,7 +1145,7 @@ void BTManager::processAdapterRemoved(std::unique_ptr<MgmtEvent> e) noexcept { DBG_PRINT("BTManager::Adapter[%d] Removed: RemoveAI failed", dev_id); } } -bool BTManager::mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept { +void BTManager::mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept { const MgmtEvtNewSettings &event = *static_cast<const MgmtEvtNewSettings *>(&e); std::shared_ptr<BTAdapter> adapter = getAdapter(event.getDevID()); if( nullptr != adapter ) { @@ -1162,13 +1162,11 @@ bool BTManager::mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept { to_string(event.getSettings()).c_str(), e.toString().c_str()); } - return true; } -bool BTManager::mgmtEventAnyCB(const MgmtEvent& e) noexcept { +void BTManager::mgmtEventAnyCB(const MgmtEvent& e) noexcept { DBG_PRINT("BTManager:mgmt:Any: %s", e.toString().c_str()); (void)e; - return true; } /** diff --git a/trial/direct_bt/dbt_endpoint.hpp b/trial/direct_bt/dbt_endpoint.hpp index 10e013dd..cd112e56 100644 --- a/trial/direct_bt/dbt_endpoint.hpp +++ b/trial/direct_bt/dbt_endpoint.hpp @@ -97,14 +97,14 @@ class DBTEndpoint { static std::mutex mtx_cas_endpts; static std::vector<DBTEndpointRef> cas_endpts; - static bool myChangedAdapterSetFunc(const bool added, BTAdapterRef& adapter) { + static void myChangedAdapterSetFunc(const bool added, BTAdapterRef& adapter) { if( added ) { for(DBTEndpointRef endpt : cas_endpts ) { if( nullptr == endpt->getAdapter() ) { if( endpt->initAdapter( adapter ) ) { endpt->setAdapter(adapter); jau::fprintf_td(stderr, "****** Adapter ADDED__: InitOK: %s\n", adapter->toString().c_str()); - return true; + return; } } } @@ -114,12 +114,11 @@ class DBTEndpoint { if( nullptr != endpt->getAdapter() && *adapter == *endpt->getAdapter() ) { endpt->setAdapter(nullptr); jau::fprintf_td(stderr, "****** Adapter REMOVED: %s\n", adapter->toString().c_str()); - return true; + return; } } jau::fprintf_td(stderr, "****** Adapter REMOVED: Ignored: %s\n", adapter->toString().c_str()); } - return true; } static ChangedAdapterSetCallback initChangedAdapterSetListener(const BTManagerRef& manager, std::vector<DBTEndpointRef> endpts) { |