diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index e617b08172..2dce10d9dc 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -157,6 +157,8 @@ void init_nr_prs_ue_vars(PHY_VARS_NR_UE *ue) for (int j=0; jnb_antennas_rx; j++) { prs_vars[idx]->prs_resource[k].prs_meas[j] = malloc16_clear(sizeof(prs_meas_t)); AssertFatal((prs_vars[idx]->prs_resource[k].prs_meas[j]!=NULL), "%s: PRS measurements malloc failed for gNB_id %d, rx_ant %d\n", __FUNCTION__, idx, j); + prs_meas_t *m = prs_vars[idx]->prs_resource[k].prs_meas[j]; + m->next_dl_toa = m->dl_toa; } } } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 4151752f11..3af0937c48 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -73,7 +73,10 @@ void peak_estimator(c16_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t * void set_prs_dl_toa(prs_meas_t *prs_meas, float dl_toa) { - prs_meas->dl_toa = dl_toa; + *prs_meas->next_dl_toa++ = dl_toa; + if (prs_meas->next_dl_toa >= prs_meas->dl_toa + sizeofArray(prs_meas->dl_toa)) + prs_meas->next_dl_toa = prs_meas->dl_toa; + LOG_D(NR_PHY, "next_dl_toa %p\n", prs_meas->next_dl_toa); } int nr_prs_channel_estimation(uint8_t gNB_id, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index f4681020eb..b4d61d32f9 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -312,7 +312,9 @@ typedef struct { int32_t sfn; int8_t slot; int8_t rxAnt_idx; - float dl_toa; + // circular buffer to be able to read maximum of last estimations + float dl_toa[128]; // set through set_prs_dl_toa() + float *next_dl_toa; int32_t dl_aoa; float snr; float rsrp;