|
|
|
@ -45,8 +45,8 @@ namespace srsue {
|
|
|
|
|
static int
|
|
|
|
|
radio_recv_callback(void* obj, cf_t* data[SRSLTE_MAX_CHANNELS], uint32_t nsamples, srslte_timestamp_t* rx_time)
|
|
|
|
|
{
|
|
|
|
|
srslte::rf_buffer_t x(data);
|
|
|
|
|
return ((sync*)obj)->radio_recv_fnc(x, nsamples, rx_time);
|
|
|
|
|
srslte::rf_buffer_t x(data, nsamples);
|
|
|
|
|
return ((sync*)obj)->radio_recv_fnc(x, rx_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SRSLTE_AGC_CALLBACK(callback_set_rx_gain)
|
|
|
|
@ -501,12 +501,13 @@ void sync::run_idle_state()
|
|
|
|
|
{
|
|
|
|
|
if (radio_h->is_init()) {
|
|
|
|
|
uint32_t nsamples = 1920;
|
|
|
|
|
if (current_srate > 0) {
|
|
|
|
|
if (std::isnormal(current_srate) and current_srate > 0.0f) {
|
|
|
|
|
nsamples = current_srate / 1000;
|
|
|
|
|
}
|
|
|
|
|
Debug("Discarding %d samples\n", nsamples);
|
|
|
|
|
srslte_timestamp_t rx_time = {};
|
|
|
|
|
if (radio_recv_fnc(dummy_buffer, nsamples, &rx_time) == SRSLTE_SUCCESS) {
|
|
|
|
|
dummy_buffer.set_nof_samples(nsamples);
|
|
|
|
|
if (radio_recv_fnc(dummy_buffer, &rx_time) == SRSLTE_SUCCESS) {
|
|
|
|
|
log_h->console("SYNC: Receiving from radio while in IDLE_RX\n");
|
|
|
|
|
}
|
|
|
|
|
// If radio is in locked state returns immediately. In that case, do a 1 ms sleep
|
|
|
|
@ -803,7 +804,7 @@ void sync::get_current_cell(srslte_cell_t* cell_, uint32_t* earfcn_)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int sync::radio_recv_fnc(srslte::rf_buffer_t& data, uint32_t nsamples, srslte_timestamp_t* rx_time)
|
|
|
|
|
int sync::radio_recv_fnc(srslte::rf_buffer_t& data, srslte_timestamp_t* rx_time)
|
|
|
|
|
{
|
|
|
|
|
// This function is designed for being called from the UE sync object which will pass a null rx_time in case
|
|
|
|
|
// receive dummy samples. So, rf_timestamp points at dummy timestamp in case rx_time is not provided
|
|
|
|
@ -811,7 +812,10 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, uint32_t nsamples, srslte_ti
|
|
|
|
|
srslte::rf_timestamp_t& rf_timestamp = (rx_time == nullptr) ? dummy_ts : last_rx_time;
|
|
|
|
|
|
|
|
|
|
// Receive
|
|
|
|
|
if (radio_h->rx_now(data, nsamples, rf_timestamp)) {
|
|
|
|
|
if (not radio_h->rx_now(data, rf_timestamp)) {
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte_timestamp_t dummy_flat_ts = {};
|
|
|
|
|
|
|
|
|
|
// Load flat timestamp
|
|
|
|
@ -854,9 +858,9 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, uint32_t nsamples, srslte_ti
|
|
|
|
|
// update timestamp
|
|
|
|
|
srslte_timestamp_copy(&tti_ts, rx_time);
|
|
|
|
|
|
|
|
|
|
if (channel_emulator && rx_time) {
|
|
|
|
|
if (channel_emulator and rx_time) {
|
|
|
|
|
channel_emulator->set_srate((uint32_t)current_srate);
|
|
|
|
|
channel_emulator->run(data.to_cf_t(), data.to_cf_t(), nsamples, *rx_time);
|
|
|
|
|
channel_emulator->run(data.to_cf_t(), data.to_cf_t(), data.get_nof_samples(), *rx_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save signal for Intra-frequency measurement
|
|
|
|
@ -869,12 +873,9 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, uint32_t nsamples, srslte_ti
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_h->debug("SYNC: received %d samples from radio\n", nsamples);
|
|
|
|
|
log_h->debug("SYNC: received %d samples from radio\n", data.get_nof_samples());
|
|
|
|
|
|
|
|
|
|
return nsamples;
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return data.get_nof_samples();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sync::set_rx_gain(float gain)
|
|
|
|
|