blob: da01e7c28ed088a99df84136f3ed0936208fa187 [file] [log] [blame]
piotrdda22272014-08-04 11:31:54 +02001/* -*- c++ -*- */
ptrkrysik529895b2014-12-02 18:07:38 +01002/*
3 * @file
4 * @author Piotr Krysik <ptrkrysik@gmail.com>
5 * @section LICENSE
6 *
7 * Gr-gsm is free software; you can redistribute it and/or modify
piotrdda22272014-08-04 11:31:54 +02008 * 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.
ptrkrysik529895b2014-12-02 18:07:38 +010011 *
12 * Gr-gsm is distributed in the hope that it will be useful,
piotrdda22272014-08-04 11:31:54 +020013 * 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.
ptrkrysik529895b2014-12-02 18:07:38 +010016 *
piotrdda22272014-08-04 11:31:54 +020017 * You should have received a copy of the GNU General Public License
ptrkrysik529895b2014-12-02 18:07:38 +010018 * along with gr-gsm; see the file COPYING. If not, write to
piotrdda22272014-08-04 11:31:54 +020019 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifndef INCLUDED_GSM_EXTRACT_SYSTEM_INFO_IMPL_H
24#define INCLUDED_GSM_EXTRACT_SYSTEM_INFO_IMPL_H
25
ptrkrysik3be74a72014-12-13 10:11:00 +010026#include <grgsm/misc_utils/extract_system_info.h>
piotrdda22272014-08-04 11:31:54 +020027
28
29namespace gr {
30 namespace gsm {
piotrdda22272014-08-04 11:31:54 +020031 class chan_info {
32 public:
33 unsigned int id;
34 int8_t pwr_db;
35 unsigned int arfcn;
piotrdda22272014-08-04 11:31:54 +020036 unsigned int lac;
37 unsigned int cell_id;
38 unsigned int mnc;
ptrkrysike9539c12015-07-06 08:34:22 +020039 std::set<int> neighbour_cells;
piotrdda22272014-08-04 11:31:54 +020040
ptrkrysike9539c12015-07-06 08:34:22 +020041 chan_info() : id(-1), pwr_db(0), arfcn(0), lac(0), cell_id(0), mnc(0){}
42 chan_info(const chan_info & info) : id(info.id), pwr_db(info.pwr_db), arfcn(info.arfcn), lac(info.lac), cell_id(info.cell_id), mnc(info.mnc){}
piotrdda22272014-08-04 11:31:54 +020043 ~chan_info(){}
ptrkrysike9539c12015-07-06 08:34:22 +020044 void copy_nonzero_elements(const chan_info & info){
45 pwr_db = info.pwr_db;
46 arfcn = info.arfcn;
47 lac = (info.lac!=0) ? info.lac : lac;
48 cell_id = (info.cell_id!=0) ? info.cell_id : cell_id;
49 mnc = (info.mnc!=0) ? info.mnc : mnc;
50 }
piotrdda22272014-08-04 11:31:54 +020051 };
52
53
54 struct compare_id {
55 inline bool operator()(const chan_info &a, const chan_info &b) const
56 {
57 return a.id < b.id;
58 }
59 };
60 struct compare_pwr {
61 inline bool operator()(const chan_info &a, const chan_info &b) const
62 {
63 return a.pwr_db < b.pwr_db;
64 }
65 };
66
ptrkrysike9539c12015-07-06 08:34:22 +020067 typedef std::map<unsigned int, chan_info> chan_info_map;
piotrdda22272014-08-04 11:31:54 +020068 class extract_system_info_impl : public extract_system_info
69 {
70 private:
71 void process_bursts(pmt::pmt_t burst);
72 void process_sysinfo(pmt::pmt_t msg);
ptrkrysike9539c12015-07-06 08:34:22 +020073 chan_info_map d_c0_channels;
piotrdda22272014-08-04 11:31:54 +020074 bool after_reset;
ptrkrysike9539c12015-07-06 08:34:22 +020075 void decode_neighbour_cells(uint8_t * data, unsigned int offset, unsigned int chan_id);
76// void dissect_channel_list_n_range(guint32 offset, guint len, gint range)
piotrdda22272014-08-04 11:31:54 +020077 public:
piotrdda22272014-08-04 11:31:54 +020078 virtual std::vector<int> get_chans();
79 virtual std::vector<int> get_pwrs();
80 virtual std::vector<int> get_lac();
81 virtual std::vector<int> get_cell_id();
82 virtual std::vector<int> get_mnc();
ptrkrysike9539c12015-07-06 08:34:22 +020083 virtual std::vector<int> get_neighbours(int chan_id);
piotrdda22272014-08-04 11:31:54 +020084 virtual void reset();
85 extract_system_info_impl();
86 ~extract_system_info_impl();
87 };
88 } // namespace gsm
89} // namespace gr
90
91#endif /* INCLUDED_GSM_EXTRACT_SYSTEM_INFO_IMPL_H */
92