aboutsummaryrefslogtreecommitdiffstats
path: root/api/direct_bt/DBTManager.hpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-05-31 05:21:54 +0200
committerSven Gothel <[email protected]>2020-05-31 05:21:54 +0200
commit7850f58d81c2262cc52baa72cf05de7e24a73588 (patch)
treef318a9ccab0cb269a7c57c14e177152b8af94b26 /api/direct_bt/DBTManager.hpp
parentdc43013a6df42ca425386520cbc40065ba1c3a43 (diff)
Differentiate disconnect w/ IO-Error, i.e. DBTDevice shall not issue HCI nor Mgmt disconnect (device gone)
It has shown that the extreme 6-9s delay in forced disconnect (device shutdown) is caused by the HCI and Mgmt disconnect command. Both fail, always. Hence, in case of a GATT send error or short read-reply timeout (ringbuffer.getBlocking(500ms)) we can cleanup the device w/o explicit disconnect command. +++ The usual disconnect signal from a device forced shutdown is as follows: L2CAP send or GATT read-reply -> Device -> HCI(1) + Mgmt(2) (1) HCI disconnect skipped if IO-Error (2) Mgmt disconnect skipped if IO-Error, but sends DISCONNECT event +++ Mgmt and GATTHandler also differentiate timeouts, lenghthly 3s for the ringbuffer read w/o any impact and 1s (mgmt) or 500ms (gatt) for command replies on the user thread. This leads to fast DISCONNECT events for the user and actual device cleanup. Subsequent connection works w/o issues. If using HCI connect via discovery (not whitelist), the turnaround time from forced disconnect to next connect is below 1s. However, using whitelist, the subsequent connect after the forced disconnect consumes 'a few seconds' and hence is seemingly not suitable for a responsive system (???). The latter is true with or without Mgmt disconnect attempts! Misc: - L2CAPComm disconnect: Show potention pthread_kill error - HCIComm send_req/send: Refine ERR_PRINT, remove unsused case HCI_EV_REMOTE_NAME
Diffstat (limited to 'api/direct_bt/DBTManager.hpp')
-rw-r--r--api/direct_bt/DBTManager.hpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp
index 8529cf85..53402ab4 100644
--- a/api/direct_bt/DBTManager.hpp
+++ b/api/direct_bt/DBTManager.hpp
@@ -106,6 +106,8 @@ namespace direct_bt {
/** 3s poll timeout for mgmt reader thread */
MGMT_READER_THREAD_POLL_TIMEOUT = 3000,
+ /** 1s timeout for mgmt command replies */
+ MGMT_COMMAND_REPLY_TIMEOUT = 1000,
MGMTEVT_RING_CAPACITY = 256
};
@@ -280,7 +282,9 @@ namespace direct_bt {
const uint16_t min_ce_length=0x0001, const uint16_t max_ce_length=0x0001,
const uint8_t initiator_filter=0);
- bool disconnect(const int dev_id, const EUI48 &peer_bdaddr, const BDAddressType peer_mac_type, const uint8_t reason=0);
+ bool disconnect(const bool ioErrorCause,
+ const int dev_id, const EUI48 &peer_bdaddr, const BDAddressType peer_mac_type,
+ const uint8_t reason=0x13 /* HCIErrorCode::REMOTE_USER_TERMINATED_CONNECTION */);
std::shared_ptr<ConnectionInfo> getConnectionInfo(const int dev_id, const EUI48 &address, const BDAddressType address_type);
std::shared_ptr<NameAndShortName> setLocalName(const int dev_id, const std::string & name, const std::string & short_name);