ms: use transceiver rssi measurements

AGC means the gain is unknown and therefore manually calculcating the
rssi does not work. Bladerf agc/rssi defaults are good enough, even
though a properly configured rssi fir would be better because at x4 gsm
rate the input bw is far too wide.

Change-Id: I5327181c20c1dead829f21600c93da4e94ba9263
This commit is contained in:
Eric Wild 2024-03-22 13:56:15 +01:00
parent 195813fd85
commit c0ef8e28f3
2 changed files with 25 additions and 16 deletions

View File

@ -382,6 +382,12 @@ struct blade_hw {
return atten;
};
int32_t get_transceiver_rssi() {
static int32_t pre_rssi, sym_rssi;
bladerf_get_rfic_rssi(dev, 0, &pre_rssi, &sym_rssi);
return sym_rssi;
}
static void check_timestamp(dev_buf_t *rcd)
{
static bool first = true;

View File

@ -160,11 +160,11 @@ static void *static_alloc(size_t newSize)
bool upper_trx::pullRadioVector(GSM::Time &wTime, int &RSSI, int &timingOffset)
{
float pow, avg = 1.0;
// float pow, avg = 1.0;
const auto zero_pad_len = 40; // give the VA some runway for misaligned bursts
const auto workbuf_size = zero_pad_len + ONE_TS_BURST_LEN + zero_pad_len;
static complex workbuf[workbuf_size];
static int32_t meas_p, meas_rssi;
static int32_t meas_rssi;
static signalVector sv(workbuf, zero_pad_len, ONE_TS_BURST_LEN, static_alloc, static_free);
one_burst e;
@ -184,8 +184,11 @@ bool upper_trx::pullRadioVector(GSM::Time &wTime, int &RSSI, int &timingOffset)
trxcon_phyif_rtr_ind i = { static_cast<uint32_t>(wTime.FN()), static_cast<uint8_t>(wTime.TN()) };
trxcon_phyif_rtr_rsp r = {};
trxcon_phyif_handle_rtr_ind(g_trxcon, &i, &r);
if (!(r.flags & TRXCON_PHYIF_RTR_F_ACTIVE))
if (!(r.flags & TRXCON_PHYIF_RTR_F_ACTIVE)) {
meas_rssi = get_transceiver_rssi();
// std::cerr << "G : \x1B[31m rx fail \033[0m @:" << meas_rssi << std::endl;
return false;
}
if (is_fcch) {
// return trash
@ -203,13 +206,13 @@ bool upper_trx::pullRadioVector(GSM::Time &wTime, int &RSSI, int &timingOffset)
if (use_va) {
convert_and_scale(ss, e.burst, ONE_TS_BURST_LEN * 2, 1.f / float(rxFullScale));
pow = energyDetect(sv, 20 * 4 /*sps*/);
if (pow < -1) {
LOG(ALERT) << "Received empty burst";
return false;
}
// pow = energyDetect(sv, 20 * 4 /*sps*/);
// if (pow < -1) {
// LOG(ALERT) << "Received empty burst";
// return false;
// }
avg = sqrt(pow);
// avg = sqrt(pow);
{
float ncmax;
std::complex<float> chan_imp_resp[CHAN_IMP_RESP_LENGTH * d_OSR];
@ -238,14 +241,14 @@ bool upper_trx::pullRadioVector(GSM::Time &wTime, int &RSSI, int &timingOffset)
// lower layer sch detection offset, easy to verify by just printing the detected value using both the va+sigproc code.
convert_and_scale(ss + 16, e.burst, ONE_TS_BURST_LEN * 2, 15);
// pow = energyDetect(sv, 20 * 4 /*sps*/);
// if (pow < -1) {
// LOG(ALERT) << "Received empty burst";
// return false;
// }
pow = energyDetect(sv, 20 * 4 /*sps*/);
if (pow < -1) {
LOG(ALERT) << "Received empty burst";
return false;
}
// avg = sqrt(pow);
avg = sqrt(pow);
/* Detect normal or RACH bursts */
CorrType type = CorrType::TSC;
struct estim_burst_params ebp;
@ -268,7 +271,7 @@ bool upper_trx::pullRadioVector(GSM::Time &wTime, int &RSSI, int &timingOffset)
}
delete bits;
}
RSSI = (int)floor(20.0 * log10(rxFullScale / avg));
RSSI = meas_rssi; // (int)floor(20.0 * log10(rxFullScale / avg));
// FIXME: properly handle offset, sch/nb alignment diff? handled by lower anyway...
timingOffset = (int)round(0);