diff --git a/pc_firm/dr_adc121s051/dr_adc121s051.c b/pc_firm/dr_adc121s051/dr_adc121s051.c index cc6a58d..d59c444 100644 --- a/pc_firm/dr_adc121s051/dr_adc121s051.c +++ b/pc_firm/dr_adc121s051/dr_adc121s051.c @@ -1388,11 +1388,17 @@ maa_async_state_t maa_async_get_state(void) return g_maa_ctx.state; } +/*============================================================================== + * 비동기 측정 상태 IDLE로 초기화 - BLE 연결이 끊어지는 경우 먹통 현상 방지 + *============================================================================*/ void maa_async_abort(void) { - if (g_maa_ctx.state != MAA_ASYNC_IDLE) { + if (g_maa_ctx.state != MAA_ASYNC_IDLE) + { ADC_LOG("maa_async_abort: aborting from state %d", g_maa_ctx.state); - g_maa_ctx.state = MAA_ASYNC_IDLE; + g_maa_ctx.state = MAA_ASYNC_IDLE; // 측정 상태 IDLE로 초기화 + g_maa_ctx.on_complete_cb = NULL; // abort 후 콜백 호출 방지 + dr_piezo_power_off(); // 전체 측정 중간에 끊기는 경우 Piezo TX/RX Sleep } } diff --git a/project/ble_peripheral/ble_app_bladder_patch/main.c b/project/ble_peripheral/ble_app_bladder_patch/main.c index 52a17d3..968d250 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/main.c +++ b/project/ble_peripheral/ble_app_bladder_patch/main.c @@ -1032,11 +1032,14 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) switch (p_ble_evt->header.evt_id) { + /* BLE 연결이 끊어지는 경우 */ case BLE_GAP_EVT_DISCONNECTED: DBG_PRINTF("[BLE] Disconnected\r\n"); ble_connection_st = 0; m_conn_handle = BLE_CONN_HANDLE_INVALID; m_tx_in_progress = false; + + maa_async_abort(); // 비동기 측정 상태에 의한 먹통 현상 방지 if (device_status == true) {