Unpack MIB to update MIB

master
Xavier Arteaga 3 years ago
parent ae0fb4f4fc
commit 65255ecb4e

@ -120,19 +120,12 @@ static void ue_sync_nr_apply_feedback(srsran_ue_sync_nr_t* q)
ue_sync_nr_reset_feedback(q);
}
static int ue_sync_nr_run_find(srsran_ue_sync_nr_t* q, cf_t* buffer)
static int ue_sync_nr_update_ssb(srsran_ue_sync_nr_t* q,
const srsran_csi_trs_measurements_t* measurements,
const srsran_pbch_msg_nr_t* pbch_msg)
{
srsran_csi_trs_measurements_t measurements = {};
srsran_pbch_msg_nr_t pbch_msg = {};
// Find SSB, measure PSS/SSS and decode PBCH
if (srsran_ssb_find(&q->ssb, buffer, q->N_id, &measurements, &pbch_msg) < SRSRAN_SUCCESS) {
ERROR("Error finding SSB");
return SRSRAN_ERROR;
}
// If the PBCH message was NOT decoded, early return
if (!pbch_msg.crc) {
srsran_mib_nr_t mib = {};
if (srsran_pbch_msg_nr_mib_unpack(pbch_msg, &mib) != SRSRAN_SUCCESS) {
return SRSRAN_SUCCESS;
}
@ -140,24 +133,43 @@ static int ue_sync_nr_run_find(srsran_ue_sync_nr_t* q, cf_t* buffer)
ue_sync_nr_reset_feedback(q);
// Set feedback measurement
srsran_combine_csi_trs_measurements(&q->feedback, &measurements, &q->feedback);
srsran_combine_csi_trs_measurements(&q->feedback, measurements, &q->feedback);
// Apply feedback
ue_sync_nr_apply_feedback(q);
// Setup context
q->ssb_idx = pbch_msg.ssb_idx;
q->sf_idx = srsran_ssb_candidate_sf_idx(&q->ssb, pbch_msg.ssb_idx, pbch_msg.hrf);
q->sfn = pbch_msg.sfn_4lsb;
q->ssb_idx = pbch_msg->ssb_idx;
q->sf_idx = srsran_ssb_candidate_sf_idx(&q->ssb, pbch_msg->ssb_idx, pbch_msg->hrf);
q->sfn = mib.sfn;
// Transition to track only if the measured delay is below 2.4 microseconds
if (measurements.delay_us < 2.4f) {
if (measurements->delay_us < 2.4f) {
q->state = SRSRAN_UE_SYNC_NR_STATE_TRACK;
}
return SRSRAN_SUCCESS;
}
static int ue_sync_nr_run_find(srsran_ue_sync_nr_t* q, cf_t* buffer)
{
srsran_csi_trs_measurements_t measurements = {};
srsran_pbch_msg_nr_t pbch_msg = {};
// Find SSB, measure PSS/SSS and decode PBCH
if (srsran_ssb_find(&q->ssb, buffer, q->N_id, &measurements, &pbch_msg) < SRSRAN_SUCCESS) {
ERROR("Error finding SSB");
return SRSRAN_ERROR;
}
// If the PBCH message was NOT decoded, early return
if (!pbch_msg.crc) {
return SRSRAN_SUCCESS;
}
return ue_sync_nr_update_ssb(q, &measurements, &pbch_msg);
}
static int ue_sync_nr_run_track(srsran_ue_sync_nr_t* q, cf_t* buffer)
{
srsran_csi_trs_measurements_t measurements = {};
@ -173,27 +185,23 @@ static int ue_sync_nr_run_track(srsran_ue_sync_nr_t* q, cf_t* buffer)
is_ssb_opportunity = is_ssb_opportunity && (half_frame == 0) && (q->sfn % q->ssb.cfg.periodicity_ms / 10 == 0);
}
if (is_ssb_opportunity) {
// Measure PSS/SSS and decode PBCH
if (srsran_ssb_track(&q->ssb, buffer, q->N_id, q->ssb_idx, half_frame, &measurements, &pbch_msg) < SRSRAN_SUCCESS) {
ERROR("Error finding SSB");
return SRSRAN_ERROR;
}
// If the PBCH message was NOT decoded, transition to find
if (!pbch_msg.crc) {
q->state = SRSRAN_UE_SYNC_NR_STATE_FIND;
return SRSRAN_SUCCESS;
}
if (!is_ssb_opportunity) {
return SRSRAN_SUCCESS;
}
// Otherwise feedback measurements and apply
srsran_combine_csi_trs_measurements(&q->feedback, &measurements, &q->feedback);
// Measure PSS/SSS and decode PBCH
if (srsran_ssb_track(&q->ssb, buffer, q->N_id, q->ssb_idx, half_frame, &measurements, &pbch_msg) < SRSRAN_SUCCESS) {
ERROR("Error finding SSB");
return SRSRAN_ERROR;
}
// Apply accumulated feedback
ue_sync_nr_apply_feedback(q);
// If the PBCH message was NOT decoded, transition to find
if (!pbch_msg.crc) {
q->state = SRSRAN_UE_SYNC_NR_STATE_FIND;
return SRSRAN_SUCCESS;
}
return SRSRAN_SUCCESS;
return ue_sync_nr_update_ssb(q, &measurements, &pbch_msg);
}
static int ue_sync_nr_recv(srsran_ue_sync_nr_t* q, cf_t** buffer, srsran_timestamp_t* timestamp)

Loading…
Cancel
Save