diff --git a/srsue/hdr/phy/phch_common.h b/srsue/hdr/phy/phch_common.h index 04102fded..851fc3581 100644 --- a/srsue/hdr/phy/phch_common.h +++ b/srsue/hdr/phy/phch_common.h @@ -47,7 +47,8 @@ namespace srsue { /* Common variables used by all phy workers */ phy_interface_rrc::phy_cfg_t *config; - phy_args_t *args; + phy_args_t *args; + rrc_interface_phy *rrc; mac_interface_phy *mac; srslte_ue_ul_t ue_ul; @@ -68,7 +69,8 @@ namespace srsue { void init(phy_interface_rrc::phy_cfg_t *config, phy_args_t *args, srslte::log *_log, - srslte::radio *_radio, + srslte::radio *_radio, + rrc_interface_phy *rrc, mac_interface_phy *_mac); /* For RNTI searches, -1 means now or forever */ diff --git a/srsue/src/phy/phch_common.cc b/srsue/src/phy/phch_common.cc index c65ec7c77..1eb0be420 100644 --- a/srsue/src/phy/phch_common.cc +++ b/srsue/src/phy/phch_common.cc @@ -74,10 +74,11 @@ phch_common::phch_common(uint32_t max_mutex_) : tx_mutex(max_mutex_) sync_metrics_count = 0; } -void phch_common::init(phy_interface_rrc::phy_cfg_t *_config, phy_args_t *_args, srslte::log *_log, srslte::radio *_radio, mac_interface_phy *_mac) +void phch_common::init(phy_interface_rrc::phy_cfg_t *_config, phy_args_t *_args, srslte::log *_log, srslte::radio *_radio, rrc_interface_phy *_rrc, mac_interface_phy *_mac) { log_h = _log; - radio_h = _radio; + radio_h = _radio; + rrc = _rrc; mac = _mac; config = _config; args = _args; diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index eac26d9ec..630de4518 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -454,7 +454,7 @@ void phch_recv::reset_sync() { wait_radio_reset(); - Info("SYNC: Resetting sync\n"); + Warning("SYNC: Resetting sync, cell_search_in_progress=%s\n", cell_search_in_progress?"yes":"no"); srslte_ue_sync_reset(&ue_mib_sync.ue_sync); srslte_ue_sync_reset(&ue_sync); resync_sfn(); @@ -718,11 +718,6 @@ void phch_recv::run_thread() { worker_com->cur_radio_power = SRSLTE_MIN(SRSLTE_PC_MAX, worker_com->pathloss+worker_com->p0_preamble); } workers_pool->start_worker(worker); - // Notify RRC in-sync every 1 frame - if ((tti % 10) == 0) { - rrc->in_sync(); - log_h->debug("SYNC: Sending in-sync to RRC\n"); - } break; case 0: log_h->error("SYNC: Sync error. Sending out-of-sync to RRC\n"); diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index b4b1169ed..8e53d9ca0 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -219,11 +219,14 @@ void phch_worker::work_imp() bzero(&ul_action, sizeof(mac_interface_phy::tb_action_ul_t)); /* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */ - if (extract_fft_and_pdcch_llr()) { - - + bool chest_ok = extract_fft_and_pdcch_llr(); + + bool snr_th_ok = 10*log10(srslte_chest_dl_get_snr(&ue_dl.chest))>1.0; + + if (chest_ok && snr_th_ok) { + /***** Downlink Processing *******/ - + /* PDCCH DL + PDSCH */ dl_grant_available = decode_pdcch_dl(&dl_mac_grant); if(dl_grant_available) { @@ -360,6 +363,17 @@ void phch_worker::work_imp() } update_measurements(); + + if (chest_ok) { + if (snr_th_ok) { + phy->rrc->in_sync(); + log_h->debug("SYNC: Sending in-sync to RRC\n"); + } else { + phy->rrc->out_of_sync(); + log_h->debug("SNR=%.1f dB under threshold. Sending out-of-sync to RRC\n", + 10*log10(srslte_chest_dl_get_snr(&ue_dl.chest))); + } + } /* Tell the plotting thread to draw the plots */ #ifdef ENABLE_GUI diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 44b548c4e..e74107661 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -129,7 +129,7 @@ bool phy::init(srslte::radio_multi* radio_handler, mac_interface_phy *mac, rrc_i void phy::run_thread() { prach_buffer.init(&config.common.prach_cnfg, SRSLTE_MAX_PRB, args, log_h); - workers_common.init(&config, args, (srslte::log*) log_vec[0], radio_handler, mac); + workers_common.init(&config, args, (srslte::log*) log_vec[0], radio_handler, rrc, mac); // Add workers to workers pool and start threads for (uint32_t i=0;itimer_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; @@ -656,8 +659,10 @@ void rrc::send_con_restablish_request() { mac_timers->timer_get(t311)->reset(); mac_timers->timer_get(t311)->run(); + phy->reset(); set_phy_default(); mac->reset(); + set_mac_default(); // FIXME: Cell selection should be different??