aboutsummaryrefslogtreecommitdiffstats
path: root/src/direct_bt/HCIComm.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-06-01 01:37:57 +0200
committerSven Gothel <[email protected]>2020-06-01 01:37:57 +0200
commit728cbb0c31ac8cab0cc6e7551c78adab5e2a4a4d (patch)
tree4df09a49017cce5759e60c6eabc171c8d82d9f6a /src/direct_bt/HCIComm.cpp
parent9ae37c02afdcd6344f32e823e40f9ee8c4a9ae0a (diff)
Complete using definite tyep HCIErrorCode for disconnect reason; Add Mgmt DisconnectReason <-> HCIErrorCode mapping
BlueZ Kernel Mgmt uses its own disconnect reason code in its implementation, well ... We add mapping in both directions, Mgmt DisconnectReason <-> HCIErrorCode mapping, while exposing HCIErrorCode in the front API only as we might move to HCI at one point.
Diffstat (limited to 'src/direct_bt/HCIComm.cpp')
-rw-r--r--src/direct_bt/HCIComm.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/direct_bt/HCIComm.cpp b/src/direct_bt/HCIComm.cpp
index 0a2b2618..a76ac2fe 100644
--- a/src/direct_bt/HCIComm.cpp
+++ b/src/direct_bt/HCIComm.cpp
@@ -118,7 +118,8 @@ namespace direct_bt {
X(LIMIT_REACHED) \
X(OPERATION_CANCELLED_BY_HOST) \
X(PACKET_TOO_LONG) \
- X(INTERNAL_FAILURE)
+ X(INTERNAL_FAILURE) \
+ X(UNKNOWN)
#define HCI_ERROR_CODE_CASE_TO_STRING(V) case HCIErrorCode::V: return #V;
@@ -506,11 +507,12 @@ done:
return HCIErrorCode::SUCCESS;
}
-bool HCIComm::disconnect(const uint16_t le_conn_handle, const uint8_t reason)
+bool HCIComm::disconnect(const uint16_t le_conn_handle, const HCIErrorCode reason)
{
/** BT Core Spec v5.2: Vol 4, Part E HCI: 7.1.6 Disconnect command */
const std::lock_guard<std::recursive_mutex> lock(mtx); // RAII-style acquire and relinquish via destructor
- DBG_PRINT("hci_disconnect: handle 0x%x, reason 0x%x", le_conn_handle, reason);
+ DBG_PRINT("hci_disconnect: handle 0x%x, reason 0x%x (%s)",
+ le_conn_handle, static_cast<uint8_t>(reason), getHCIErrorCodeString(reason).c_str());
if( 0 > _dd ) {
return true;
}
@@ -522,7 +524,7 @@ bool HCIComm::disconnect(const uint16_t le_conn_handle, const uint8_t reason)
bzero(&cp, sizeof(cp));
cp.handle = le_conn_handle;
- cp.reason = reason;
+ cp.reason = static_cast<uint8_t>(reason);
HCIErrorCode res = send_req( hci_opcode_pack(OGF_LINK_CTL, HCI_OP_DISCONNECT), &cp, sizeof(cp),
HCI_EV_DISCONN_COMPLETE, &rp, sizeof(rp) );