Reduced time to sync to cell

master
Ismael Gomez 7 years ago
parent 31cdd734ee
commit f1bacd009a

@ -227,7 +227,7 @@ int rf_uhd_start_rx_stream(void *h)
.stream_now = false
};
uhd_usrp_get_time_now(handler->usrp, 0, &stream_cmd.time_spec_full_secs, &stream_cmd.time_spec_frac_secs);
stream_cmd.time_spec_frac_secs += 0.5;
stream_cmd.time_spec_frac_secs += 0.1;
if (stream_cmd.time_spec_frac_secs > 1) {
stream_cmd.time_spec_frac_secs -= 1;
stream_cmd.time_spec_full_secs += 1;

@ -149,7 +149,7 @@ private:
srslte_ue_dl_t ue_dl_measure;
const static int RSRP_MEASURE_NOF_FRAMES = 20;
const static int RSRP_MEASURE_NOF_FRAMES = 5;
int cell_sync_sfn();
int cell_meas_rsrp();

@ -57,6 +57,7 @@
namespace srsue {
//#define LOG_STDOUT
/*******************************************************************************
Main UE class
@ -99,8 +100,11 @@ private:
srslte::gw gw;
srsue::usim usim;
srslte::logger_file logger;
//srslte::logger_stdout logger;
#ifdef LOG_STDOUT
srslte::logger_stdout logger;
#else
srslte::logger_file logger;
#endif
srslte::log_filter rf_log;
srslte::log_filter phy_log;
srslte::log_filter mac_log;

@ -100,14 +100,16 @@ private:
uint8_t transaction_id;
bool drb_up;
// timeouts in ms
uint32_t connecting_timeout;
static const uint32_t RRC_CONNECTING_TIMEOUT = 100;
static const uint32_t RRC_CONNECTING_TIMEOUT = 1000;
uint32_t plmn_select_timeout;
static const uint32_t RRC_PLMN_SELECT_TIMEOUT = 1000;
static const uint32_t RRC_PLMN_SELECT_TIMEOUT = 10000;
uint32_t select_cell_timeout;
static const uint32_t RRC_SELECT_CELL_TIMEOUT = 500;
static const uint32_t RRC_SELECT_CELL_TIMEOUT = 2000;
uint8_t k_rrc_enc[32];
uint8_t k_rrc_int[32];

@ -93,13 +93,13 @@ void phch_recv:: init(srslte::radio_multi *_radio_handler, mac_interface_phy *_
}
if (srslte_ue_cellsearch_init_multi(&cs, SRSLTE_DEFAULT_MAX_FRAMES_PSS, radio_recv_wrapper_cs, nof_rx_antennas,
if (srslte_ue_cellsearch_init_multi(&cs, 5, radio_recv_wrapper_cs, nof_rx_antennas,
radio_h)) {
Error("Initiating UE cell search\n");
return;
}
srslte_ue_cellsearch_set_nof_valid_frames(&cs, SRSLTE_DEFAULT_NOF_VALID_PSS_FRAMES);
srslte_ue_cellsearch_set_nof_valid_frames(&cs, 2);
// Set options defined in expert section
set_ue_sync_opts(&cs.ue_sync);
@ -211,6 +211,8 @@ bool phch_recv::set_cell() {
return false;
}
worker_com->set_cell(cell);
for (uint32_t i = 0; i < workers_pool->get_nof_workers(); i++) {
if (!((phch_worker *) workers_pool->get_worker(i))->set_cell(cell)) {
Error("Setting cell: initiating PHCH worker\n");
@ -235,11 +237,9 @@ bool phch_recv::cell_search(int force_N_id_2) {
bzero(found_cells, 3 * sizeof(srslte_ue_cellsearch_result_t));
if (srate_mode != SRATE_FIND) {
printf("set rx rate\n");
srate_mode = SRATE_FIND;
radio_h->set_rx_srate(1.92e6);
}
printf("start rx\n");
radio_h->start_rx();
/* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */
@ -247,6 +247,7 @@ bool phch_recv::cell_search(int force_N_id_2) {
int ret = SRSLTE_ERROR;
Info("Searching for cell...\n");
printf("."); fflush(stdout);
if (force_N_id_2 >= 0 && force_N_id_2 < 3) {
ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]);
@ -257,22 +258,24 @@ bool phch_recv::cell_search(int force_N_id_2) {
last_gain = srslte_agc_get_gain(&cs.ue_sync.agc);
printf("stop rx\n");
radio_h->stop_rx();
if (ret < 0) {
radio_h->stop_rx();
Error("Error decoding MIB: Error searching PSS\n");
return false;
} else if (ret == 0) {
radio_h->stop_rx();
Info("Could not find any cell in this frequency\n");
return false;
}
// Save result
cell.id = found_cells[max_peak_cell].cell_id;
cell.cp = found_cells[max_peak_cell].cp;
cellsearch_cfo = found_cells[max_peak_cell].cfo;
printf("\n");
Info("SYNC: PSS/SSS detected: PCI=%d, CFO=%.1f KHz, CP=%s\n",
cell.id, cellsearch_cfo/1000, srslte_cp_string(cell.cp));
if (srslte_ue_mib_sync_set_cell(&ue_mib_sync, cell.id, cell.cp)) {
Error("Setting UE MIB cell\n");
return false;
@ -290,7 +293,6 @@ bool phch_recv::cell_search(int force_N_id_2) {
/* Find and decode MIB */
int sfn_offset;
radio_h->start_rx();
ret = srslte_ue_mib_sync_decode(&ue_mib_sync,
40,
bch_payload, &cell.nof_ports, &sfn_offset);
@ -301,14 +303,18 @@ bool phch_recv::cell_search(int force_N_id_2) {
srslte_ue_sync_reset(&ue_sync);
srslte_ue_sync_set_cfo(&ue_sync, cellsearch_cfo);
Info("Setting ue_sync cfo=%f KHz\n", cellsearch_cfo/1000);
if (ret == 1) {
srslte_pbch_mib_unpack(bch_payload, &cell, NULL);
worker_com->set_cell(cell);
fprintf(stdout, "Found Cell: PCI=%d, PRB=%d, Ports=%d, CFO=%.1f KHz\n",
cell.id, cell.nof_prb, cell.nof_ports, cellsearch_cfo/1000);
Info("SYNC: MIB Decoded: PCI=%d, PRB=%d, Ports=%d, CFO=%.1f KHz\n",
cell.id, cell.nof_prb, cell.nof_ports, cellsearch_cfo/1000);
return true;
} else {
Warning("Error decoding MIB: Error decoding PBCH\n");
Warning("Found PSS but could not decode PBCH\n");
return false;
}
}
@ -329,7 +335,7 @@ int phch_recv::cell_sync_sfn(void) {
if (ret == 1) {
if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
int sfn_offset = 0;
Info("SYNC: Decoding MIB...\n");
Info("SYNC: Trying to decode MIB...\n");
int n = srslte_ue_mib_decode(&ue_mib, sf_buffer[0], bch_payload, NULL, &sfn_offset);
if (n < 0) {
Error("SYNC: Error decoding MIB while synchronising SFN");
@ -388,6 +394,7 @@ void phch_recv::resync_sfn() {
radio_h->stop_rx();
radio_h->start_rx();
srslte_ue_mib_reset(&ue_mib);
Info("SYNC: Starting SFN synchronization\n");
sync_sfn_cnt = 0;
phy_state = CELL_SELECT;
}
@ -397,7 +404,7 @@ void phch_recv::set_earfcn(std::vector<uint32_t> earfcn) {
}
bool phch_recv::stop_sync() {
Info("SYNC: Going to IDLE\n");
Info("SYNC: Going to IDLE\n");
phy_state = IDLE;
int cnt=0;
while(!is_in_idle && cnt<100) {
@ -409,7 +416,6 @@ bool phch_recv::stop_sync() {
void phch_recv::cell_search_inc()
{
printf("cell search inc\n");
cur_earfcn_index++;
Info("SYNC: Cell Search idx %d/%d\n", cur_earfcn_index, earfcn.size());
if (cur_earfcn_index >= 0) {
@ -500,7 +506,6 @@ bool phch_recv::set_frequency()
log_h->console("Searching cell in DL EARFCN=%d, f_dl=%.1f MHz, f_ul=%.1f MHz\n",
current_earfcn, dl_freq / 1e6, ul_freq / 1e6);
printf("set frequency\n");
radio_h->set_rx_freq(dl_freq);
radio_h->set_tx_freq(ul_freq);
ul_dl_factor = ul_freq / dl_freq;
@ -518,12 +523,13 @@ void phch_recv::set_sampling_rate()
{
float srate = (float) srslte_sampling_freq_hz(cell.nof_prb);
Info("Setting sampling rate %.1f MHz\n", srate/1000000);
if (30720 % ((int) srate / 1000) == 0) {
radio_h->set_master_clock_rate(30.72e6);
} else {
radio_h->set_master_clock_rate(23.04e6);
}
srate_mode = SRATE_CAMP;
radio_h->set_rx_srate(srate);
radio_h->set_tx_srate(srate);
@ -554,9 +560,7 @@ void phch_recv::run_thread() {
resync_sfn();
}
Info("SYNC: Cell found. Synchronizing...\n");
} else {
printf("no trobat in progress=%d\n", cell_search_in_progress);
if (cell_search_in_progress) {
cell_search_inc();
}
@ -636,7 +640,7 @@ void phch_recv::run_thread() {
srslte_timestamp_add(&tx_time, 0, 4e-3 - time_adv_sec);
worker->set_tx_time(tx_time);
Debug("Settting TTI=%d, tx_mutex=%d to worker %d\n", tti, tx_mutex_cnt, worker->get_id());
Debug("Setting TTI=%d, tx_mutex=%d to worker %d\n", tti, tx_mutex_cnt, worker->get_id());
worker->set_tti(tti, tx_mutex_cnt);
tx_mutex_cnt = (tx_mutex_cnt+1) % nof_tx_mutex;

@ -52,7 +52,9 @@ bool ue::init(all_args_t *args_)
{
args = args_;
logger.init(args->log.filename);
#ifndef LOG_STDOUT
logger.init(args->log.filename);
#endif
rf_log.init("RF ", &logger);
phy_log.init("PHY ", &logger, true);
mac_log.init("MAC ", &logger, true);
@ -64,7 +66,9 @@ bool ue::init(all_args_t *args_)
usim_log.init("USIM", &logger);
// Init logs
#ifndef LOG_STDOUT
logger.log("\n\n");
#endif
rf_log.set_level(srslte::LOG_LEVEL_INFO);
phy_log.set_level(level(args->log.phy_level));
mac_log.set_level(level(args->log.mac_level));

@ -249,14 +249,9 @@ void rrc::cell_found(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
si_acquire_state = SI_ACQUIRE_SIB1;
rrc_log->info("Found Cell: PCI=%d, PRB=%d, Ports=%d, EARFCN=%d, RSRP=%.1f dBm\n",
rrc_log->info("New Cell: PCI=%d, PRB=%d, Ports=%d, EARFCN=%d, RSRP=%.1f dBm\n",
cell.phy_cell.id, cell.phy_cell.nof_prb, cell.phy_cell.nof_ports,
cell.earfcn, cell.rsrp);
rrc_log->console("Found Cell: PCI=%d, PRB=%d, Ports=%d, EARFCN=%d, RSRP=%.1f dBm\n",
cell.phy_cell.id, cell.phy_cell.nof_prb, cell.phy_cell.nof_ports,
cell.earfcn, cell.rsrp);
}
// Detection of physical layer problems (5.3.11.1)
@ -426,7 +421,7 @@ void rrc::run_thread() {
switch(state) {
case RRC_STATE_IDLE:
if (nas->is_attached()) {
usleep(100000);
usleep(10000);
rrc_log->info("RRC IDLE: NAS is attached, re-selecting cell...\n");
plmn_select(selected_plmn_id);
}
@ -436,7 +431,7 @@ void rrc::run_thread() {
if (plmn_select_timeout >= RRC_PLMN_SELECT_TIMEOUT) {
rrc_log->info("RRC PLMN Search: timeout expired. Searching again\n");
sleep(1);
rrc_log->console("RRC PLMN Search: timeout expired. Searching again\n");
rrc_log->console("\nRRC PLMN Search: timeout expired. Searching again\n");
plmn_select_timeout = 0;
phy->cell_search_start();
}
@ -481,7 +476,7 @@ void rrc::run_thread() {
default:
break;
}
usleep(10000);
usleep(1000);
}
}

Loading…
Cancel
Save