fixed naming for ue_sync_nbiot

master
Andre Puschmann 5 years ago
parent 447f71b8c9
commit 8bec22ff11

@ -213,7 +213,7 @@ int main(int argc, char** argv)
srslte_ue_cellsearch_nbiot_set_nof_valid_frames(&cs, cell_detect_config.nof_valid_pss_frames); srslte_ue_cellsearch_nbiot_set_nof_valid_frames(&cs, cell_detect_config.nof_valid_pss_frames);
} }
if (cell_detect_config.init_agc) { if (cell_detect_config.init_agc) {
srslte_nbiot_ue_sync_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, cell_detect_config.init_agc); srslte_ue_sync_nbiot_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, cell_detect_config.init_agc);
} }
INFO("Setting sampling frequency %.2f MHz for NPSS search\n", SRSLTE_CS_SAMP_FREQ / 1000000); INFO("Setting sampling frequency %.2f MHz for NPSS search\n", SRSLTE_CS_SAMP_FREQ / 1000000);

@ -141,7 +141,7 @@ int main(int argc, char** argv)
buff_ptrs[0] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB_NBIOT * 10); buff_ptrs[0] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB_NBIOT * 10);
srslte_nbiot_ue_sync_t ue_sync; srslte_nbiot_ue_sync_t ue_sync;
if (srslte_nbiot_ue_sync_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*)&rf)) { if (srslte_ue_sync_nbiot_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*)&rf)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
@ -151,7 +151,7 @@ int main(int argc, char** argv)
bool start_capture = false; bool start_capture = false;
bool stop_capture = false; bool stop_capture = false;
while ((subframe_count < nof_subframes || nof_subframes == -1) && !stop_capture) { while ((subframe_count < nof_subframes || nof_subframes == -1) && !stop_capture) {
int n = srslte_nbiot_ue_sync_zerocopy_multi(&ue_sync, buff_ptrs); int n = srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error receiving samples\n"); fprintf(stderr, "Error receiving samples\n");
exit(-1); exit(-1);
@ -160,7 +160,7 @@ int main(int argc, char** argv)
if (n == 1) { if (n == 1) {
if (!start_capture) { if (!start_capture) {
if (nof_warmup_subframes <= 0) { if (nof_warmup_subframes <= 0) {
if (srslte_nbiot_ue_sync_get_sfidx(&ue_sync) == 9) { if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) {
printf("Starting capture ..\n"); printf("Starting capture ..\n");
start_capture = true; start_capture = true;
} }
@ -168,16 +168,16 @@ int main(int argc, char** argv)
nof_warmup_subframes--; nof_warmup_subframes--;
} else { } else {
printf("Writing subframe %d (%d/%d) to file (cfo=%6.2f kHz)\n", printf("Writing subframe %d (%d/%d) to file (cfo=%6.2f kHz)\n",
srslte_nbiot_ue_sync_get_sfidx(&ue_sync), srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
subframe_count, subframe_count,
nof_subframes, nof_subframes,
srslte_nbiot_ue_sync_get_cfo(&ue_sync) / 1000); srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000);
srslte_filesink_write(&sink, buff_ptrs[0], SRSLTE_SF_LEN_PRB(nof_prb)); srslte_filesink_write(&sink, buff_ptrs[0], SRSLTE_SF_LEN_PRB(nof_prb));
subframe_count++; subframe_count++;
} }
} }
if (!keep_running) { if (!keep_running) {
if (!start_capture || (start_capture && srslte_nbiot_ue_sync_get_sfidx(&ue_sync) == 9)) { if (!start_capture || (start_capture && srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9)) {
printf("Stopping capture ..\n"); printf("Stopping capture ..\n");
stop_capture = true; stop_capture = true;
} }
@ -186,7 +186,7 @@ int main(int argc, char** argv)
srslte_filesink_free(&sink); srslte_filesink_free(&sink);
srslte_rf_close(&rf); srslte_rf_close(&rf);
srslte_nbiot_ue_sync_free(&ue_sync); srslte_ue_sync_nbiot_free(&ue_sync);
printf("Ok - wrote %d subframes\n", subframe_count); printf("Ok - wrote %d subframes\n", subframe_count);
exit(0); exit(0);

@ -93,73 +93,73 @@ typedef struct SRSLTE_API {
#endif #endif
} srslte_nbiot_ue_sync_t; } srslte_nbiot_ue_sync_t;
SRSLTE_API int srslte_nbiot_ue_sync_init(srslte_nbiot_ue_sync_t* q, SRSLTE_API int srslte_ue_sync_nbiot_init(srslte_nbiot_ue_sync_t* q,
srslte_nbiot_cell_t cell, srslte_nbiot_cell_t cell,
int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*),
void* stream_handler); void* stream_handler);
SRSLTE_API int SRSLTE_API int
srslte_nbiot_ue_sync_init_multi(srslte_nbiot_ue_sync_t* q, srslte_ue_sync_nbiot_init_multi(srslte_nbiot_ue_sync_t* q,
uint32_t max_prb, uint32_t max_prb,
int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*),
uint32_t nof_rx_antennas, uint32_t nof_rx_antennas,
void* stream_handler); void* stream_handler);
SRSLTE_API int srslte_nbiot_ue_sync_init_file(srslte_nbiot_ue_sync_t* q, SRSLTE_API int srslte_ue_sync_nbiot_init_file(srslte_nbiot_ue_sync_t* q,
srslte_nbiot_cell_t cell, srslte_nbiot_cell_t cell,
char* file_name, char* file_name,
int offset_time, int offset_time,
float offset_freq); float offset_freq);
SRSLTE_API int srslte_nbiot_ue_sync_init_file_multi(srslte_nbiot_ue_sync_t* q, SRSLTE_API int srslte_ue_sync_nbiot_init_file_multi(srslte_nbiot_ue_sync_t* q,
srslte_nbiot_cell_t cell, srslte_nbiot_cell_t cell,
char* file_name, char* file_name,
int offset_time, int offset_time,
float offset_freq, float offset_freq,
uint32_t nof_rx_ant); uint32_t nof_rx_ant);
SRSLTE_API void srslte_nbiot_ue_sync_free(srslte_nbiot_ue_sync_t* q); SRSLTE_API void srslte_ue_sync_nbiot_free(srslte_nbiot_ue_sync_t* q);
SRSLTE_API int srslte_nbiot_ue_sync_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t cell); SRSLTE_API int srslte_ue_sync_nbiot_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t cell);
SRSLTE_API int srslte_nbiot_ue_sync_start_agc(srslte_nbiot_ue_sync_t* q, SRSLTE_API int srslte_ue_sync_nbiot_start_agc(srslte_nbiot_ue_sync_t* q,
float(set_gain_callback)(void*, float), float(set_gain_callback)(void*, float),
float init_gain_value); float init_gain_value);
SRSLTE_API uint32_t srslte_nbiot_ue_sync_sf_len(srslte_nbiot_ue_sync_t* q); SRSLTE_API uint32_t srslte_ue_sync_nbiot_sf_len(srslte_nbiot_ue_sync_t* q);
SRSLTE_API int srslte_nbiot_ue_sync_get_buffer(srslte_nbiot_ue_sync_t* q, cf_t** sf_symbols); SRSLTE_API int srslte_nbiot_ue_sync_get_buffer(srslte_nbiot_ue_sync_t* q, cf_t** sf_symbols);
SRSLTE_API void srslte_nbiot_ue_sync_set_agc_period(srslte_nbiot_ue_sync_t* q, uint32_t period); SRSLTE_API void srslte_ue_sync_nbiot_set_agc_period(srslte_nbiot_ue_sync_t* q, uint32_t period);
/* CAUTION: input_buffer MUST have space for 2 subframes */ /* CAUTION: input_buffer MUST have space for 2 subframes */
SRSLTE_API int srslte_nbiot_ue_sync_zerocopy(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer); SRSLTE_API int srslte_ue_sync_nbiot_zerocopy(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer);
SRSLTE_API int srslte_nbiot_ue_sync_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_PORTS]); SRSLTE_API int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_buffer);
SRSLTE_API void srslte_nbiot_ue_sync_set_cfo(srslte_nbiot_ue_sync_t* q, float cfo); SRSLTE_API void srslte_ue_sync_nbiot_set_cfo(srslte_nbiot_ue_sync_t* q, float cfo);
SRSLTE_API void srslte_nbiot_ue_sync_reset(srslte_nbiot_ue_sync_t* q); SRSLTE_API void srslte_ue_sync_nbiot_reset(srslte_nbiot_ue_sync_t* q);
SRSLTE_API srslte_nbiot_ue_sync_state_t srslte_nbiot_ue_sync_get_state(srslte_nbiot_ue_sync_t* q); SRSLTE_API srslte_nbiot_ue_sync_state_t srslte_ue_sync_nbiot_get_state(srslte_nbiot_ue_sync_t* q);
SRSLTE_API uint32_t srslte_nbiot_ue_sync_get_sfidx(srslte_nbiot_ue_sync_t* q); SRSLTE_API uint32_t srslte_ue_sync_nbiot_get_sfidx(srslte_nbiot_ue_sync_t* q);
SRSLTE_API void srslte_nbiot_ue_sync_set_cfo_enable(srslte_nbiot_ue_sync_t* q, bool enable); SRSLTE_API void srslte_ue_sync_nbiot_set_cfo_enable(srslte_nbiot_ue_sync_t* q, bool enable);
SRSLTE_API float srslte_nbiot_ue_sync_get_cfo(srslte_nbiot_ue_sync_t* q); SRSLTE_API float srslte_ue_sync_nbiot_get_cfo(srslte_nbiot_ue_sync_t* q);
SRSLTE_API float srslte_nbiot_ue_sync_get_sfo(srslte_nbiot_ue_sync_t* q); SRSLTE_API float srslte_ue_sync_nbiot_get_sfo(srslte_nbiot_ue_sync_t* q);
SRSLTE_API void srslte_nbiot_ue_sync_set_cfo_ema(srslte_nbiot_ue_sync_t* q, float ema); SRSLTE_API void srslte_ue_sync_nbiot_set_cfo_ema(srslte_nbiot_ue_sync_t* q, float ema);
SRSLTE_API void srslte_nbiot_ue_sync_set_cfo_tol(srslte_nbiot_ue_sync_t* q, float cfo_tol); SRSLTE_API void srslte_ue_sync_nbiot_set_cfo_tol(srslte_nbiot_ue_sync_t* q, float cfo_tol);
SRSLTE_API int srslte_nbiot_ue_sync_get_last_sample_offset(srslte_nbiot_ue_sync_t* q); SRSLTE_API int srslte_ue_sync_nbiot_get_last_sample_offset(srslte_nbiot_ue_sync_t* q);
SRSLTE_API void srslte_nbiot_ue_sync_set_sample_offset_correct_period(srslte_nbiot_ue_sync_t* q, SRSLTE_API void srslte_ue_sync_nbiot_set_sample_offset_correct_period(srslte_nbiot_ue_sync_t* q,
uint32_t nof_subframes); uint32_t nof_subframes);
SRSLTE_API void srslte_nbiot_ue_sync_get_last_timestamp(srslte_nbiot_ue_sync_t* q, srslte_timestamp_t* timestamp); SRSLTE_API void srslte_ue_sync_nbiot_get_last_timestamp(srslte_nbiot_ue_sync_t* q, srslte_timestamp_t* timestamp);
#endif // SRSLTE_UE_SYNC_NBIOT_H #endif // SRSLTE_UE_SYNC_NBIOT_H

