diff --git a/project/ble_peripheral/ble_app_bladder_patch/main.c b/project/ble_peripheral/ble_app_bladder_patch/main.c index a5817a6..0f8846e 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/main.c +++ b/project/ble_peripheral/ble_app_bladder_patch/main.c @@ -573,6 +573,11 @@ static void nus_data_handler(ble_nus_evt_t * p_evt) { if (p_evt->type == BLE_NUS_EVT_RX_DATA) { + if (!ble_connection_st) + { + return; /* Reject command before security is established */ + } + cmd_type_t = CMD_BLE; ble_got_new_data = true; @@ -1048,11 +1053,14 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) break; case BLE_GAP_EVT_CONNECTED: - DBG_PRINTF("[BLE] Connected\r\n"); + DBG_PRINTF("[BLE] GAP Connected\r\n"); #if FEATURE_SECURE_CONNECTION - ble_connection_st = 1; - battery_timer_start(); + if (BLE_DEV_MODE) + { + ble_connection_st = 1; + battery_timer_start(); + } #endif m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;