trx_interface: set proper burst type in GSMTAP header
If received burst is a RACH burst, one should contain the RACH
synchronization sequence (GSM 05.02 Chapter 5.2.7) and long
guard period filled by 0x00.
diff --git a/lib/trx_interface/trx_impl.cc b/lib/trx_interface/trx_impl.cc
index 48ef51a..8847278 100644
--- a/lib/trx_interface/trx_impl.cc
+++ b/lib/trx_interface/trx_impl.cc
@@ -33,6 +33,16 @@
#define BURST_SIZE 148
#define DATA_IF_MTU 160
+/**
+ * 41-bit RACH synchronization sequence
+ * GSM 05.02 Chapter 5.2.7 Access burst (AB)
+ */
+static uint8_t rach_synch_seq[] = {
+ 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0,
+ 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,
+};
+
namespace gr {
namespace grgsm {
@@ -90,6 +100,24 @@
}
/*
+ * Check if burst is a RACH burst
+ */
+ bool trx_impl::detect_rach(uint8_t *burst)
+ {
+ // Compare synchronization sequence
+ for (int i = 0; i < 41; i++)
+ if (burst[i + 8] != rach_synch_seq[i])
+ return false;
+
+ // Make sure TB and GP are filled by 0x00
+ for (int i = 0; i < 63; i++)
+ if (burst[i + 85] != 0x00)
+ return false;
+
+ return true;
+ }
+
+ /*
* Create an UDP payload with clock indication
*/
void
@@ -204,9 +232,9 @@
header->timeslot = payload[0];
header->frame_number = htobe32(fn);
- // HACK: use GSMTAP_BURST_NORMAL for now
- // FIXME: We will need to distinguish between RACN and NORMAL
- header->sub_type = GSMTAP_BURST_NORMAL;
+ // Check if one is a RACH burst
+ header->sub_type = detect_rach(payload + 6) ?
+ GSMTAP_BURST_ACCESS : GSMTAP_BURST_NORMAL;
// Copy burst bits (0 & 1) for source message
memcpy(buf + sizeof(gsmtap_hdr), payload + 6, BURST_SIZE);
diff --git a/lib/trx_interface/trx_impl.h b/lib/trx_interface/trx_impl.h
index 29545b1..65b4d97 100644
--- a/lib/trx_interface/trx_impl.h
+++ b/lib/trx_interface/trx_impl.h
@@ -37,6 +37,7 @@
udp_socket *d_data_sock;
udp_socket *d_clck_sock;
+ bool detect_rach(uint8_t *burst);
void clck_ind_send(uint32_t frame_nr);
void burst_pack(pmt::pmt_t msg, uint8_t *buf);