diff options
author | Sven Gothel <[email protected]> | 2020-10-14 18:50:18 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-14 18:50:18 +0200 |
commit | 84c3223d4ca0de21caf40b523357bf4e42b90b70 (patch) | |
tree | 812161cfb7ac6af1d53663aa31f5bc36e584753c /src | |
parent | 4b7dea80e1a56b72dd3fc11d18178a26d70b66bc (diff) |
HCIHandler ctor: Move 'getLocalVersion(..)' from ctor to user-method, as an optional lazy POWERED test.
Diffstat (limited to 'src')
-rw-r--r-- | src/direct_bt/HCIHandler.cpp | 31 | ||||
-rw-r--r-- | src/direct_bt/HCITypes.cpp | 5 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp index 218c064d..eb300449 100644 --- a/src/direct_bt/HCIHandler.cpp +++ b/src/direct_bt/HCIHandler.cpp @@ -507,19 +507,6 @@ HCIHandler::HCIHandler(const BTMode btMode, const uint16_t dev_id) noexcept filter_set_opcbit(HCIOpcodeBit::LE_CREATE_CONN, mask); filter_put_opcbit(mask); } - { - HCICommand req0(HCIOpcode::READ_LOCAL_VERSION, 0); - const hci_rp_read_local_version * ev_lv; - HCIStatusCode status; - std::shared_ptr<HCIEvent> ev = processCommandComplete(req0, &ev_lv, &status); - if( nullptr == ev || nullptr == ev_lv ) { - ERR_PRINT("HCIHandler::ctor: failed READ_LOCAL_VERSION: 0x%x (%s)", number(status), getHCIStatusCodeString(status).c_str()); - goto fail; - } - WORDY_PRINT("HCIHandler: LOCAL_VERSION: %d (rev %d), manuf 0x%x, lmp %d (subver %d)", - ev_lv->hci_ver, le_to_cpu(ev_lv->hci_rev), le_to_cpu(ev_lv->manufacturer), - ev_lv->lmp_ver, le_to_cpu(ev_lv->lmp_subver)); - } PERF_TS_TD("HCIHandler::open.ok"); return; @@ -632,6 +619,24 @@ HCIStatusCode HCIHandler::reset() noexcept { return ev_cc->getReturnStatus(0); } +HCIStatusCode HCIHandler::getLocalVersion(HCILocalVersion &version) noexcept { + HCICommand req0(HCIOpcode::READ_LOCAL_VERSION, 0); + const hci_rp_read_local_version * ev_lv; + HCIStatusCode status; + std::shared_ptr<HCIEvent> ev = processCommandComplete(req0, &ev_lv, &status); + if( nullptr == ev || nullptr == ev_lv || HCIStatusCode::SUCCESS != status ) { + ERR_PRINT("HCIHandler::getLocalVersion: READ_LOCAL_VERSION: 0x%x (%s)", number(status), getHCIStatusCodeString(status).c_str()); + bzero(&version, sizeof(version)); + } else { + version.hci_ver = ev_lv->hci_ver; + version.hci_rev = le_to_cpu(ev_lv->hci_rev); + version.manufacturer = le_to_cpu(ev_lv->manufacturer); + version.lmp_ver = ev_lv->lmp_ver; + version.lmp_subver = le_to_cpu(ev_lv->lmp_subver); + } + return status; +} + HCIStatusCode HCIHandler::le_set_scan_param(const bool le_scan_active, const HCILEOwnAddressType own_mac_type, const uint16_t le_scan_interval, const uint16_t le_scan_window, diff --git a/src/direct_bt/HCITypes.cpp b/src/direct_bt/HCITypes.cpp index fe72c64a..960e3e3e 100644 --- a/src/direct_bt/HCITypes.cpp +++ b/src/direct_bt/HCITypes.cpp @@ -298,4 +298,9 @@ std::shared_ptr<HCIEvent> HCIEvent::getSpecialized(const uint8_t * buffer, int c return std::shared_ptr<HCIEvent>(res); } +std::string HCILocalVersion::toString() noexcept { + return "LocalVersion[version "+std::to_string(hci_ver)+"."+std::to_string(hci_rev)+ + ", manuf "+uint16HexString(manufacturer)+", lmp "+std::to_string(lmp_ver)+"."+std::to_string(lmp_subver)+"]"; +} + } /* namespace direct_bt */ |