@ -245,6 +245,7 @@ nas::nas(srslte::task_sched_handle task_sched_) :
t3411 ( task_sched_ . get_unique_timer ( ) ) ,
t3421 ( task_sched_ . get_unique_timer ( ) ) ,
reattach_timer ( task_sched_ . get_unique_timer ( ) ) ,
airplane_mode_sim_timer ( task_sched_ . get_unique_timer ( ) ) ,
nas_log { " NAS " }
{ }
@ -302,7 +303,10 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_
t3421 . set ( t3421_duration_ms , [ this ] ( uint32_t tid ) { timer_expired ( tid ) ; } ) ;
reattach_timer . set ( reattach_timer_duration_ms , [ this ] ( uint32_t tid ) { timer_expired ( tid ) ; } ) ;
handle_airplane_mode_sim ( ) ;
if ( cfg . sim . airplane_t_on_ms > 0 ) {
airplane_mode_sim_timer . set ( cfg . sim . airplane_t_on_ms , [ this ] ( uint32_t tid ) { timer_expired ( tid ) ; } ) ;
airplane_mode_sim_timer . run ( ) ;
}
running = true ;
}
@ -372,6 +376,26 @@ void nas::timer_expired(uint32_t timeout_id)
} else if ( timeout_id = = reattach_timer . id ( ) ) {
nas_log - > info ( " Reattach timer expired: trying to attach again \n " ) ;
start_attach_proc ( nullptr , srslte : : establishment_cause_t : : mo_sig ) ;
} else if ( timeout_id = = airplane_mode_sim_timer . id ( ) ) {
if ( airplane_mode_state = = DISABLED ) {
// Enabling air-plane mode
send_detach_request ( true ) ;
airplane_mode_state = ENABLED ;
if ( cfg . sim . airplane_t_on_ms > 0 ) {
airplane_mode_sim_timer . set ( cfg . sim . airplane_t_on_ms , [ this ] ( uint32_t tid ) { timer_expired ( tid ) ; } ) ;
airplane_mode_sim_timer . run ( ) ;
}
} else if ( airplane_mode_state = = ENABLED ) {
// Disabling airplane mode again
start_attach_proc ( nullptr , srslte : : establishment_cause_t : : mo_sig ) ;
airplane_mode_state = DISABLED ;
if ( cfg . sim . airplane_t_off_ms > 0 ) {
airplane_mode_sim_timer . set ( cfg . sim . airplane_t_off_ms , [ this ] ( uint32_t tid ) { timer_expired ( tid ) ; } ) ;
airplane_mode_sim_timer . run ( ) ;
}
}
} else {
nas_log - > error ( " Timeout from unknown timer id %d \n " , timeout_id ) ;
}
@ -2488,40 +2512,6 @@ void nas::send_close_ue_test_loop_complete()
ctxt . tx_count + + ;
}
/*
* Handles the airplane mode simulation by triggering a UE switch off / on
* in user - definable time intervals
*/
void nas : : handle_airplane_mode_sim ( )
{
if ( cfg . sim . airplane_t_on_ms > 0 & & airplane_mode_state = = DISABLED ) {
// check if we're already attached, if so, schedule airplane mode command
if ( state = = EMM_STATE_REGISTERED ) {
// NAS is attached
task_sched . defer_callback ( cfg . sim . airplane_t_on_ms , [ & ] ( ) {
// Enabling air-plane mode
send_detach_request ( true ) ;
airplane_mode_state = ENABLED ;
} ) ;
}
} else if ( cfg . sim . airplane_t_off_ms > 0 & & airplane_mode_state = = ENABLED ) {
// check if we are already deregistered, if so, schedule command to turn off airplone mode again
if ( state = = EMM_STATE_DEREGISTERED ) {
// NAS is deregistered
task_sched . defer_callback ( cfg . sim . airplane_t_off_ms , [ & ] ( ) {
// Disabling airplane mode again
start_attach_proc ( nullptr , srslte : : establishment_cause_t : : mo_sig ) ;
airplane_mode_state = DISABLED ;
} ) ;
}
}
// schedule another call
if ( cfg . sim . airplane_t_on_ms > 0 | | cfg . sim . airplane_t_off_ms > 0 ) {
task_sched . defer_callback ( 1000 , [ & ] ( ) { handle_airplane_mode_sim ( ) ; } ) ;
}
}
/*******************************************************************************
* Security context persistence file
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */