aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmr1_rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmr1_rx.c')
-rw-r--r--src/gmr1_rx.c94
1 files changed, 85 insertions, 9 deletions
diff --git a/src/gmr1_rx.c b/src/gmr1_rx.c
index f064d81..8928977 100644
--- a/src/gmr1_rx.c
+++ b/src/gmr1_rx.c
@@ -42,6 +42,7 @@
#include <osmocom/gmr1/l1/interleave.h>
#include <osmocom/gmr1/l1/tch3.h>
#include <osmocom/gmr1/l1/tch9.h>
+#include <osmocom/gmr1/l1/xch_dc12.h>
#include <osmocom/gmr1/sdr/defs.h>
#include <osmocom/gmr1/sdr/dkab.h>
#include <osmocom/gmr1/sdr/fcch.h>
@@ -54,7 +55,7 @@
static struct gsmtap_inst *g_gti;
-static const struct gmr1_fcch_burst *fcch_type = &gmr1_fcch_burst;
+static const struct gmr1_fcch_burst *fcch_type = &gmr1_fcch3_lband_burst;
struct tch3_state {
@@ -679,6 +680,7 @@ fcch_multi_process(struct chan_desc *cd, fcch_multi_cb_t cb)
}
/* Compute SNR (comparing energy with neighboring CICH) */
+#if 0
win_map(win, cd->bcch,
base_align + mtoa[i] + toa + 5 * cd->sps,
(117 - 10) * cd->sps
@@ -694,6 +696,17 @@ fcch_multi_process(struct chan_desc *cd, fcch_multi_cb_t cb)
e_cich = burst_energy(win);
snr = e_fcch / e_cich;
+#else
+ win_map(win, cd->bcch,
+ base_align + mtoa[i] + toa,
+ fcch_type->len * cd->sps
+ );
+
+ rv = gmr1_fcch_snr(fcch_type, win, cd->sps, -(cd->freq_err + freq_err), &snr);
+ if (rv) {
+ fprintf(stderr, "[!] Error during FCCH SNR estimation (%d)\n", rv);
+ }
+#endif
/* Check against strongest */
if (i==0) {
@@ -746,7 +759,7 @@ static int
rx_bcch(struct chan_desc *cd, float *energy)
{
struct osmo_cxvec _burst, *burst = &_burst;
- sbit_t ebits[424];
+ sbit_t ebits[432];
uint8_t l2[24];
float freq_err, toa;
int rv, crc, conv, e_toa;
@@ -755,12 +768,14 @@ rx_bcch(struct chan_desc *cd, float *energy)
fprintf(stderr, "[.] BCCH\n");
/* Demodulate burst */
- e_toa = burst_map(burst, cd, &gmr1_bcch_burst, cd->sa_bcch_stn, 20 * cd->sps, 0);
+ e_toa = burst_map(burst, cd, &gmr1_dc12_burst, cd->sa_bcch_stn, 20 * cd->sps, 0);
if (e_toa < 0)
return e_toa;
+ osmo_cxvec_dbg_dump(burst, "/tmp/dbg_burst.cfile");
+
rv = gmr1_pi4cxpsk_demod(
- &gmr1_bcch_burst,
+ &gmr1_dc12_burst,
burst, cd->sps, -cd->freq_err,
ebits, NULL, &toa, &freq_err
);
@@ -773,7 +788,7 @@ rx_bcch(struct chan_desc *cd, float *energy)
*energy = burst_energy(burst);
/* Decode burst */
- crc = gmr1_bcch_decode(l2, ebits, &conv);
+ crc = gmr1_xch_dc12_decode(l2, ebits, &conv);
fprintf(stderr, "crc=%d, conv=%d\n", crc, conv);
@@ -805,7 +820,7 @@ rx_ccch(struct chan_desc *cd, float min_energy)
int rv, crc, conv, e_toa;
/* Map potential burst */
- e_toa = burst_map(burst, cd, &gmr1_dc6_burst, cd->sa_bcch_stn, 10 * cd->sps, 0);
+ e_toa = burst_map(burst, cd, &gmr1_dc12_burst, cd->sa_bcch_stn, 10 * cd->sps, 0);
if (e_toa < 0)
return e_toa;
@@ -818,7 +833,7 @@ rx_ccch(struct chan_desc *cd, float min_energy)
/* Demodulate burst */
rv = gmr1_pi4cxpsk_demod(
- &gmr1_dc6_burst,
+ &gmr1_dc12_burst,
burst, cd->sps, -cd->freq_err,
ebits, NULL, NULL, NULL
);
@@ -827,7 +842,7 @@ rx_ccch(struct chan_desc *cd, float min_energy)
return rv;
/* Decode burst */
- crc = gmr1_ccch_decode(l2, ebits, &conv);
+ crc = gmr1_xch_dc12_decode(l2, ebits, &conv);
fprintf(stderr, "crc=%d, conv=%d\n", crc, conv);
@@ -849,6 +864,64 @@ rx_ccch(struct chan_desc *cd, float min_energy)
}
static int
+rx_cbch(struct chan_desc *cd, float min_energy)
+{
+ struct osmo_cxvec _burst, *burst = &_burst;
+ sbit_t ebits[432];
+ uint8_t l2[24];
+ int rv, crc, conv, e_toa;
+
+ /* Map potential burst */
+ e_toa = burst_map(burst, cd, &gmr1_dc12_burst, cd->sa_bcch_stn + 12, 10 * cd->sps, 0);
+ if (e_toa < 0)
+ return e_toa;
+
+ /* Energy detection */
+ if (burst_energy(burst) < min_energy)
+ return 0; /* Nothing to do */
+
+ /* Debug */
+ fprintf(stderr, "[.] CBCH\n");
+
+ /* Demodulate burst */
+ rv = gmr1_pi4cxpsk_demod(
+ &gmr1_dc12_burst,
+ burst, cd->sps, -cd->freq_err,
+ ebits, NULL, NULL, NULL
+ );
+
+ if (rv)
+ return rv;
+
+ /* Decode burst */
+ crc = gmr1_xch_dc12_decode(l2, ebits, &conv);
+
+ fprintf(stderr, "crc=%d, conv=%d\n", crc, conv);
+
+ /* Send to GSMTap if correct */
+// if (!crc)
+// gsmtap_sendmsg(g_gti, gmr1_gsmtap_makemsg(
+// GSMTAP_GMR1_CCCH,
+// 0, cd->fn, cd->sa_bcch_stn, l2, 24));
+
+ l2[0] |= 0x20;
+
+ gsmtap_sendmsg(g_gti, gsmtap_makemsg_ex(
+ GSMTAP_TYPE_UM, /* type */
+ 0, /* arfcn */
+ 12, /* ts */
+ GSMTAP_CHANNEL_CBCH51, /* chan_type */
+ 0, /* ss */
+ cd->fn, /* fn */
+ 0, /* signal_dbm */
+ 0, /* snr */
+ l2, 23
+ ));
+
+ return 0;
+}
+
+static int
process_bcch(struct chan_desc *cd)
{
int frame_len;
@@ -873,9 +946,12 @@ process_bcch(struct chan_desc *cd)
rx_bcch(cd, &bcch_energy);
/* CCCH */
- if ((sirfn % 8 != 0) && (sirfn % 8 != 2))
+ if (sirfn % 8 == 3)
rx_ccch(cd, bcch_energy / 2.0f);
+ /* CBCH */
+ //rx_cbch(cd, bcch_energy / 2.0f);
+
/* TCH */
rx_tch3(cd);
rx_tch9(cd);