dev 모드 BLE 연결 수정
- dev 모드인 경우 보안 x
This commit is contained in:
@@ -95,6 +95,14 @@ void ble_security_quick_pm_handler(pm_evt_t const *p_evt)
|
||||
{
|
||||
ret_code_t err_code;
|
||||
|
||||
// DEV 모드: 보안 실패 이벤트는 SDK 핸들러에 전달하지 않음 (disconnect 방지)
|
||||
if (m_state.dev_mode && p_evt->evt_id == PM_EVT_CONN_SEC_FAILED) {
|
||||
DBG_PRINTF("Security failed: error=%d\r\n",
|
||||
p_evt->params.conn_sec_failed.error);
|
||||
DBG_PRINTF("DEV: Ignoring sec failure, keeping connection\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Call standard handlers (required)
|
||||
pm_handler_on_pm_evt(p_evt);
|
||||
pm_handler_flash_clean(p_evt);
|
||||
@@ -113,6 +121,12 @@ void ble_security_quick_pm_handler(pm_evt_t const *p_evt)
|
||||
DBG_PRINTF("Security failed: error=%d\r\n",
|
||||
p_evt->params.conn_sec_failed.error);
|
||||
|
||||
if (m_state.dev_mode) {
|
||||
// DEV 모드: 보안 실패 무시 — 연결 유지
|
||||
DBG_PRINTF("DEV: Ignoring sec failure, keeping connection\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (p_evt->params.conn_sec_failed.error == PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING) {
|
||||
// Key missing: 재페어링 시도, 실패 시 disconnect로 폴백
|
||||
err_code = pm_conn_secure(p_evt->conn_handle, true);
|
||||
|
||||
@@ -1016,7 +1016,9 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
|
||||
#endif
|
||||
|
||||
#if FEATURE_SECURE_CONNECTION
|
||||
pm_handler_secure_on_connection(p_ble_evt);
|
||||
if (!ble_security_is_dev_mode()) {
|
||||
pm_handler_secure_on_connection(p_ble_evt);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
@@ -1102,6 +1104,14 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
|
||||
BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
|
||||
NULL, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
#else
|
||||
if (ble_security_is_dev_mode()) {
|
||||
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
|
||||
BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
|
||||
NULL, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
DBG_PRINTF("DEV: Rejected security request\r\n");
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user