From 98605be5b8cf93bf6e54e8f84dab960dd8879f9a Mon Sep 17 00:00:00 2001 From: dxl <64101226@qq.com> Date: Thu, 14 Sep 2023 10:52:05 +0800 Subject: [PATCH] Fixed some bugs caused by closing pairing. --- firmware/application/src/ble_main.c | 6 +----- .../components/ble/peer_manager/peer_manager.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/firmware/application/src/ble_main.c b/firmware/application/src/ble_main.c index 577a93eb..464caaa5 100644 --- a/firmware/application/src/ble_main.c +++ b/firmware/application/src/ble_main.c @@ -783,9 +783,5 @@ void ble_slave_init(void) { services_init(); // Initialization of service characteristics advertising_init(); // Broadcast parameter initialization conn_params_init(); // Connection parameter initialization - - // Pairing enable? - if (settings_get_ble_pairing_enable_first_load()) { - peer_manager_init(); // Peer manager Initialization - } + peer_manager_init(); // Peer manager Initialization } diff --git a/firmware/nrf52_sdk/components/ble/peer_manager/peer_manager.c b/firmware/nrf52_sdk/components/ble/peer_manager/peer_manager.c index c832e629..327da57f 100644 --- a/firmware/nrf52_sdk/components/ble/peer_manager/peer_manager.c +++ b/firmware/nrf52_sdk/components/ble/peer_manager/peer_manager.c @@ -52,6 +52,7 @@ #include "ble_conn_state.h" #include "peer_manager_internal.h" #include "nrf_sdh_ble.h" +#include "settings.h" #define NRF_LOG_MODULE_NAME peer_manager #if PM_LOG_ENABLED @@ -348,9 +349,13 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) return; } - im_ble_evt_handler(p_ble_evt); - sm_ble_evt_handler(p_ble_evt); - gcm_ble_evt_handler(p_ble_evt); + if (settings_get_ble_pairing_enable_first_load()) { + im_ble_evt_handler(p_ble_evt); + sm_ble_evt_handler(p_ble_evt); + gcm_ble_evt_handler(p_ble_evt); + } else { + NRF_LOG_INFO("Pairing is disable, ignore ble event for peer manager."); + } } NRF_SDH_BLE_OBSERVER(m_ble_evt_observer, PM_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);