diff --git a/srsue/hdr/upper/rrc.h b/srsue/hdr/upper/rrc.h index 3e2fb70dd..0e123e988 100644 --- a/srsue/hdr/upper/rrc.h +++ b/srsue/hdr/upper/rrc.h @@ -127,6 +127,8 @@ private: // RRC constants and timers srslte::mac_interface_timers *mac_timers; + uint32_t sync_reset_cnt; + const static uint32_t SYNC_RESET_TIMEOUT = 10; uint32_t n310_cnt, N310; uint32_t n311_cnt, N311; uint32_t t301, t310, t311; diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 10373dcf2..7b4bef710 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -48,6 +48,9 @@ rrc::rrc() :state(RRC_STATE_IDLE) ,drb_up(false) { + sync_reset_cnt = 0; + n310_cnt = 0; + n311_cnt = 0; } static void liblte_rrc_handler(void *ctx, char *str) { @@ -489,13 +492,17 @@ void rrc::earfcn_end() { // Detection of physical layer problems (5.3.11.1) void rrc::out_of_sync() { + // attempt resync + sync_reset_cnt++; + if (sync_reset_cnt >= SYNC_RESET_TIMEOUT) { + rrc_log->info("Detected %d out-of-sync from PHY. Resynchronizing PHY.\n", sync_reset_cnt); + phy->sync_reset(); + sync_reset_cnt = 0; + } current_cell->in_sync = false; if (!mac_timers->timer_get(t311)->is_running() && !mac_timers->timer_get(t310)->is_running()) { n310_cnt++; if (n310_cnt == N310) { - // attempt resync - //phy->sync_reset(); - mac_timers->timer_get(t310)->reset(); mac_timers->timer_get(t310)->run(); n310_cnt = 0;