@ -167,7 +167,7 @@ int main(int argc, char** argv)
srslte_mib_nb_t mib_nb; srslte_mib_nb_t mib_nb;
srslte_npbch_mib_unpack(bch_payload_rx, &mib_nb); srslte_npbch_mib_unpack(bch_payload_rx, &mib_nb);
srslte_mib_nb_printf(stdout, cell, &mib_nb); srslte_mib_nb_printf(stdout, cell, &mib_nb);
printf("CFO: %+6.2f kHz\n", srslte_nbiot_ue_sync_get_cfo(&mib_sync.ue_sync) / 1000); printf("CFO: %+6.2f kHz\n", srslte_ue_sync_nbiot_get_cfo(&mib_sync.ue_sync) / 1000);
} else { } else {
printf("Failed!\n"); printf("Failed!\n");
} }

@ -176,13 +176,13 @@ int main(int argc, char** argv)
} }
srslte_nbiot_ue_sync_t ue_sync; srslte_nbiot_ue_sync_t ue_sync;
if (srslte_nbiot_ue_sync_init(&ue_sync, cell, srslte_rf_recv_wrapper_cs, (void*)&rf)) { if (srslte_ue_sync_nbiot_init(&ue_sync, cell, srslte_rf_recv_wrapper_cs, (void*)&rf)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
srslte_nbiot_ue_sync_set_cfo_enable(&ue_sync, do_cfo_corr); srslte_ue_sync_nbiot_set_cfo_enable(&ue_sync, do_cfo_corr);
srslte_nbiot_ue_sync_set_cfo_ema(&ue_sync, cfo_ema); srslte_ue_sync_nbiot_set_cfo_ema(&ue_sync, cfo_ema);
srslte_rf_start_rx_stream(&rf, false); srslte_rf_start_rx_stream(&rf, false);
@ -190,20 +190,20 @@ int main(int argc, char** argv)
printf("Trying to keep syncronized to cell for %d frames\n", nof_frames); printf("Trying to keep syncronized to cell for %d frames\n", nof_frames);
while ((frame_cnt < nof_frames || nof_frames == -1) && !go_exit) { while ((frame_cnt < nof_frames || nof_frames == -1) && !go_exit) {
if (srslte_nbiot_ue_sync_zerocopy_multi(&ue_sync, rx_buffer) < 0) { if (srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, rx_buffer) < 0) {
fprintf(stderr, "Error calling srslte_nbiot_ue_sync_work()\n"); fprintf(stderr, "Error calling srslte_nbiot_ue_sync_work()\n");
break; break;
} }
if (srslte_nbiot_ue_sync_get_sfidx(&ue_sync) == 0) { if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 0) {
printf("CFO: %+6.2f kHz\r", srslte_nbiot_ue_sync_get_cfo(&ue_sync) / 1000); printf("CFO: %+6.2f kHz\r", srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000);
frame_cnt++; frame_cnt++;
} }
#ifndef DISABLE_GRAPHICS #ifndef DISABLE_GRAPHICS
if (!disable_plots) { if (!disable_plots) {
// get current CFO estimate // get current CFO estimate
cfo_table[cfo_table_index++] = srslte_nbiot_ue_sync_get_cfo(&ue_sync) / 1000; cfo_table[cfo_table_index++] = srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000;
if (cfo_table_index == cfo_num_plot) { if (cfo_table_index == cfo_num_plot) {
do_plots_cfo(cfo_table, cfo_num_plot); do_plots_cfo(cfo_table, cfo_num_plot);
cfo_table_index = 0; cfo_table_index = 0;
@ -220,7 +220,7 @@ int main(int argc, char** argv)
} }
clean_exit: clean_exit:
srslte_nbiot_ue_sync_free(&ue_sync); srslte_ue_sync_nbiot_free(&ue_sync);
srslte_rf_close(&rf); srslte_rf_close(&rf);
for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) {

@ -41,7 +41,7 @@ int srslte_ue_cellsearch_nbiot_init(srslte_ue_cellsearch_nbiot_t* q,
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(srslte_ue_cellsearch_nbiot_t)); bzero(q, sizeof(srslte_ue_cellsearch_nbiot_t));
if (srslte_nbiot_ue_sync_init_multi( if (srslte_ue_sync_nbiot_init_multi(
&q->ue_sync, SRSLTE_NBIOT_MAX_PRB, recv_callback, SRSLTE_NBIOT_NUM_RX_ANTENNAS, stream_handler)) { &q->ue_sync, SRSLTE_NBIOT_MAX_PRB, recv_callback, SRSLTE_NBIOT_NUM_RX_ANTENNAS, stream_handler)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
goto clean_exit; goto clean_exit;
@ -83,7 +83,7 @@ void srslte_ue_cellsearch_nbiot_free(srslte_ue_cellsearch_nbiot_t* q)
} }
} }
srslte_nbiot_ue_sync_free(&q->ue_sync); srslte_ue_sync_nbiot_free(&q->ue_sync);
bzero(q, sizeof(srslte_ue_cellsearch_nbiot_t)); bzero(q, sizeof(srslte_ue_cellsearch_nbiot_t));
} }
@ -108,18 +108,18 @@ int srslte_ue_cellsearch_nbiot_scan(srslte_ue_cellsearch_nbiot_t* q)
if (q != NULL) { if (q != NULL) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
srslte_nbiot_ue_sync_reset(&q->ue_sync); srslte_ue_sync_nbiot_reset(&q->ue_sync);
q->nsss_sf_counter = 0; q->nsss_sf_counter = 0;
do { do {
ret = srslte_nbiot_ue_sync_zerocopy_multi(&q->ue_sync, q->rx_buffer); ret = srslte_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->rx_buffer);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error calling srslte_nbiot_ue_sync_get_buffer()\n"); fprintf(stderr, "Error calling srslte_nbiot_ue_sync_get_buffer()\n");
break; break;
} else if (ret == 1) { } else if (ret == 1) {
// we are in sync, wait until we have received two full frames, store subframe 9 for both // we are in sync, wait until we have received two full frames, store subframe 9 for both
DEBUG("In tracking state sf_idx=%d\n", srslte_nbiot_ue_sync_get_sfidx(&q->ue_sync)); DEBUG("In tracking state sf_idx=%d\n", srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync));
if (srslte_nbiot_ue_sync_get_sfidx(&q->ue_sync) == 9) { if (srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 9) {
// accumulate NSSS subframes for cell id detection // accumulate NSSS subframes for cell id detection
memcpy(&q->nsss_buffer[q->nsss_sf_counter * SRSLTE_SF_LEN_PRB_NBIOT], memcpy(&q->nsss_buffer[q->nsss_sf_counter * SRSLTE_SF_LEN_PRB_NBIOT],
q->rx_buffer[0], q->rx_buffer[0],
@ -150,7 +150,7 @@ int srslte_ue_cellsearch_nbiot_detect(srslte_ue_cellsearch_nbiot_t* q, srslte_nb
found_cells[0].n_id_ncell = (uint32_t)cell_id; found_cells[0].n_id_ncell = (uint32_t)cell_id;
found_cells[0].peak = q->ue_sync.strack.npss.peak_value; found_cells[0].peak = q->ue_sync.strack.npss.peak_value;
found_cells[0].psr = srslte_sync_nbiot_get_peak_value(&q->ue_sync.strack); found_cells[0].psr = srslte_sync_nbiot_get_peak_value(&q->ue_sync.strack);
found_cells[0].cfo = srslte_nbiot_ue_sync_get_cfo(&q->ue_sync); found_cells[0].cfo = srslte_ue_sync_nbiot_get_cfo(&q->ue_sync);
INFO("CELL SEARCH: Found peak PSR=%.3f, Cell_id: %d\n", found_cells[0].psr, found_cells[0].n_id_ncell); INFO("CELL SEARCH: Found peak PSR=%.3f, Cell_id: %d\n", found_cells[0].psr, found_cells[0].n_id_ncell);
} }
} }

@ -203,7 +203,7 @@ int srslte_ue_mib_sync_nbiot_init_multi(
fprintf(stderr, "Error initiating ue_mib\n"); fprintf(stderr, "Error initiating ue_mib\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_nbiot_ue_sync_init_multi( if (srslte_ue_sync_nbiot_init_multi(
&q->ue_sync, SRSLTE_NBIOT_MAX_PRB, recv_callback, q->nof_rx_antennas, stream_handler)) { &q->ue_sync, SRSLTE_NBIOT_MAX_PRB, recv_callback, q->nof_rx_antennas, stream_handler)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
srslte_ue_mib_nbiot_free(&q->ue_mib); srslte_ue_mib_nbiot_free(&q->ue_mib);
@ -218,7 +218,7 @@ int srslte_ue_mib_sync_nbiot_set_cell(srslte_ue_mib_sync_nbiot_t* q, srslte_nbio
fprintf(stderr, "Error initiating ue_mib\n"); fprintf(stderr, "Error initiating ue_mib\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_nbiot_ue_sync_set_cell(&q->ue_sync, cell)) { if (srslte_ue_sync_nbiot_set_cell(&q->ue_sync, cell)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
srslte_ue_mib_nbiot_free(&q->ue_mib); srslte_ue_mib_nbiot_free(&q->ue_mib);
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -229,13 +229,13 @@ int srslte_ue_mib_sync_nbiot_set_cell(srslte_ue_mib_sync_nbiot_t* q, srslte_nbio
void srslte_ue_mib_sync_nbiot_free(srslte_ue_mib_sync_nbiot_t* q) void srslte_ue_mib_sync_nbiot_free(srslte_ue_mib_sync_nbiot_t* q)
{ {
srslte_ue_mib_nbiot_free(&q->ue_mib); srslte_ue_mib_nbiot_free(&q->ue_mib);
srslte_nbiot_ue_sync_free(&q->ue_sync); srslte_ue_sync_nbiot_free(&q->ue_sync);
} }
void srslte_ue_mib_sync_nbiot_reset(srslte_ue_mib_sync_nbiot_t* q) void srslte_ue_mib_sync_nbiot_reset(srslte_ue_mib_sync_nbiot_t* q)
{ {
srslte_ue_mib_nbiot_reset(&q->ue_mib); srslte_ue_mib_nbiot_reset(&q->ue_mib);
srslte_nbiot_ue_sync_reset(&q->ue_sync); srslte_ue_sync_nbiot_reset(&q->ue_sync);
} }
int srslte_ue_mib_sync_nbiot_decode(srslte_ue_mib_sync_nbiot_t* q, int srslte_ue_mib_sync_nbiot_decode(srslte_ue_mib_sync_nbiot_t* q,
@ -251,11 +251,11 @@ int srslte_ue_mib_sync_nbiot_decode(srslte_ue_mib_sync_nbiot_t* q,
uint32_t nof_frames = 0; uint32_t nof_frames = 0;
do { do {
mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND; mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND;
ret = srslte_nbiot_ue_sync_zerocopy_multi(&q->ue_sync, q->sf_buffer); ret = srslte_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->sf_buffer);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error calling srslte_nbiot_ue_sync_zerocopy_multi()\n"); fprintf(stderr, "Error calling srslte_ue_sync_nbiot_zerocopy_multi()\n");
break; break;
} else if (srslte_nbiot_ue_sync_get_sfidx(&q->ue_sync) == 0) { } else if (srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 0) {
mib_ret = srslte_ue_mib_nbiot_decode(&q->ue_mib, NULL, bch_payload, nof_tx_ports, sfn_offset); mib_ret = srslte_ue_mib_nbiot_decode(&q->ue_mib, NULL, bch_payload, nof_tx_ports, sfn_offset);
if (mib_ret < 0) { if (mib_ret < 0) {
DEBUG("Resetting NPBCH decoder after %d frames\n", q->ue_mib.frame_cnt); DEBUG("Resetting NPBCH decoder after %d frames\n", q->ue_mib.frame_cnt);

@ -33,33 +33,30 @@
#define REPEAT_FROM_FILE 0 #define REPEAT_FROM_FILE 0
#define TIME_ALIGN_FROM_FILE 1 #define TIME_ALIGN_FROM_FILE 1
#define MAX_TIME_OFFSET 128 #define MAX_TIME_OFFSET 128
cf_t dummy[MAX_TIME_OFFSET];
#define TRACK_MAX_LOST 4 #define TRACK_MAX_LOST 4
#define TRACK_FRAME_SIZE 32 #define TRACK_FRAME_SIZE 32
#define FIND_NOF_AVG_FRAMES 4 #define FIND_NOF_AVG_FRAMES 4
#define DEFAULT_SFO_EMA_COEFF 0.1 #define DEFAULT_SFO_EMA_COEFF 0.1
cf_t dummy_buffer_nbiot0[15 * 2048 / 2]; static cf_t dummy_buffer_nbiot0[15 * 2048 / 2];
cf_t dummy_buffer_nbiot1[15 * 2048 / 2]; static cf_t dummy_buffer_nbiot1[15 * 2048 / 2];
static cf_t* dummy_offset_buffer_nbiot[SRSLTE_MAX_PORTS] = {dummy_buffer_nbiot0, dummy_buffer_nbiot1, NULL, NULL};
// FIXME: this will break for 4 antennas!!
cf_t* dummy_offset_buffer_nbiot[SRSLTE_MAX_PORTS] = {dummy_buffer_nbiot0, dummy_buffer_nbiot1};
///< This is a list of CFO candidates that the sync object uses to pre-compensate the received signal ///< This is a list of CFO candidates that the sync object uses to pre-compensate the received signal
static const float cfo_cands[] = static const float cfo_cands[] =
{0.0, 1000.0, -1000.0, 2000.0, -2000.0, 3000.0, -3000.0, 4000.0, -4000.0, 5000.0, -5000.0}; {0.0, 1000.0, -1000.0, 2000.0, -2000.0, 3000.0, -3000.0, 4000.0, -4000.0, 5000.0, -5000.0};
int srslte_nbiot_ue_sync_init_file(srslte_nbiot_ue_sync_t* q, int srslte_ue_sync_nbiot_init_file(srslte_nbiot_ue_sync_t* q,
srslte_nbiot_cell_t cell, srslte_nbiot_cell_t cell,
char* file_name, char* file_name,
int offset_time, int offset_time,
float offset_freq) float offset_freq)
{ {
return srslte_nbiot_ue_sync_init_file_multi(q, cell, file_name, offset_time, offset_freq, 1); return srslte_ue_sync_nbiot_init_file_multi(q, cell, file_name, offset_time, offset_freq, 1);
} }
int srslte_nbiot_ue_sync_init_file_multi(srslte_nbiot_ue_sync_t* q, int srslte_ue_sync_nbiot_init_file_multi(srslte_nbiot_ue_sync_t* q,
srslte_nbiot_cell_t cell, srslte_nbiot_cell_t cell,
char* file_name, char* file_name,
int offset_time, int offset_time,
@ -118,18 +115,18 @@ int srslte_nbiot_ue_sync_init_file_multi(srslte_nbiot_ue_sync_t* q,
INFO("Offseting input file by %d samples and %.1f kHz\n", offset_time, offset_freq / 1000); INFO("Offseting input file by %d samples and %.1f kHz\n", offset_time, offset_freq / 1000);
srslte_filesource_read(&q->file_source, dummy_buffer_nbiot0, offset_time); srslte_filesource_read(&q->file_source, dummy_buffer_nbiot0, offset_time);
srslte_nbiot_ue_sync_reset(q); srslte_ue_sync_nbiot_reset(q);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} }
clean_exit: clean_exit:
if (ret == SRSLTE_ERROR) { if (ret == SRSLTE_ERROR) {
srslte_nbiot_ue_sync_free(q); srslte_ue_sync_nbiot_free(q);
} }
return ret; return ret;
} }
int srslte_nbiot_ue_sync_start_agc(srslte_nbiot_ue_sync_t* q, int srslte_ue_sync_nbiot_start_agc(srslte_nbiot_ue_sync_t* q,
float(set_gain_callback)(void*, float), float(set_gain_callback)(void*, float),
float init_gain_value) float init_gain_value)
{ {
@ -153,19 +150,19 @@ int recv_callback_nbiot_multi_to_single(void* h, cf_t* x[SRSLTE_MAX_PORTS], uint
return q->recv_callback_single(q->stream_single, (void*)x[0], nsamples, t); return q->recv_callback_single(q->stream_single, (void*)x[0], nsamples, t);
} }
int srslte_nbiot_ue_sync_init(srslte_nbiot_ue_sync_t* q, int srslte_ue_sync_nbiot_init(srslte_nbiot_ue_sync_t* q,
srslte_nbiot_cell_t cell, srslte_nbiot_cell_t cell,
int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*),
void* stream_handler) void* stream_handler)
{ {
int ret = srslte_nbiot_ue_sync_init_multi( int ret = srslte_ue_sync_nbiot_init_multi(
q, SRSLTE_NBIOT_MAX_PRB, recv_callback_nbiot_multi_to_single, SRSLTE_NBIOT_NUM_RX_ANTENNAS, (void*)q); q, SRSLTE_NBIOT_MAX_PRB, recv_callback_nbiot_multi_to_single, SRSLTE_NBIOT_NUM_RX_ANTENNAS, (void*)q);
q->recv_callback_single = recv_callback; q->recv_callback_single = recv_callback;
q->stream_single = stream_handler; q->stream_single = stream_handler;
return ret; return ret;
} }
int srslte_nbiot_ue_sync_init_multi(srslte_nbiot_ue_sync_t* q, int srslte_ue_sync_nbiot_init_multi(srslte_nbiot_ue_sync_t* q,
uint32_t max_prb, uint32_t max_prb,
int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*),
uint32_t nof_rx_antennas, uint32_t nof_rx_antennas,
@ -206,24 +203,24 @@ int srslte_nbiot_ue_sync_init_multi(srslte_nbiot_ue_sync_t* q,
goto clean_exit; goto clean_exit;
} }
srslte_nbiot_ue_sync_reset(q); srslte_ue_sync_nbiot_reset(q);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} }
clean_exit: clean_exit:
if (ret == SRSLTE_ERROR) { if (ret == SRSLTE_ERROR) {
srslte_nbiot_ue_sync_free(q); srslte_ue_sync_nbiot_free(q);
} }
return ret; return ret;
} }
uint32_t srslte_nbiot_ue_sync_sf_len(srslte_nbiot_ue_sync_t* q) uint32_t srslte_ue_sync_nbiot_sf_len(srslte_nbiot_ue_sync_t* q)
{ {
return q->frame_len; return q->frame_len;
} }
void srslte_nbiot_ue_sync_free(srslte_nbiot_ue_sync_t* q) void srslte_ue_sync_nbiot_free(srslte_nbiot_ue_sync_t* q)
{ {
if (q->do_agc) { if (q->do_agc) {
srslte_agc_free(&q->agc); srslte_agc_free(&q->agc);
@ -237,7 +234,7 @@ void srslte_nbiot_ue_sync_free(srslte_nbiot_ue_sync_t* q)
bzero(q, sizeof(srslte_nbiot_ue_sync_t)); bzero(q, sizeof(srslte_nbiot_ue_sync_t));
} }
int srslte_nbiot_ue_sync_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t cell) int srslte_ue_sync_nbiot_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t cell)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
@ -268,7 +265,7 @@ int srslte_nbiot_ue_sync_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_nbiot_ue_sync_reset(q); srslte_ue_sync_nbiot_reset(q);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} }
@ -276,75 +273,75 @@ int srslte_nbiot_ue_sync_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t
return ret; return ret;
} }
void srslte_nbiot_ue_sync_get_last_timestamp(srslte_nbiot_ue_sync_t* q, srslte_timestamp_t* timestamp) void srslte_ue_sync_nbiot_get_last_timestamp(srslte_nbiot_ue_sync_t* q, srslte_timestamp_t* timestamp)
{ {
memcpy(timestamp, &q->last_timestamp, sizeof(srslte_timestamp_t)); memcpy(timestamp, &q->last_timestamp, sizeof(srslte_timestamp_t));
} }
uint32_t srslte_nbiot_ue_sync_peak_idx(srslte_nbiot_ue_sync_t* q) uint32_t srslte_ue_sync_nbiot_peak_idx(srslte_nbiot_ue_sync_t* q)
{ {
return q->peak_idx; return q->peak_idx;
} }
srslte_nbiot_ue_sync_state_t srslte_nbiot_ue_sync_get_state(srslte_nbiot_ue_sync_t* q) srslte_nbiot_ue_sync_state_t srslte_ue_sync_nbiot_get_state(srslte_nbiot_ue_sync_t* q)
{ {
return q->state; return q->state;
} }
uint32_t srslte_nbiot_ue_sync_get_sfidx(srslte_nbiot_ue_sync_t* q) uint32_t srslte_ue_sync_nbiot_get_sfidx(srslte_nbiot_ue_sync_t* q)
{ {
return q->sf_idx; return q->sf_idx;
} }
void srslte_nbiot_ue_sync_set_cfo_enable(srslte_nbiot_ue_sync_t* q, bool enable) void srslte_ue_sync_nbiot_set_cfo_enable(srslte_nbiot_ue_sync_t* q, bool enable)
{ {
srslte_sync_nbiot_set_cfo_enable(&q->sfind, enable); srslte_sync_nbiot_set_cfo_enable(&q->sfind, enable);
srslte_sync_nbiot_set_cfo_enable(&q->strack, enable); srslte_sync_nbiot_set_cfo_enable(&q->strack, enable);
} }
float srslte_nbiot_ue_sync_get_cfo(srslte_nbiot_ue_sync_t* q) float srslte_ue_sync_nbiot_get_cfo(srslte_nbiot_ue_sync_t* q)
{ {
return 15000 * (q->state == SF_TRACK ? srslte_sync_nbiot_get_cfo(&q->strack) : srslte_sync_nbiot_get_cfo(&q->sfind)); return 15000 * (q->state == SF_TRACK ? srslte_sync_nbiot_get_cfo(&q->strack) : srslte_sync_nbiot_get_cfo(&q->sfind));
} }
void srslte_nbiot_ue_sync_set_cfo(srslte_nbiot_ue_sync_t* q, float cfo) void srslte_ue_sync_nbiot_set_cfo(srslte_nbiot_ue_sync_t* q, float cfo)
{ {
srslte_sync_nbiot_set_cfo(&q->sfind, cfo / 15000); srslte_sync_nbiot_set_cfo(&q->sfind, cfo / 15000);
srslte_sync_nbiot_set_cfo(&q->strack, cfo / 15000); srslte_sync_nbiot_set_cfo(&q->strack, cfo / 15000);
} }
float srslte_nbiot_ue_sync_get_sfo(srslte_nbiot_ue_sync_t* q) float srslte_ue_sync_nbiot_get_sfo(srslte_nbiot_ue_sync_t* q)
{ {
return q->mean_sfo / 5e-3; return q->mean_sfo / 5e-3;
} }
int srslte_nbiot_ue_sync_get_last_sample_offset(srslte_nbiot_ue_sync_t* q) int srslte_ue_sync_nbiot_get_last_sample_offset(srslte_nbiot_ue_sync_t* q)
{ {
return q->last_sample_offset; return q->last_sample_offset;
} }
void srslte_nbiot_ue_sync_set_sample_offset_correct_period(srslte_nbiot_ue_sync_t* q, uint32_t nof_subframes) void srslte_ue_sync_nbiot_set_sample_offset_correct_period(srslte_nbiot_ue_sync_t* q, uint32_t nof_subframes)
{ {
q->sample_offset_correct_period = nof_subframes; q->sample_offset_correct_period = nof_subframes;
} }
void srslte_nbiot_ue_sync_set_cfo_ema(srslte_nbiot_ue_sync_t* q, float ema) void srslte_ue_sync_nbiot_set_cfo_ema(srslte_nbiot_ue_sync_t* q, float ema)
{ {
srslte_sync_nbiot_set_cfo_ema_alpha(&q->sfind, ema); srslte_sync_nbiot_set_cfo_ema_alpha(&q->sfind, ema);
srslte_sync_nbiot_set_cfo_ema_alpha(&q->strack, ema); srslte_sync_nbiot_set_cfo_ema_alpha(&q->strack, ema);
} }
void srslte_nbiot_ue_sync_set_cfo_tol(srslte_nbiot_ue_sync_t* q, float cfo_tol) void srslte_ue_sync_nbiot_set_cfo_tol(srslte_nbiot_ue_sync_t* q, float cfo_tol)
{ {
srslte_sync_nbiot_set_cfo_tol(&q->sfind, cfo_tol); srslte_sync_nbiot_set_cfo_tol(&q->sfind, cfo_tol);
srslte_sync_nbiot_set_cfo_tol(&q->strack, cfo_tol); srslte_sync_nbiot_set_cfo_tol(&q->strack, cfo_tol);
} }
void srslte_nbiot_ue_sync_set_sfo_ema(srslte_nbiot_ue_sync_t* q, float ema_coefficient) void srslte_ue_sync_nbiot_set_sfo_ema(srslte_nbiot_ue_sync_t* q, float ema_coefficient)
{ {
q->sfo_ema = ema_coefficient; q->sfo_ema = ema_coefficient;
} }
void srslte_nbiot_ue_sync_set_agc_period(srslte_nbiot_ue_sync_t* q, uint32_t period) void srslte_ue_sync_nbiot_set_agc_period(srslte_nbiot_ue_sync_t* q, uint32_t period)
{ {
q->agc_period = period; q->agc_period = period;
} }
@ -425,7 +422,7 @@ static int track_peak_ok(srslte_nbiot_ue_sync_t* q, uint32_t track_idx)
INFO("Time offset adjustment: %d samples (%.2f), mean SFO: %.2f Hz, %.5f samples/10-sf, ema=%f, length=%d\n", INFO("Time offset adjustment: %d samples (%.2f), mean SFO: %.2f Hz, %.5f samples/10-sf, ema=%f, length=%d\n",
q->next_rf_sample_offset, q->next_rf_sample_offset,
q->mean_sample_offset, q->mean_sample_offset,
srslte_nbiot_ue_sync_get_sfo(q), srslte_ue_sync_nbiot_get_sfo(q),
q->mean_sfo, q->mean_sfo,
q->sfo_ema, q->sfo_ema,
q->sample_offset_correct_period); q->sample_offset_correct_period);
@ -497,15 +494,15 @@ static int receive_samples(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int srslte_nbiot_ue_sync_zerocopy(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer) int srslte_ue_sync_nbiot_zerocopy(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer)
{ {
cf_t* _input_buffer[SRSLTE_MAX_PORTS] = {NULL}; cf_t* _input_buffer[SRSLTE_MAX_PORTS] = {NULL};
_input_buffer[0] = input_buffer; _input_buffer[0] = input_buffer;
return srslte_nbiot_ue_sync_zerocopy_multi(q, _input_buffer); return srslte_ue_sync_nbiot_zerocopy_multi(q, _input_buffer);
} }
/* Returns 1 if the subframe is synchronized in time, 0 otherwise */ /* Returns 1 if the subframe is synchronized in time, 0 otherwise */
int srslte_nbiot_ue_sync_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_PORTS]) int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_buffer)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
@ -629,7 +626,7 @@ int srslte_nbiot_ue_sync_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t* input_b
return ret; return ret;
} }
void srslte_nbiot_ue_sync_reset(srslte_nbiot_ue_sync_t* q) void srslte_ue_sync_nbiot_reset(srslte_nbiot_ue_sync_t* q)
{ {
///< Set default params ///< Set default params
srslte_sync_nbiot_set_cfo_enable(&q->sfind, true); srslte_sync_nbiot_set_cfo_enable(&q->sfind, true);

Loading…
Cancel
Save