bts: Add timing offset tolerance module parameter to support real HW

When we don't use trxcon (ie we run real HW) we need to relax template
matching when we receive UL measurements in that case.

Change-Id: Icf1d2216d29c1ebf68c672e6ca06c54a7457304b
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 809a403..a74b3fe 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -51,11 +51,14 @@
 	charstring mp_bb_trxc_ip := "127.0.0.1";
 	integer mp_bb_trxc_port := 6701;
 	charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
-	integer mp_tolerance_rxqual := 1;
-	integer mp_tolerance_rxlev := 3;
 	charstring mp_ctrl_ip := "127.0.0.1";
 	integer mp_ctrl_port := 4238;
+	integer mp_tolerance_rxqual := 1;
+	integer mp_tolerance_rxlev := 3;
+	integer mp_tolerance_timing_offset_256syms := 0;
 	integer mp_rxlev_exp := 57;
+	integer mp_ms_actual_ta_exp := 0;
+	integer mp_timing_offset_256syms_exp := 512;
 }
 
 type record of RslChannelNr ChannelNrs;
@@ -521,10 +524,10 @@
 				rxqual := 0
 			}
 		},
-		timing_offset_256syms := 0,
+		timing_offset_256syms := mp_timing_offset_256syms_exp,
 		bs_power_level := 0,
 		ms_power_level := 0,
-		ms_actual_ta := 0
+		ms_actual_ta := mp_ms_actual_ta_exp
 	},
 	spec := omit,
 	encr := omit
@@ -1258,7 +1261,7 @@
 	if (l1p.toa256_enabled) {
 		ul_meas.len := (3+8);
 		ul_meas.supp_meas_info := {
-			toa256_mean := l1p.timing_offset_256syms,
+			toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
 			toa256_min := ?,
 			toa256_max := ?,
 			toa256_std_dev := ?
@@ -1279,10 +1282,10 @@
 		ms_power_lvl := l1p.ms_power_level,
 		fpc := false,
 		reserved := 0,
-		actual_ta := l1p.ms_actual_ta
+		actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
 	};
 	var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
-	var template uint8_t t_toffs := (offs-1 .. offs+1);	 /* some tolerance */
+	var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
 	return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
 				    ?, t_toffs);
 }
@@ -1399,17 +1402,12 @@
 	f_l1_tune(L1CTL);
 	RSL.clear;
 
-	if (mp_bb_trxc_port != -1) {
-		g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100);
-		f_trxc_fake_rssi(100);
-
-		g_pars.l1_pars.timing_offset_256syms := 512; /* 2 symbols */
-		f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
-	} else {
-		g_pars.l1_pars.timing_offset_256syms := 0; /* FIXME */
-		g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-55); /* FIXME */
-	}
+	g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100);
 	g_pars.l1_pars.meas_ul.sub.rxlev := g_pars.l1_pars.meas_ul.full.rxlev;
+	if (mp_bb_trxc_port != -1) {
+		f_trxc_fake_rssi(100);
+		f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
+	}
 
 	f_est_dchan();