BLE 보안 실패 시 자동 재페어링 및 버그 3건 수정

- 앱과 기기 사이 키가 불일치하는 경우 새로운 키 생성 요청(재페어링 허용)
- main.c: PM_EVT_CONN_SEC_CONFIG_REQ 중복 핸들러 제거
- main.c: DEV 모드에서 pm_peers_delete() 이중 호출 방지
- main.c: 활성 연결 중 advertising 재시작 방지(m_conn_handle 체크)
- ble_quick_security: 보안 실패 시 bond 삭제 + 자동 재페어링 시도
- ble_quick_security: allow_repairing = true (항상 재페어링 허용)
This commit is contained in:
jhChun
2026-03-31 14:17:35 +09:00
parent 217d741d31
commit d63a9cfa3c
2 changed files with 18 additions and 13 deletions

View File

@@ -944,19 +944,15 @@ static void pm_evt_handler(pm_evt_t const * p_evt)
DBG_PRINTF("[PM] Sec failed\r\n");
break;
/* 모든 본딩 삭제 완료 → 광고 재시작 */
/* 모든 본딩 삭제 완료 → 활성 연결이 없을 때만 광고 재시작 */
case PM_EVT_PEERS_DELETE_SUCCEEDED:
DBG_PRINTF("[PM] Bonds erased\r\n");
advertising_start(false);
if (m_conn_handle == BLE_CONN_HANDLE_INVALID) {
advertising_start(false);
}
break;
/* 보안 설정 요청 → 재페어링 허용 */
case PM_EVT_CONN_SEC_CONFIG_REQ:
{
pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
}
break;
/* PM_EVT_CONN_SEC_CONFIG_REQ → ble_quick_security에서 처리 */
/* 피어 데이터(본딩 정보) 갱신 성공 → 피어 BLE 주소 저장 */
case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
@@ -1641,7 +1637,8 @@ static void main_s(void * p_context)
battery_timer_start();
#if FEATURE_SECURE_CONNECTION
advertising_start(erase_bonds || bond_data_delete);
/* DEV 모드: ble_security_quick_init()에서 이미 bond 삭제됨 → 중복 방지 */
advertising_start(!ble_security_is_dev_mode() && (erase_bonds || bond_data_delete));
#else
advertising_start();
#endif