aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/HCIHandler.hpp2
-rw-r--r--api/direct_bt/HCITypes.hpp10
-rw-r--r--src/direct_bt/HCIHandler.cpp31
-rw-r--r--src/direct_bt/HCITypes.cpp5
4 files changed, 35 insertions, 13 deletions
diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp
index 1b3ad394..776eb5a3 100644
--- a/api/direct_bt/HCIHandler.hpp
+++ b/api/direct_bt/HCIHandler.hpp
@@ -331,6 +331,8 @@ namespace direct_bt {
*/
HCIStatusCode reset() noexcept;
+ HCIStatusCode getLocalVersion(HCILocalVersion &version) noexcept;
+
/**
* Sets LE scanning parameters.
* <p>
diff --git a/api/direct_bt/HCITypes.hpp b/api/direct_bt/HCITypes.hpp
index c2871d8e..97f88cf7 100644
--- a/api/direct_bt/HCITypes.hpp
+++ b/api/direct_bt/HCITypes.hpp
@@ -933,6 +933,16 @@ namespace direct_bt {
// hcistruct * getWStruct() noexcept { return (hcistruct *)( pdu.get_wptr_nc(number(HCIConstU8::EVENT_HDR_SIZE)+1) ); }
};
+ struct HCILocalVersion {
+ uint8_t hci_ver;
+ uint16_t hci_rev;
+ uint8_t lmp_ver;
+ uint16_t manufacturer;
+ uint16_t lmp_subver;
+
+ std::string toString() noexcept;
+ };
+
} // namespace direct_bt
#endif /* HCI_TYPES_HPP_ */
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 */