From 58106006b9f23edbe8830f2c97344f4abe0632dc Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 1 Feb 2019 16:42:13 +0700 Subject: [PATCH] clean up --- .../Bluefruit52Lib/src/BLEConnection.cpp | 2 ++ libraries/Bluefruit52Lib/src/bluefruit.cpp | 23 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/libraries/Bluefruit52Lib/src/BLEConnection.cpp b/libraries/Bluefruit52Lib/src/BLEConnection.cpp index ccbc6a59..8496562c 100644 --- a/libraries/Bluefruit52Lib/src/BLEConnection.cpp +++ b/libraries/Bluefruit52Lib/src/BLEConnection.cpp @@ -254,6 +254,7 @@ void BLEConnection::_eventHandler(ble_evt_t* evt) //--------------------------------------------------------------------+ /* First-time Pairing + * Connect -> SEC_PARAMS_REQUEST -> CONN_SEC_UPDATE -> AUTH_STATUS * 1. Either we or peer initiate the process * 2. Peer ask for Secure Parameter ( I/O Caps ) BLE_GAP_EVT_SEC_PARAMS_REQUEST * 3. Pair Key exchange ( PIN code) @@ -261,6 +262,7 @@ void BLEConnection::_eventHandler(ble_evt_t* evt) * 5. Long term Keys exchanged BLE_GAP_EVT_AUTH_STATUS * * Reconnect using bonded key + * Connect -> SEC_INFO_REQUEST -> CONN_SEC_UPDATE * 1. Either we or peer initiate the process * 2. Peer ask for Secure Info ( bond keys ) BLE_GAP_EVT_SEC_INFO_REQUEST * 3. Connection is secured BLE_GAP_EVT_CONN_SEC_UPDATE diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 8c357e3b..3c4d453a 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -924,12 +924,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt) * or a few special one * - Connected event * - Advertising timeout (could be connected and advertising at the same time) - * - * Pairing procedure - * - Connect -> SEC_PARAMS_REQUEST -> CONN_SEC_UPDATE -> AUTH_STATUS - * - * Reconnect to a paired device - * - Connect -> SEC_INFO_REQUEST -> CONN_SEC_UPDATE */ if ( conn_hdl == _conn_hdl || evt->header.evt_id == BLE_GAP_EVT_CONNECTED) @@ -955,18 +949,17 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt) } } - // Central Event Handler - if (_central_count) + // Periph event handler, skip if it is central connection + if ( _prph_count && !(conn && (conn->getRole() == BLE_GAP_ROLE_CENTRAL)) ) { - // Skip if not central connection - if (conn_hdl != _conn_hdl || - conn_hdl == BLE_CONN_HANDLE_INVALID) - { - Central._eventHandler(evt); - } + Periph._eventHandler(evt); } - Periph._eventHandler(evt); + // Central Event Handler, skip if it is peripheral connection + if ( _central_count && !(conn && (conn->getRole() == BLE_GAP_ROLE_PERIPH)) ) + { + Central._eventHandler(evt); + } // Discovery Event Handler if ( Discovery.begun() ) Discovery._eventHandler(evt);