blob: fe75f21ba80749b61f075b91942ada6378aaa6df [file] [log] [blame]
Piotr Krysikc097ce72018-03-05 13:16:32 +01001/* -*- c++ -*- */
2/*
3 * @file
4 * @author (C) 2018 by Piotr Krysik <ptrkrysik@gmail.com>
5 * @section LICENSE
6 *
7 * Gr-gsm is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * Gr-gsm is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with gr-gsm; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <gnuradio/io_signature.h>
28#include <grgsm/gsmtap.h>
29//#include <unistd.h>
30#include <grgsm/endian.h>
31
32#include "extract_assignment_cmd_impl.h"
33
34namespace gr {
35 namespace gsm {
36 void extract_assignment_cmd_impl::process_messages(pmt::pmt_t msg)
37 {
38 pmt::pmt_t message_plus_header_blob = pmt::cdr(msg);
39 uint8_t * message_plus_header = (uint8_t *)pmt::blob_data(message_plus_header_blob);
40 gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header;
41 uint8_t * msg_elements = (uint8_t *)(message_plus_header+sizeof(gsmtap_hdr));
42
43 if((msg_elements[3] & 0xFF) == 0x06 && msg_elements[4] == 0x2e)
44 {
45 int frame_nr = be32toh(header->frame_number);
46 d_assignment_commands.push_back(frame_nr);
47 }
48 }
49
50
51
52 std::vector<int> extract_assignment_cmd_impl::get_assignment_commands()
53 {
54 return d_assignment_commands;
55 }
56
57 extract_assignment_cmd::sptr
58 extract_assignment_cmd::make()
59 {
60 return gnuradio::get_initial_sptr
61 (new extract_assignment_cmd_impl());
62 }
63
64 /*
65 * The private constructor
66 */
67 extract_assignment_cmd_impl::extract_assignment_cmd_impl()
68 : gr::block("extract_assignment_cmd",
69 gr::io_signature::make(0, 0, 0),
70 gr::io_signature::make(0, 0, 0))
71 {
72 message_port_register_in(pmt::mp("msgs"));
Vadim Yanitskiya1169202021-05-03 19:00:43 +020073 set_msg_handler(pmt::mp("msgs"), boost::bind(&extract_assignment_cmd_impl::process_messages, this, boost::placeholders::_1));
Piotr Krysikc097ce72018-03-05 13:16:32 +010074 }
75
76 /*
77 * Our virtual destructor.
78 */
79 extract_assignment_cmd_impl::~extract_assignment_cmd_impl()
80 {
81 }
82 } /* namespace gsm */
83} /* namespace gr */