summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-12-18 06:21:23 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-01-02 12:23:07 +0100
commit5caa4ac9661db3e16275307a8baeb05613b574fc (patch)
treec1ea6b6a571f9301bc7d9d06a0d250397ceca91e
parent684fa75b4926bf9f0ce31e353357fd937fd49c38 (diff)
trxcon/scheduler: fix RSSI -> RX level conversion
Due to a mistake, average RSSI value of received bursts was not converted to GSM RX level (range 0..63), so trxcon has been sending incorrect values to the higher layers. Let's fix this, and also prevent possible division by zero. Change-Id: Id4659de899411ec1ba1718fdcb40aec562dbfd65
-rw-r--r--src/host/trxcon/sched_lchan_common.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/host/trxcon/sched_lchan_common.c b/src/host/trxcon/sched_lchan_common.c
index 95e496b..540a57f 100644
--- a/src/host/trxcon/sched_lchan_common.c
+++ b/src/host/trxcon/sched_lchan_common.c
@@ -87,6 +87,7 @@ int sched_send_dt_ind(struct trx_instance *trx, struct trx_ts *ts,
{
const struct trx_lchan_desc *lchan_desc;
struct l1ctl_info_dl dl_hdr;
+ int dbm_avg;
/* Set up pointers */
lchan_desc = &trx_lchan_desc[lchan->type];
@@ -96,9 +97,18 @@ int sched_send_dt_ind(struct trx_instance *trx, struct trx_ts *ts,
dl_hdr.link_id = lchan_desc->link_id;
dl_hdr.band_arfcn = htons(trx->band_arfcn);
dl_hdr.frame_nr = htonl(lchan->rx_first_fn);
- dl_hdr.rx_level = -(lchan->meas.rssi_sum / lchan->meas.rssi_num);
dl_hdr.num_biterr = bit_error_count;
+ /* Convert average RSSI to RX level */
+ if (lchan->meas.rssi_num) {
+ /* RX level: 0 .. 63 in typical GSM notation (dBm + 110) */
+ dbm_avg = lchan->meas.rssi_sum / lchan->meas.rssi_num;
+ dl_hdr.rx_level = dbm2rxlev(dbm_avg);
+ } else {
+ /* No measurements, assuming the worst */
+ dl_hdr.rx_level = 0;
+ }
+
/* FIXME: set proper values */
dl_hdr.snr = 0;