Added SIB19 related calculations on UE

This commit is contained in:
Roberto Rosca
2024-12-11 10:20:34 +02:00
parent 06c0374ec8
commit 698ff73c7f
3 changed files with 39 additions and 31 deletions
+35 -5
View File
@@ -31,6 +31,7 @@
*/
#define _GNU_SOURCE
#define SPEED_OF_LIGHT 299792458
//#include "mac_defs.h"
#include <NR_MAC_gNB/mac_proto.h>
@@ -41,6 +42,7 @@
#include "executables/softmodem-common.h"
#include "SCHED_NR/phy_frame_config_nr.h"
#include "oai_asn1.h"
#include "executables/position_interface.h"
void set_tdd_config_nr_ue(fapi_nr_tdd_table_t *tdd_table,
int mu,
@@ -1746,15 +1748,43 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id,
AssertFatal(!ret, "mutex failed %d\n", ret);
}
void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id,
NR_SIB19_r17_t *sib19_r17)
// computes delay between ue and sat based on SIB19 ephemeris data
static double calculate_ue_sat_ta(position_t *position_params, struct NR_PositionVelocity_r17 *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_req_sib19_r17(module_id_t module_id, NR_SIB19_r17_t *sib19_r17)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
// ntn-Config-r17
UPDATE_IE(mac->sc_info.ntn_Config_r17, sib19_r17->ntn_Config_r17, NR_NTN_Config_r17_t);
// ntn-Config-r17 deep copy into mac
asn_copy(&asn_DEF_NR_NTN_Config_r17, (void **)&mac->sc_info.ntn_Config_r17, sib19_r17->ntn_Config_r17);
// TODO handle other SIB19 elements
// if ephemerisInfo_r17 present in SIB19
if (mac->sc_info.ntn_Config_r17->ephemerisInfo_r17 && mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17
&& (mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionX_r17 != 0
|| mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionY_r17 != 0
|| mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17->positionZ_r17 != 0)) {
get_nrUE_params()->ntn_ta_common =
calculate_ue_sat_ta(get_position(module_id), mac->sc_info.ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17);
}
get_nrUE_params()->ntn_koffset = *mac->sc_info.ntn_Config_r17->cellSpecificKoffset_r17;
}
static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac,
-23
View File
@@ -86,29 +86,6 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac)
mac->pucch_power_control_initialized = false;
mac->pusch_power_control_initialized = false;
// Fake SIB19 reception for NTN
// TODO: remove this and implement the actual SIB19 reception instead!
if (get_nrUE_params()->ntn_koffset || get_nrUE_params()->ntn_ta_common || get_nrUE_params()->ntn_ta_commondrift) {
NR_SIB19_r17_t *sib19_r17 = calloc(1, sizeof(*sib19_r17));
sib19_r17->ntn_Config_r17 = calloc(1, sizeof(*sib19_r17->ntn_Config_r17));
// NTN cellSpecificKoffset-r17
if (get_nrUE_params()->ntn_koffset) {
asn1cCallocOne(sib19_r17->ntn_Config_r17->cellSpecificKoffset_r17, get_nrUE_params()->ntn_koffset);
}
// NTN ta-Common-r17
if (get_nrUE_params()->ntn_ta_common || get_nrUE_params()->ntn_ta_commondrift) {
sib19_r17->ntn_Config_r17->ta_Info_r17 = calloc(1, sizeof(*sib19_r17->ntn_Config_r17->ta_Info_r17));
sib19_r17->ntn_Config_r17->ta_Info_r17->ta_Common_r17 = get_nrUE_params()->ntn_ta_common / 4.072e-6; // ta-Common-r17 is in units of 4.072e-3 µs, ntn_ta_common is in ms
if (get_nrUE_params()->ntn_ta_commondrift)
asn1cCallocOne(sib19_r17->ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17, get_nrUE_params()->ntn_ta_commondrift / 0.2e-3); // is in units of 0.2e-3 µs/s, ntn_ta_commondrift is in µs/s
}
nr_rrc_mac_config_req_sib19_r17(mac->ue_id, sib19_r17);
asn1cFreeStruc(asn_DEF_NR_SIB19_r17, sib19_r17);
}
}
void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
+4 -3
View File
@@ -165,7 +165,7 @@ static void set_DRB_status(NR_UE_RRC_INST_t *rrc, NR_DRB_Identity_t drb_id, NR_R
rrc->status_DRBs[drb_id - 1] = status;
}
static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si)
static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si, instance_t ue_id)
{
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN);
@@ -241,6 +241,7 @@ static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si)
SI_info->SInfo_r17.sib19_validity = true;
if (g_log->log_component[NR_RRC].level >= OAILOG_DEBUG)
xer_fprint(stdout, &asn_DEF_NR_SIB19_r17, (const void *)typeandinfo->choice.sib19_v1700);
nr_rrc_mac_config_req_sib19_r17(ue_id, typeandinfo->choice.sib19_v1700);
nr_timer_start(&SI_info->SInfo_r17.sib19_timer);
break;
default:
@@ -386,7 +387,7 @@ static void nr_rrc_process_reconfiguration_v1530(NR_UE_RRC_INST_t *rrc, NR_RRCRe
SEQUENCE_free(&asn_DEF_NR_SystemInformation, si, 1);
} else {
LOG_I(NR_RRC, "[UE %ld] Decoding dedicatedSystemInformationDelivery\n", rrc->ue_id);
nr_decode_SI(SI_info, si);
nr_decode_SI(SI_info, si, rrc->ue_id);
}
}
if (rec_1530->otherConfig) {
@@ -895,7 +896,7 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(NR_UE_RRC_INST_t *rrc,
case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformation:
LOG_I(NR_RRC, "[UE %ld] Decoding SI\n", rrc->ue_id);
NR_SystemInformation_t *si = bcch_message->message.choice.c1->choice.systemInformation;
nr_decode_SI(SI_info, si);
nr_decode_SI(SI_info, si, rrc->ue_id);
break;
case NR_BCCH_DL_SCH_MessageType__c1_PR_NOTHING:
default: