|
|
@ -75,7 +75,7 @@ void prach::init(LIBLTE_RRC_PRACH_CONFIG_SIB_STRUCT *config_, uint32_t max_prb,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
srslte_cfo_set_tol(&cfo_h, 0);
|
|
|
|
srslte_cfo_set_tol(&cfo_h, 0);
|
|
|
|
signal_buffer = (cf_t *) srslte_vec_malloc(SRSLTE_PRACH_MAX_LEN * sizeof(cf_t));
|
|
|
|
signal_buffer = (cf_t *) srslte_vec_malloc(MAX_LEN_SF * 30720 * sizeof(cf_t));
|
|
|
|
if (!signal_buffer) {
|
|
|
|
if (!signal_buffer) {
|
|
|
|
perror("malloc");
|
|
|
|
perror("malloc");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -159,10 +159,10 @@ bool prach::is_pending() {
|
|
|
|
bool prach::is_ready_to_send(uint32_t current_tti_) {
|
|
|
|
bool prach::is_ready_to_send(uint32_t current_tti_) {
|
|
|
|
if (is_pending()) {
|
|
|
|
if (is_pending()) {
|
|
|
|
// consider the number of subframes the transmission must be anticipated
|
|
|
|
// consider the number of subframes the transmission must be anticipated
|
|
|
|
uint32_t current_tti = (current_tti_ + tx_advance_sf)%10240;
|
|
|
|
uint32_t tti_tx = TTI_TX(current_tti_);
|
|
|
|
if (srslte_prach_tti_opportunity(&prach_obj, current_tti, allowed_subframe)) {
|
|
|
|
if (srslte_prach_tti_opportunity(&prach_obj, tti_tx, allowed_subframe)) {
|
|
|
|
Debug("PRACH Buffer: Ready to send at tti: %d (now is %d)\n", current_tti, current_tti_);
|
|
|
|
Debug("PRACH Buffer: Ready to send at tti: %d (now is %d)\n", tti_tx, current_tti_);
|
|
|
|
transmitted_tti = current_tti;
|
|
|
|
transmitted_tti = tti_tx;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -173,55 +173,31 @@ int prach::tx_tti() {
|
|
|
|
return transmitted_tti;
|
|
|
|
return transmitted_tti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float prach::get_p0_preamble()
|
|
|
|
cf_t *prach::generate(float cfo, uint32_t *nof_sf, float *target_power) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return target_power_dbm;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void prach::send(srslte::radio *radio_handler, float cfo, float pathloss, srslte_timestamp_t tx_time)
|
|
|
|
if (cell_initiated && preamble_idx >= 0 && nof_sf) {
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get current TX gain
|
|
|
|
|
|
|
|
float old_gain = radio_handler->get_tx_gain();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Correct CFO before transmission FIXME: UL SISO Only
|
|
|
|
// Correct CFO before transmission FIXME: UL SISO Only
|
|
|
|
srslte_cfo_correct(&cfo_h, buffer[preamble_idx], signal_buffer, cfo / srslte_symbol_sz(cell.nof_prb));
|
|
|
|
srslte_cfo_correct(&cfo_h, buffer[preamble_idx], signal_buffer, cfo / srslte_symbol_sz(cell.nof_prb));
|
|
|
|
|
|
|
|
|
|
|
|
// If power control is enabled, choose amplitude and power
|
|
|
|
// pad guard symbols with zeros
|
|
|
|
if (args->ul_pwr_ctrl_en) {
|
|
|
|
uint32_t nsf = (len-1)/SRSLTE_SF_LEN_PRB(cell.nof_prb)+1;
|
|
|
|
// Get PRACH transmission power
|
|
|
|
bzero(&signal_buffer[len], (nsf*SRSLTE_SF_LEN_PRB(cell.nof_prb)-len)*sizeof(cf_t));
|
|
|
|
float tx_power = SRSLTE_MIN(SRSLTE_PC_MAX, pathloss + target_power_dbm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get output power for amplitude 1
|
|
|
|
|
|
|
|
radio_handler->set_tx_power(tx_power);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Scale signal
|
|
|
|
*nof_sf = nsf;
|
|
|
|
float digital_power = srslte_vec_avg_power_cf(signal_buffer, len);
|
|
|
|
|
|
|
|
float scale = sqrtf(pow(10,tx_power/10)/digital_power);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srslte_vec_sc_prod_cfc(signal_buffer, scale, signal_buffer, len);
|
|
|
|
if (target_power) {
|
|
|
|
log_h->console("PRACH: Pathloss=%.2f dB, Target power %.2f dBm, TX_power %.2f dBm, TX_gain %.1f dB, scale %.2f\n",
|
|
|
|
*target_power = target_power_dbm;
|
|
|
|
pathloss, target_power_dbm, tx_power, radio_handler->get_tx_gain(), scale);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
float prach_gain = args->prach_gain;
|
|
|
|
|
|
|
|
if (prach_gain > 0) {
|
|
|
|
|
|
|
|
radio_handler->set_tx_gain(prach_gain);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug("TX PRACH: Power control for PRACH is disabled, setting gain to %.0f dB\n", prach_gain);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *tmp_buffer[SRSLTE_MAX_PORTS] = {signal_buffer, NULL, NULL, NULL};
|
|
|
|
Info("PRACH: Transmitted preamble=%d, CFO=%.2f KHz, nof_sf=%d, target_power=%.1f dBm\n",
|
|
|
|
radio_handler->tx(tmp_buffer, len, tx_time);
|
|
|
|
preamble_idx, cfo*15, nsf, target_power_dbm);
|
|
|
|
radio_handler->tx_end();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Info("PRACH: Transmitted preamble=%d, CFO=%.2f KHz, tx_time=%f\n",
|
|
|
|
|
|
|
|
preamble_idx, cfo*15, tx_time.frac_secs);
|
|
|
|
|
|
|
|
preamble_idx = -1;
|
|
|
|
preamble_idx = -1;
|
|
|
|
|
|
|
|
|
|
|
|
radio_handler->set_tx_gain(old_gain);
|
|
|
|
return signal_buffer;
|
|
|
|
Debug("Restoring TX gain to %.0f dB\n", old_gain);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace srsue
|
|
|
|
} // namespace srsue
|
|
|
|