Commit 3231b0bc authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/ntn-phytest-mode' into integration_2025_w04 (!3192)

fix nr phy-test mode in ntn

Following SIB19 MR !3019 (merged), the phy-test mode is no longer working
In this MR we update the handling NTN-Config from ServingCellConfigCommon
to be the same as when NTN-Config is received in SIB19

More details: !3019 (comment 145103)
parents c0a0de3e 2924d18e
......@@ -246,6 +246,56 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac,
}
// computes delay between ue and sat based on SIB19 ephemeris data
static double calculate_ue_sat_ta(const position_t *position_params, NR_PositionVelocity_r17_t *sat_pos)
{
// get UE position coordinates
double posx = position_params->positionX;
double posy = position_params->positionY;
double posz = position_params->positionZ;
// get sat position coordinates
double posx_0 = (double)sat_pos->positionX_r17 * 1.3;
double posy_0 = (double)sat_pos->positionY_r17 * 1.3;
double posz_0 = (double)sat_pos->positionZ_r17 * 1.3;
double distance = sqrt(pow(posx - posx_0, 2) + pow(posy - posy_0, 2) + pow(posz - posz_0, 2));
// this computation will ensure 3 decimal precision
double ta_ms = round(((distance / SPEED_OF_LIGHT) * 1000) * 1000.0) / 1000.0;
return ta_ms;
}
// populate ntn_ta structure from mac
void configure_ntn_ta(module_id_t module_id, ntn_timing_advance_componets_t *ntn_ta, NR_NTN_Config_r17_t *ntn_Config_r17)
{
position_t position_params = {0};
get_position_coordinates(module_id, &position_params);
// if ephemerisInfo_r17 present in SIB19
NR_EphemerisInfo_r17_t *ephemeris_info = ntn_Config_r17->ephemerisInfo_r17;
if (ephemeris_info) {
NR_PositionVelocity_r17_t *position_velocity = ephemeris_info->choice.positionVelocity_r17;
if (position_velocity
&& (position_velocity->positionX_r17 != 0 || position_velocity->positionY_r17 != 0
|| position_velocity->positionZ_r17 != 0)) {
ntn_ta->N_UE_TA_adj = calculate_ue_sat_ta(&position_params, position_velocity);
}
}
// if cellSpecificKoffset_r17 is present
if (ntn_Config_r17->cellSpecificKoffset_r17) {
ntn_ta->cell_specific_k_offset = *ntn_Config_r17->cellSpecificKoffset_r17;
}
// Check if ta_Info_r17 is present and convert directly ta_Common_r17 (is in units of 4.072e-3 µs)
if (ntn_Config_r17->ta_Info_r17) {
ntn_ta->N_common_ta_adj = ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6;
// ta_CommonDrift_r17 (is in units of 0.2e-3 µs/s)
if (ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17)
ntn_ta->ntn_ta_commondrift = *ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17 * 0.2e-3;
}
ntn_ta->ntn_params_changed = true;
}
static void config_common_ue(NR_UE_MAC_INST_t *mac,
NR_ServingCellConfigCommon_t *scc,
int cc_idP)
......@@ -421,6 +471,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac,
// NTN Config
if (scc->ext2) {
UPDATE_IE(mac->sc_info.ntn_Config_r17, scc->ext2->ntn_Config_r17, NR_NTN_Config_r17_t);
configure_ntn_ta(mac->ue_id, &mac->ntn_ta, mac->sc_info.ntn_Config_r17);
} else {
asn1cFreeStruc(asn_DEF_NR_NTN_Config_r17, mac->sc_info.ntn_Config_r17);
}
......@@ -1750,64 +1801,18 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *si
AssertFatal(!ret, "mutex failed %d\n", ret);
}
// computes delay between ue and sat based on SIB19 ephemeris data
static double calculate_ue_sat_ta(const position_t *position_params, NR_PositionVelocity_r17_t *sat_pos)
{
// get UE position coordinates
double posx = position_params->positionX;
double posy = position_params->positionY;
double posz = position_params->positionZ;
// get sat position coordinates
double posx_0 = (double)sat_pos->positionX_r17 * 1.3;
double posy_0 = (double)sat_pos->positionY_r17 * 1.3;
double posz_0 = (double)sat_pos->positionZ_r17 * 1.3;
double distance = sqrt(pow(posx - posx_0, 2) + pow(posy - posy_0, 2) + pow(posz - posz_0, 2));
// this computation will ensure 3 decimal precision
double ta_ms = round(((distance / SPEED_OF_LIGHT) * 1000) * 1000.0) / 1000.0;
return ta_ms;
}
void nr_rrc_mac_config_other_sib(module_id_t module_id, NR_SIB19_r17_t *sib19)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
int ret = pthread_mutex_lock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
if (sib19) {
// update ntn_Config_r17 with received values
NR_NTN_Config_r17_t *ntn_Config_r17 = mac->sc_info.ntn_Config_r17;
UPDATE_IE(ntn_Config_r17, sib19->ntn_Config_r17, NR_NTN_Config_r17_t);
position_t position_params = {0};
get_position_coordinates(module_id, &position_params);
// populate ntn_ta structure from mac
// if ephemerisInfo_r17 present in SIB19
NR_EphemerisInfo_r17_t *ephemeris_info = ntn_Config_r17->ephemerisInfo_r17;
if (ephemeris_info) {
NR_PositionVelocity_r17_t *position_velocity = ephemeris_info->choice.positionVelocity_r17;
if (position_velocity
&& (position_velocity->positionX_r17 != 0
|| position_velocity->positionY_r17 != 0
|| position_velocity->positionZ_r17 != 0)) {
mac->ntn_ta.N_UE_TA_adj = calculate_ue_sat_ta(&position_params, position_velocity);
}
}
// if cellSpecificKoffset_r17 is present
if (ntn_Config_r17->cellSpecificKoffset_r17) {
mac->ntn_ta.cell_specific_k_offset = *ntn_Config_r17->cellSpecificKoffset_r17;
}
// Check if ta_Info_r17 is present and convert directly ta_Common_r17 (is in units of 4.072e-3 µs)
if (ntn_Config_r17->ta_Info_r17) {
mac->ntn_ta.N_common_ta_adj = ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6;
// ta_CommonDrift_r17 (is in units of 0.2e-3 µs/s)
if (ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17)
mac->ntn_ta.ntn_ta_commondrift = *ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17 * 0.2e-3;
}
mac->ntn_ta.ntn_params_changed = true;
configure_ntn_ta(mac->ue_id, &mac->ntn_ta, ntn_Config_r17);
}
ret = pthread_mutex_unlock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment