mirror of https://github.com/PentHertz/srsLTE.git
fixing various issues in NB-IoT sync code detected by Coverity and clang-tidy
This commit is contained in:
parent
c9d3b61038
commit
ada4e6644f
|
@ -100,7 +100,7 @@ SRSLTE_API void srslte_sync_nbiot_set_cfo_enable(srslte_sync_nbiot_t* q, bool en
|
||||||
|
|
||||||
SRSLTE_API void srslte_sync_nbiot_set_cfo_cand_test_enable(srslte_sync_nbiot_t* q, bool enable);
|
SRSLTE_API void srslte_sync_nbiot_set_cfo_cand_test_enable(srslte_sync_nbiot_t* q, bool enable);
|
||||||
|
|
||||||
SRSLTE_API int srslte_sync_nbiot_set_cfo_cand(srslte_sync_nbiot_t* q, float* cand, const int num);
|
SRSLTE_API int srslte_sync_nbiot_set_cfo_cand(srslte_sync_nbiot_t* q, const float* cand, const int num);
|
||||||
|
|
||||||
SRSLTE_API void srslte_sync_nbiot_set_cfo_tol(srslte_sync_nbiot_t* q, float tol);
|
SRSLTE_API void srslte_sync_nbiot_set_cfo_tol(srslte_sync_nbiot_t* q, float tol);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t
|
||||||
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||||||
|
|
||||||
if (q != NULL) {
|
if (q != NULL) {
|
||||||
bzero(q, sizeof(srslte_npss_synch_t));
|
ret = SRSLTE_ERROR;
|
||||||
|
|
||||||
|
memset(q, 0, sizeof(srslte_npss_synch_t));
|
||||||
|
|
||||||
q->fft_size = q->max_fft_size = fft_size;
|
q->fft_size = q->max_fft_size = fft_size;
|
||||||
q->frame_size = q->max_frame_size = frame_size;
|
q->frame_size = q->max_frame_size = frame_size;
|
||||||
|
@ -64,27 +66,27 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t
|
||||||
PRINT_ERR("Error allocating memory\n");
|
PRINT_ERR("Error allocating memory\n");
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
bzero(q->tmp_input, buffer_size * sizeof(cf_t));
|
memset(q->tmp_input, 0, buffer_size * sizeof(cf_t));
|
||||||
|
|
||||||
q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
||||||
if (!q->conv_output) {
|
if (!q->conv_output) {
|
||||||
fprintf(stderr, "Error allocating memory\n");
|
fprintf(stderr, "Error allocating memory\n");
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
bzero(q->conv_output, sizeof(cf_t) * buffer_size);
|
memset(q->conv_output, 0, sizeof(cf_t) * buffer_size);
|
||||||
q->conv_output_avg = srslte_vec_malloc(buffer_size * sizeof(float));
|
q->conv_output_avg = srslte_vec_malloc(buffer_size * sizeof(float));
|
||||||
if (!q->conv_output_avg) {
|
if (!q->conv_output_avg) {
|
||||||
fprintf(stderr, "Error allocating memory\n");
|
fprintf(stderr, "Error allocating memory\n");
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
|
memset(q->conv_output_avg, 0, sizeof(float) * buffer_size);
|
||||||
#ifdef SRSLTE_NPSS_ACCUMULATE_ABS
|
#ifdef SRSLTE_NPSS_ACCUMULATE_ABS
|
||||||
q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float));
|
q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float));
|
||||||
if (!q->conv_output_abs) {
|
if (!q->conv_output_abs) {
|
||||||
fprintf(stderr, "Error allocating memory\n");
|
fprintf(stderr, "Error allocating memory\n");
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
bzero(q->conv_output_abs, sizeof(float) * buffer_size);
|
memset(q->conv_output_abs, 0, sizeof(float) * buffer_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
q->npss_signal_time = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
q->npss_signal_time = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
||||||
|
@ -92,7 +94,7 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t
|
||||||
fprintf(stderr, "Error allocating memory\n");
|
fprintf(stderr, "Error allocating memory\n");
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
bzero(q->npss_signal_time, sizeof(cf_t) * buffer_size);
|
memset(q->npss_signal_time, 0, sizeof(cf_t) * buffer_size);
|
||||||
|
|
||||||
// The NPSS is translated into the time domain
|
// The NPSS is translated into the time domain
|
||||||
if (srslte_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) {
|
if (srslte_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) {
|
||||||
|
@ -137,16 +139,15 @@ int srslte_npss_synch_resize(srslte_npss_synch_t* q, uint32_t frame_size, uint32
|
||||||
q->frame_size = frame_size;
|
q->frame_size = frame_size;
|
||||||
|
|
||||||
uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + frame_size + 1;
|
uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + frame_size + 1;
|
||||||
bzero(q->tmp_input, buffer_size * sizeof(cf_t));
|
memset(q->tmp_input, 0, buffer_size * sizeof(cf_t));
|
||||||
bzero(q->conv_output, sizeof(cf_t) * buffer_size);
|
memset(q->conv_output, 0, sizeof(cf_t) * buffer_size);
|
||||||
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
|
memset(q->conv_output_avg, 0, sizeof(float) * buffer_size);
|
||||||
|
|
||||||
#ifdef SRSLTE_NPSS_ACCUMULATE_ABS
|
#ifdef SRSLTE_NPSS_ACCUMULATE_ABS
|
||||||
bzero(q->conv_output_abs, sizeof(float) * buffer_size);
|
memset(q->conv_output_abs, 0, sizeof(float) * buffer_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Re-generate NPSS sequences for this FFT size
|
// Re-generate NPSS sequences for this FFT size
|
||||||
// bzero(q->npss_signal_time, sizeof(cf_t) * buffer_size);
|
|
||||||
if (srslte_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) {
|
if (srslte_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) {
|
||||||
fprintf(stderr, "Error initiating NPSS detector for fft_size=%d\n", fft_size);
|
fprintf(stderr, "Error initiating NPSS detector for fft_size=%d\n", fft_size);
|
||||||
return SRSLTE_ERROR;
|
return SRSLTE_ERROR;
|
||||||
|
@ -166,11 +167,11 @@ int srslte_npss_synch_resize(srslte_npss_synch_t* q, uint32_t frame_size, uint32
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int srslte_npss_corr_init(cf_t* npss_signal_time, uint32_t fft_size, uint32_t frame_size)
|
int srslte_npss_corr_init(cf_t* npss_signal_time, const uint32_t fft_size, const uint32_t frame_size)
|
||||||
{
|
{
|
||||||
srslte_dft_plan_t plan;
|
srslte_dft_plan_t plan;
|
||||||
_Complex float npss_signal_pad[fft_size];
|
_Complex float npss_signal_pad[fft_size];
|
||||||
_Complex float npss_signal[SRSLTE_NPSS_TOT_LEN];
|
_Complex float npss_signal[SRSLTE_NPSS_TOT_LEN] = {};
|
||||||
|
|
||||||
// generate correlation sequence
|
// generate correlation sequence
|
||||||
srslte_npss_generate(npss_signal);
|
srslte_npss_generate(npss_signal);
|
||||||
|
@ -179,8 +180,8 @@ int srslte_npss_corr_init(cf_t* npss_signal_time, uint32_t fft_size, uint32_t fr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// zero buffers
|
// zero buffers
|
||||||
bzero(npss_signal_time, (fft_size + frame_size) * sizeof(cf_t));
|
memset(npss_signal_time, 0, (fft_size + frame_size) * sizeof(cf_t));
|
||||||
bzero(npss_signal_pad, fft_size * sizeof(cf_t));
|
memset(npss_signal_pad, 0, fft_size * sizeof(cf_t));
|
||||||
|
|
||||||
// construct dft plan and convert signal into the time domain
|
// construct dft plan and convert signal into the time domain
|
||||||
if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) {
|
if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) {
|
||||||
|
@ -195,7 +196,7 @@ int srslte_npss_corr_init(cf_t* npss_signal_time, uint32_t fft_size, uint32_t fr
|
||||||
int output_len = 0;
|
int output_len = 0;
|
||||||
for (int i = 0; i < SRSLTE_NPSS_NUM_OFDM_SYMS; i++) {
|
for (int i = 0; i < SRSLTE_NPSS_NUM_OFDM_SYMS; i++) {
|
||||||
// zero buffer, copy NPSS symbol to appr. pos and transform to time-domain
|
// zero buffer, copy NPSS symbol to appr. pos and transform to time-domain
|
||||||
bzero(npss_signal_pad, fft_size * sizeof(cf_t));
|
memset(npss_signal_pad, 0, fft_size * sizeof(cf_t));
|
||||||
|
|
||||||
// 5th NPSS symbol has CP length of 10 symbols
|
// 5th NPSS symbol has CP length of 10 symbols
|
||||||
int cp_len = (i != 4) ? SRSLTE_CP_LEN_NORM(1, SRSLTE_NBIOT_FFT_SIZE) : SRSLTE_CP_LEN_NORM(0, SRSLTE_NBIOT_FFT_SIZE);
|
int cp_len = (i != 4) ? SRSLTE_CP_LEN_NORM(1, SRSLTE_NBIOT_FFT_SIZE) : SRSLTE_CP_LEN_NORM(0, SRSLTE_NBIOT_FFT_SIZE);
|
||||||
|
@ -384,7 +385,7 @@ void srslte_npss_synch_reset(srslte_npss_synch_t* q)
|
||||||
{
|
{
|
||||||
if (q->conv_output_avg) {
|
if (q->conv_output_avg) {
|
||||||
uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + q->max_frame_size + 1;
|
uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + q->max_frame_size + 1;
|
||||||
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
|
memset(q->conv_output_avg, 0, sizeof(float) * buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +413,7 @@ int srslte_npss_generate(cf_t* signal)
|
||||||
__real__ signal[l * SRSLTE_NPSS_LEN + n] = cosf(arg);
|
__real__ signal[l * SRSLTE_NPSS_LEN + n] = cosf(arg);
|
||||||
__imag__ signal[l * SRSLTE_NPSS_LEN + n] = sinf(arg);
|
__imag__ signal[l * SRSLTE_NPSS_LEN + n] = sinf(arg);
|
||||||
|
|
||||||
signal[l * SRSLTE_NPSS_LEN + n] *= (float)factor_lut[l];
|
signal[l * SRSLTE_NPSS_LEN + n] *= factor_lut[l];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +426,7 @@ void srslte_npss_put_subframe(
|
||||||
srslte_npss_synch_t* q, cf_t* npss_signal, cf_t* sf, const uint32_t nof_prb, const uint32_t nbiot_prb_offset)
|
srslte_npss_synch_t* q, cf_t* npss_signal, cf_t* sf, const uint32_t nof_prb, const uint32_t nbiot_prb_offset)
|
||||||
{
|
{
|
||||||
// skip first 3 OFDM symbols over all PRBs completely
|
// skip first 3 OFDM symbols over all PRBs completely
|
||||||
int k = 3 * nof_prb * SRSLTE_NRE + nbiot_prb_offset * SRSLTE_NRE;
|
uint32_t k = 3 * nof_prb * SRSLTE_NRE + nbiot_prb_offset * SRSLTE_NRE;
|
||||||
|
|
||||||
// put NPSS in each of the 11 symbols of the subframe
|
// put NPSS in each of the 11 symbols of the subframe
|
||||||
for (int l = 0; l < SRSLTE_CP_NORM_SF_NSYMB - 3; l++) {
|
for (int l = 0; l < SRSLTE_CP_NORM_SF_NSYMB - 3; l++) {
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "srslte/phy/utils/debug.h"
|
#include "srslte/phy/utils/debug.h"
|
||||||
#include "srslte/phy/utils/vector.h"
|
#include "srslte/phy/utils/vector.h"
|
||||||
|
|
||||||
#define MEANPEAK_EMA_ALPHA 0.1
|
|
||||||
#define CFO_EMA_ALPHA 0.1
|
#define CFO_EMA_ALPHA 0.1
|
||||||
#define CP_EMA_ALPHA 0.1
|
#define CP_EMA_ALPHA 0.1
|
||||||
#define DEFAULT_CFO_TOL 50.0 // Hz
|
#define DEFAULT_CFO_TOL 50.0 // Hz
|
||||||
|
@ -43,65 +42,69 @@ int srslte_sync_nbiot_init(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t
|
||||||
{
|
{
|
||||||
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||||||
|
|
||||||
q->n_id_ncell = SRSLTE_CELL_ID_UNKNOWN;
|
if (q != NULL) {
|
||||||
q->mean_cfo = 0;
|
ret = SRSLTE_ERROR;
|
||||||
q->cfo_ema_alpha = CFO_EMA_ALPHA;
|
|
||||||
q->fft_size = fft_size;
|
|
||||||
q->frame_size = frame_size;
|
|
||||||
q->max_frame_size = frame_size;
|
|
||||||
q->max_offset = max_offset;
|
|
||||||
q->threshold = 5.0;
|
|
||||||
q->enable_cfo_estimation = true;
|
|
||||||
|
|
||||||
if (srslte_cfo_init(&q->cfocorr, q->frame_size)) {
|
q->n_id_ncell = SRSLTE_CELL_ID_UNKNOWN;
|
||||||
fprintf(stderr, "Error initiating CFO\n");
|
q->mean_cfo = 0;
|
||||||
goto clean_exit;
|
q->cfo_ema_alpha = CFO_EMA_ALPHA;
|
||||||
|
q->fft_size = fft_size;
|
||||||
|
q->frame_size = frame_size;
|
||||||
|
q->max_frame_size = frame_size;
|
||||||
|
q->max_offset = max_offset;
|
||||||
|
q->threshold = 5.0;
|
||||||
|
q->enable_cfo_estimation = true;
|
||||||
|
|
||||||
|
if (srslte_cfo_init(&q->cfocorr, q->frame_size)) {
|
||||||
|
fprintf(stderr, "Error initiating CFO\n");
|
||||||
|
goto clean_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set default CFO tolerance
|
||||||
|
srslte_sync_nbiot_set_cfo_tol(q, DEFAULT_CFO_TOL);
|
||||||
|
|
||||||
|
// initialize shift buffer for CFO estimation
|
||||||
|
q->shift_buffer = srslte_vec_malloc(SRSLTE_SF_LEN(q->fft_size) * sizeof(cf_t));
|
||||||
|
if (!q->shift_buffer) {
|
||||||
|
perror("malloc");
|
||||||
|
goto clean_exit;
|
||||||
|
}
|
||||||
|
srslte_cexptab_gen_sf(q->shift_buffer, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR, q->fft_size);
|
||||||
|
|
||||||
|
// allocate memory for early CFO estimation
|
||||||
|
q->cfo_output = srslte_vec_malloc(10 * SRSLTE_SF_LEN(q->fft_size) * sizeof(cf_t));
|
||||||
|
if (!q->cfo_output) {
|
||||||
|
perror("malloc");
|
||||||
|
goto clean_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// configure CP
|
||||||
|
q->cp = SRSLTE_CP_NORM;
|
||||||
|
q->cp_len = SRSLTE_CP_LEN_NORM(1, q->fft_size);
|
||||||
|
if (q->frame_size < q->fft_size) {
|
||||||
|
q->nof_symbols = 1;
|
||||||
|
} else {
|
||||||
|
q->nof_symbols = q->frame_size / (q->fft_size + q->cp_len) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srslte_npss_synch_init(&q->npss, frame_size, fft_size)) {
|
||||||
|
fprintf(stderr, "Error initializing NPSS object\n");
|
||||||
|
return SRSLTE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srslte_nsss_synch_init(&q->nsss, SRSLTE_NSSS_NUM_SF_DETECT * SRSLTE_SF_LEN_PRB_NBIOT, fft_size)) {
|
||||||
|
fprintf(stderr, "Error initializing NSSS object\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srslte_cp_synch_init(&q->cp_synch, fft_size)) {
|
||||||
|
fprintf(stderr, "Error initiating CFO\n");
|
||||||
|
goto clean_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = SRSLTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default CFO tolerance
|
|
||||||
srslte_sync_nbiot_set_cfo_tol(q, DEFAULT_CFO_TOL);
|
|
||||||
|
|
||||||
// initialize shift buffer for CFO estimation
|
|
||||||
q->shift_buffer = srslte_vec_malloc(SRSLTE_SF_LEN(q->fft_size) * sizeof(cf_t));
|
|
||||||
if (!q->shift_buffer) {
|
|
||||||
perror("malloc");
|
|
||||||
goto clean_exit;
|
|
||||||
}
|
|
||||||
srslte_cexptab_gen_sf(q->shift_buffer, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR, q->fft_size);
|
|
||||||
|
|
||||||
// allocate memory for early CFO estimation
|
|
||||||
q->cfo_output = srslte_vec_malloc(10 * SRSLTE_SF_LEN(q->fft_size) * sizeof(cf_t));
|
|
||||||
if (!q->cfo_output) {
|
|
||||||
perror("malloc");
|
|
||||||
goto clean_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure CP
|
|
||||||
q->cp = SRSLTE_CP_NORM;
|
|
||||||
q->cp_len = SRSLTE_CP_LEN_NORM(1, q->fft_size);
|
|
||||||
if (q->frame_size < q->fft_size) {
|
|
||||||
q->nof_symbols = 1;
|
|
||||||
} else {
|
|
||||||
q->nof_symbols = q->frame_size / (q->fft_size + q->cp_len) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (srslte_npss_synch_init(&q->npss, frame_size, fft_size)) {
|
|
||||||
fprintf(stderr, "Error initializing NPSS object\n");
|
|
||||||
return SRSLTE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (srslte_nsss_synch_init(&q->nsss, SRSLTE_NSSS_NUM_SF_DETECT * SRSLTE_SF_LEN_PRB_NBIOT, fft_size)) {
|
|
||||||
fprintf(stderr, "Error initializing NSSS object\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (srslte_cp_synch_init(&q->cp_synch, fft_size)) {
|
|
||||||
fprintf(stderr, "Error initiating CFO\n");
|
|
||||||
goto clean_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SRSLTE_SUCCESS;
|
|
||||||
|
|
||||||
clean_exit:
|
clean_exit:
|
||||||
if (ret == SRSLTE_ERROR) {
|
if (ret == SRSLTE_ERROR) {
|
||||||
srslte_sync_nbiot_free(q);
|
srslte_sync_nbiot_free(q);
|
||||||
|
@ -134,7 +137,7 @@ int srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32
|
||||||
|
|
||||||
if (frame_size > q->max_frame_size) {
|
if (frame_size > q->max_frame_size) {
|
||||||
fprintf(stderr, "Error in srslte_sync_nbiot_resize(): frame_size must be lower than initialized\n");
|
fprintf(stderr, "Error in srslte_sync_nbiot_resize(): frame_size must be lower than initialized\n");
|
||||||
return SRSLTE_ERROR;
|
return ret;
|
||||||
}
|
}
|
||||||
q->mean_cfo = 0;
|
q->mean_cfo = 0;
|
||||||
q->cfo_i = 0;
|
q->cfo_i = 0;
|
||||||
|
@ -147,21 +150,21 @@ int srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32
|
||||||
|
|
||||||
if (srslte_npss_synch_resize(&q->npss, max_offset, fft_size)) {
|
if (srslte_npss_synch_resize(&q->npss, max_offset, fft_size)) {
|
||||||
fprintf(stderr, "Error resizing PSS object\n");
|
fprintf(stderr, "Error resizing PSS object\n");
|
||||||
return SRSLTE_ERROR;
|
return ret;
|
||||||
}
|
}
|
||||||
if (srslte_nsss_synch_resize(&q->nsss, fft_size)) {
|
if (srslte_nsss_synch_resize(&q->nsss, fft_size)) {
|
||||||
fprintf(stderr, "Error resizing SSS object\n");
|
fprintf(stderr, "Error resizing SSS object\n");
|
||||||
return SRSLTE_ERROR;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srslte_cp_synch_resize(&q->cp_synch, fft_size)) {
|
if (srslte_cp_synch_resize(&q->cp_synch, fft_size)) {
|
||||||
fprintf(stderr, "Error resizing CFO\n");
|
fprintf(stderr, "Error resizing CFO\n");
|
||||||
return SRSLTE_ERROR;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srslte_cfo_resize(&q->cfocorr, q->frame_size)) {
|
if (srslte_cfo_resize(&q->cfocorr, q->frame_size)) {
|
||||||
fprintf(stderr, "Error resizing CFO\n");
|
fprintf(stderr, "Error resizing CFO\n");
|
||||||
return SRSLTE_ERROR;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update CFO tolerance
|
// Update CFO tolerance
|
||||||
|
@ -186,7 +189,7 @@ int srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32
|
||||||
srslte_sync_find_ret_t
|
srslte_sync_find_ret_t
|
||||||
srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset, uint32_t* peak_position)
|
srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset, uint32_t* peak_position)
|
||||||
{
|
{
|
||||||
srslte_sync_find_ret_t ret = SRSLTE_SYNC_ERROR;
|
srslte_sync_find_ret_t ret = SRSLTE_SYNC_NOFOUND;
|
||||||
|
|
||||||
int peak_pos = 0;
|
int peak_pos = 0;
|
||||||
if (peak_position) {
|
if (peak_position) {
|
||||||
|
@ -215,8 +218,6 @@ srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset
|
||||||
/* If peak is over threshold return success */
|
/* If peak is over threshold return success */
|
||||||
if (q->peak_value >= q->threshold) {
|
if (q->peak_value >= q->threshold) {
|
||||||
ret = SRSLTE_SYNC_FOUND;
|
ret = SRSLTE_SYNC_FOUND;
|
||||||
} else {
|
|
||||||
ret = SRSLTE_SYNC_NOFOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// estimate CFO after NPSS has been detected
|
// estimate CFO after NPSS has been detected
|
||||||
|
@ -278,7 +279,7 @@ void srslte_sync_nbiot_set_cfo_cand_test_enable(srslte_sync_nbiot_t* q, bool ena
|
||||||
q->enable_cfo_cand_test = enable;
|
q->enable_cfo_cand_test = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
int srslte_sync_nbiot_set_cfo_cand(srslte_sync_nbiot_t* q, float* cand, const int num)
|
int srslte_sync_nbiot_set_cfo_cand(srslte_sync_nbiot_t* q, const float* cand, const int num)
|
||||||
{
|
{
|
||||||
if (num > MAX_NUM_CFO_CANDITATES) {
|
if (num > MAX_NUM_CFO_CANDITATES) {
|
||||||
printf("Too many candidates, maximum is %d.\n", MAX_NUM_CFO_CANDITATES);
|
printf("Too many candidates, maximum is %d.\n", MAX_NUM_CFO_CANDITATES);
|
||||||
|
|
Loading…
Reference in New Issue