diff --git a/smtc_rac_lib/radio_planner/src/radio_planner.c b/smtc_rac_lib/radio_planner/src/radio_planner.c index 2c44c68..a4c99d6 100644 --- a/smtc_rac_lib/radio_planner/src/radio_planner.c +++ b/smtc_rac_lib/radio_planner/src/radio_planner.c @@ -444,8 +444,15 @@ rp_stats_t rp_get_stats( const radio_planner_t* rp ) void rp_callback( radio_planner_t* rp ) { + // UNLOCK_RADIO_ACCESS must be exempt like LOCK_RADIO_ACCESS: a lock task + // held open longer than the failsafe window (e.g. continuous RX under the + // raw RAC) keeps its original start_time_ms, and unlock_radio_access + // retypes the still-RUNNING task to UNLOCK before the engine processes + // it — the very next rp_callback would evaluate the failsafe against the + // stale start time and panic at the moment the client releases the lock. if( ( rp->tasks[rp->radio_task_id].state == RP_TASK_STATE_RUNNING ) && ( rp->tasks[rp->radio_task_id].type != RP_TASK_TYPE_LOCK_RADIO_ACCESS ) && + ( rp->tasks[rp->radio_task_id].type != RP_TASK_TYPE_UNLOCK_RADIO_ACCESS ) && ( rp->disable_failsafe != RP_DISABLE_FAILSAFE_KEY ) && ( ( int32_t ) ( rp->tasks[rp->radio_task_id].start_time_ms + 128000 - smtc_modem_hal_get_time_in_ms( ) ) < 0 ) ) {