aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2017-11-29 16:39:22 +0100
committerPiotr Krysik <ptrkrysik@gmail.com>2017-11-29 16:39:22 +0100
commit23444838698302e5dd331cfac44082d71794d7d2 (patch)
treed7a03ab811d627dd592e3fcec39b8bd6ba75a110 /lib
parent2f0406b76daf3df6f8a70b116bb8dd3bf9112e88 (diff)
Added a block for generating Access Bursts
Diffstat (limited to 'lib')
-rw-r--r--lib/transmitter/CMakeLists.txt1
-rw-r--r--lib/transmitter/gen_test_ab_impl.cc107
-rw-r--r--lib/transmitter/gen_test_ab_impl.h47
3 files changed, 155 insertions, 0 deletions
diff --git a/lib/transmitter/CMakeLists.txt b/lib/transmitter/CMakeLists.txt
index c61654a..eb53162 100644
--- a/lib/transmitter/CMakeLists.txt
+++ b/lib/transmitter/CMakeLists.txt
@@ -20,4 +20,5 @@
add_sources(
txtime_setter_impl.cc
preprocess_tx_burst_impl.cc
+ gen_test_ab_impl
)
diff --git a/lib/transmitter/gen_test_ab_impl.cc b/lib/transmitter/gen_test_ab_impl.cc
new file mode 100644
index 0000000..66873db
--- /dev/null
+++ b/lib/transmitter/gen_test_ab_impl.cc
@@ -0,0 +1,107 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Piotr Krysik <ptrkrysik@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gr-gsm; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include <grgsm/gsmtap.h>
+#include <grgsm/gsm_constants.h>
+#include "gen_test_ab_impl.h"
+
+namespace gr {
+ namespace gsm {
+
+ 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,
+ };
+
+// static uint8_t AB[] = { 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+// static uint8_t AB[] = {0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
+// static uint8_t AB[] = { 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1};
+ static uint8_t AB[] = {1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,0,1,0,1,0,1,1,1,0,0,0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
+ ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+ gen_test_ab::sptr
+ gen_test_ab::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new gen_test_ab_impl());
+ }
+
+ /*
+ * The private constructor
+ */
+ gen_test_ab_impl::gen_test_ab_impl()
+ : gr::block("gen_test_ab",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0))
+ {
+ message_port_register_in(pmt::intern("bursts_in"));
+ message_port_register_out(pmt::intern("bursts_out"));
+
+ set_msg_handler(pmt::intern("bursts_in"), boost::bind(&gen_test_ab_impl::generate_ab, this, _1));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ gen_test_ab_impl::~gen_test_ab_impl()
+ {
+ }
+
+ void gen_test_ab_impl::generate_ab(pmt::pmt_t burst)
+ {
+ uint8_t buf[sizeof(gsmtap_hdr) + 148];
+ struct gsmtap_hdr *tap_header = (struct gsmtap_hdr *) buf;
+ uint8_t *access_burst = buf + sizeof(gsmtap_hdr);
+
+// memset(access_burst, 0, 8); /* TB */
+// memcpy(access_burst + 8, rach_synch_seq, 41); /* sync seq */
+// memcpy(access_burst + 49, AB, 36); /* payload */
+// memset(access_burst + 85, 0, 63); /* TB + GP */
+
+ memcpy(access_burst, AB, 148);
+
+ gsmtap_hdr * header = (gsmtap_hdr *)(pmt::blob_data(pmt::cdr(burst)));
+ uint32_t frame_nr = be32toh(header->frame_number);
+ frame_nr = (frame_nr+51)% (26*51*2048);
+
+ tap_header->version = GSMTAP_VERSION;
+ tap_header->hdr_len = sizeof(gsmtap_hdr) / 4;
+ tap_header->type = GSMTAP_TYPE_UM_BURST;
+ tap_header->sub_type = GSMTAP_BURST_ACCESS;
+ tap_header->frame_number = htobe32(frame_nr);
+ tap_header->timeslot = header->timeslot;
+ tap_header->arfcn = 0;
+
+ pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE);
+ pmt::pmt_t pdu_header = pmt::make_dict();
+
+ pmt::pmt_t new_msg = pmt::cons(pdu_header, blob);
+ message_port_pub(pmt::intern("bursts_out"), new_msg);
+ }
+ } /* namespace gsm */
+} /* namespace gr */
+
diff --git a/lib/transmitter/gen_test_ab_impl.h b/lib/transmitter/gen_test_ab_impl.h
new file mode 100644
index 0000000..366481e
--- /dev/null
+++ b/lib/transmitter/gen_test_ab_impl.h
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Piotr Krysik <ptrkrysik@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gr-gsm; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef INCLUDED_GSM_GEN_TEST_AB_IMPL_H
+#define INCLUDED_GSM_GEN_TEST_AB_IMPL_H
+
+#include <grgsm/transmitter/gen_test_ab.h>
+#include <grgsm/misc_utils/time_spec.h>
+#include <grgsm/misc_utils/fn_time.h>
+
+namespace gr {
+ namespace gsm {
+
+ class gen_test_ab_impl : public gen_test_ab
+ {
+ private:
+ void generate_ab(pmt::pmt_t burst);
+
+ public:
+ gen_test_ab_impl();
+ ~gen_test_ab_impl();
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GSM_GEN_TEST_AB_IMPL_H */
+