Commit 815a5719 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/define_c' into integration_2026_w03 (!3826)

Define speed of light

Common definition for speed of light constant, instead of multiple local
definitions
parents d456b190 d4e3c5d3
...@@ -100,4 +100,5 @@ ...@@ -100,4 +100,5 @@
// SDAP // SDAP
#define MAX_QOS_FLOWS 64 #define MAX_QOS_FLOWS 64
#define SPEED_OF_LIGHT 299792458 // in m/s
#endif /* __PLATFORM_CONSTANTS_H__ */ #endif /* __PLATFORM_CONSTANTS_H__ */
...@@ -48,8 +48,6 @@ void fix_ntn_epoch_hfn(PHY_VARS_NR_UE *UE, int hfn, int frame) ...@@ -48,8 +48,6 @@ void fix_ntn_epoch_hfn(PHY_VARS_NR_UE *UE, int hfn, int frame)
LOG_I(PHY, "setting epoch_hfn = %d\n", *epoch_hfn); LOG_I(PHY, "setting epoch_hfn = %d\n", *epoch_hfn);
} }
#define SPEED_OF_LIGHT 299792458
// calculate TA and Doppler based on the NTN-Config, if abs_subframe_tx < 0 then apply only Doppler // calculate TA and Doppler based on the NTN-Config, if abs_subframe_tx < 0 then apply only Doppler
void apply_ntn_timing_advance_and_doppler(PHY_VARS_NR_UE *UE, const NR_DL_FRAME_PARMS *fp, int abs_subframe_tx) void apply_ntn_timing_advance_and_doppler(PHY_VARS_NR_UE *UE, const NR_DL_FRAME_PARMS *fp, int abs_subframe_tx)
{ {
......
...@@ -462,8 +462,7 @@ void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, ...@@ -462,8 +462,7 @@ void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc,
// TS 38.104 - Table G.3-1 // TS 38.104 - Table G.3-1
uint16_t Dmin = 2; uint16_t Dmin = 2;
uint16_t Ds = 300; uint16_t Ds = 300;
double c = 299792458; double v = chan_desc->max_Doppler * ((double) SPEED_OF_LIGHT / (double)chan_desc->center_freq);
double v = chan_desc->max_Doppler * (c / (double)chan_desc->center_freq);
#ifdef DOPPLER_DEBUG #ifdef DOPPLER_DEBUG
printf("v = %f\n", v); printf("v = %f\n", v);
......
...@@ -1542,8 +1542,7 @@ static void nr_generate_Msg2(module_id_t module_idP, ...@@ -1542,8 +1542,7 @@ static void nr_generate_Msg2(module_id_t module_idP,
float T_c_ns = 0.509; float T_c_ns = 0.509;
int numerology = ul_bwp->scs; int numerology = ul_bwp->scs;
float rtt_ns = T_c_ns * 16 * 64 / (1 << numerology) * ra->timing_offset; float rtt_ns = T_c_ns * 16 * 64 / (1 << numerology) * ra->timing_offset;
float speed_of_light_in_meters_per_second = 299792458.0f; float distance_in_meters = (float) SPEED_OF_LIGHT * rtt_ns / 1000 / 1000 / 1000 / 2;
float distance_in_meters = speed_of_light_in_meters_per_second * rtt_ns / 1000 / 1000 / 1000 / 2;
LOG_A(NR_MAC, LOG_A(NR_MAC,
"UE %04x: %d.%d Generating RA-Msg2 DCI, RA RNTI 0x%x, state %d, preamble_index(RAPID) %d, " "UE %04x: %d.%d Generating RA-Msg2 DCI, RA RNTI 0x%x, state %d, preamble_index(RAPID) %d, "
"timing_offset = %d (estimated distance %.1f [m])\n", "timing_offset = %d (estimated distance %.1f [m])\n",
......
...@@ -65,7 +65,7 @@ void update_channel_model(channel_desc_t *channelDesc, uint64_t TS) ...@@ -65,7 +65,7 @@ void update_channel_model(channel_desc_t *channelDesc, uint64_t TS)
const double pos_ue_y = 0; const double pos_ue_y = 0;
const double pos_ue_z = radius_earth; const double pos_ue_z = radius_earth;
const double c = 299792458; // m/s const double c = (double) SPEED_OF_LIGHT;
if (channelDesc->is_uplink) { if (channelDesc->is_uplink) {
const double dir_ue_sat_x = pos_sat_x - pos_ue_x; const double dir_ue_sat_x = pos_sat_x - pos_ue_x;
......
...@@ -713,7 +713,7 @@ static int rfsimu_setdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt ...@@ -713,7 +713,7 @@ static int rfsimu_setdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt
rfsimulator_state_t *t = (rfsimulator_state_t *)arg; rfsimulator_state_t *t = (rfsimulator_state_t *)arg;
const double sample_rate = t->sample_rate; const double sample_rate = t->sample_rate;
const double c = 299792458; /* 3e8 */ const double c = (double) SPEED_OF_LIGHT;
const uint64_t new_offset = (double)distance * sample_rate / c; const uint64_t new_offset = (double)distance * sample_rate / c;
const double new_distance = (double)new_offset * c / sample_rate; const double new_distance = (double)new_offset * c / sample_rate;
...@@ -749,7 +749,7 @@ static int rfsimu_getdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt ...@@ -749,7 +749,7 @@ static int rfsimu_getdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt
rfsimulator_state_t *t = (rfsimulator_state_t *)arg; rfsimulator_state_t *t = (rfsimulator_state_t *)arg;
const double sample_rate = t->sample_rate; const double sample_rate = t->sample_rate;
const double c = 299792458; /* 3e8 */ const double c = (double) SPEED_OF_LIGHT;
for (int i = 0; i < MAX_FD_RFSIMU; i++) { for (int i = 0; i < MAX_FD_RFSIMU; i++) {
buffer_t *b = &t->buf[i]; buffer_t *b = &t->buf[i];
......
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