blob: 2ddc84daead013dbeff542148812ff1a400b43fb [file] [log] [blame]
piotrdda22272014-08-04 11:31:54 +02001/* -*- c++ -*- */
ptrkrysik529895b2014-12-02 18:07:38 +01002/*
3 * @file
Piotr Krysika6268a52017-08-23 16:02:19 +02004 * @author (C) 2014 by Piotr Krysik <ptrkrysik@gmail.com>
ptrkrysik529895b2014-12-02 18:07:38 +01005 * @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>
ptrkrysik3fe75842015-07-07 16:51:06 +020027#include <set>
28#include <map>
ptrkrysik42411c62015-07-08 10:50:41 +020029#include <vector>
piotrdda22272014-08-04 11:31:54 +020030
31namespace gr {
32 namespace gsm {
piotrdda22272014-08-04 11:31:54 +020033 class chan_info {
34 public:
35 unsigned int id;
36 int8_t pwr_db;
37 unsigned int arfcn;
piotrdda22272014-08-04 11:31:54 +020038 unsigned int lac;
39 unsigned int cell_id;
Roman Khassrafa1dd7ee2015-09-26 17:20:49 +020040 unsigned int mcc;
piotrdda22272014-08-04 11:31:54 +020041 unsigned int mnc;
Roman Khassraf9f4feb52015-09-26 18:44:56 +020042 unsigned int ccch_conf;
ptrkrysike9539c12015-07-06 08:34:22 +020043 std::set<int> neighbour_cells;
Roman Khassraf74efd102015-09-27 10:49:23 +020044 std::set<int> cell_arfcns;
piotrdda22272014-08-04 11:31:54 +020045
Roman Khassraf9f4feb52015-09-26 18:44:56 +020046 chan_info() : id(-1), pwr_db(0), arfcn(0), lac(0), cell_id(0), mcc(0), mnc(0), ccch_conf(-1){}
47 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), mcc(info.mcc), mnc(info.mnc), ccch_conf(info.ccch_conf){}
piotrdda22272014-08-04 11:31:54 +020048 ~chan_info(){}
ptrkrysike9539c12015-07-06 08:34:22 +020049 void copy_nonzero_elements(const chan_info & info){
ptrkrysik5e376742015-08-06 10:02:04 +020050 id = info.id;
ptrkrysike9539c12015-07-06 08:34:22 +020051 pwr_db = info.pwr_db;
52 arfcn = info.arfcn;
53 lac = (info.lac!=0) ? info.lac : lac;
54 cell_id = (info.cell_id!=0) ? info.cell_id : cell_id;
Roman Khassrafa1dd7ee2015-09-26 17:20:49 +020055 mcc = (info.mcc!=0) ? info.mcc : mcc;
ptrkrysike9539c12015-07-06 08:34:22 +020056 mnc = (info.mnc!=0) ? info.mnc : mnc;
Roman Khassraf9f4feb52015-09-26 18:44:56 +020057 ccch_conf = (info.ccch_conf!=-1) ? info.ccch_conf : ccch_conf;
ptrkrysike9539c12015-07-06 08:34:22 +020058 }
piotrdda22272014-08-04 11:31:54 +020059 };
60
61
62 struct compare_id {
63 inline bool operator()(const chan_info &a, const chan_info &b) const
64 {
65 return a.id < b.id;
66 }
67 };
68 struct compare_pwr {
69 inline bool operator()(const chan_info &a, const chan_info &b) const
70 {
71 return a.pwr_db < b.pwr_db;
72 }
73 };
74
ptrkrysike9539c12015-07-06 08:34:22 +020075 typedef std::map<unsigned int, chan_info> chan_info_map;
piotrdda22272014-08-04 11:31:54 +020076 class extract_system_info_impl : public extract_system_info
77 {
78 private:
79 void process_bursts(pmt::pmt_t burst);
80 void process_sysinfo(pmt::pmt_t msg);
ptrkrysike9539c12015-07-06 08:34:22 +020081 chan_info_map d_c0_channels;
piotrdda22272014-08-04 11:31:54 +020082 bool after_reset;
ptrkrysike9539c12015-07-06 08:34:22 +020083 void decode_neighbour_cells(uint8_t * data, unsigned int offset, unsigned int chan_id);
84// void dissect_channel_list_n_range(guint32 offset, guint len, gint range)
piotrdda22272014-08-04 11:31:54 +020085 public:
piotrdda22272014-08-04 11:31:54 +020086 virtual std::vector<int> get_chans();
87 virtual std::vector<int> get_pwrs();
88 virtual std::vector<int> get_lac();
89 virtual std::vector<int> get_cell_id();
Roman Khassrafa1dd7ee2015-09-26 17:20:49 +020090 virtual std::vector<int> get_mcc();
piotrdda22272014-08-04 11:31:54 +020091 virtual std::vector<int> get_mnc();
Roman Khassraf9f4feb52015-09-26 18:44:56 +020092 virtual std::vector<int> get_ccch_conf();
Roman Khassraf74efd102015-09-27 10:49:23 +020093 virtual std::vector<int> get_cell_arfcns(int chan_id);
ptrkrysike9539c12015-07-06 08:34:22 +020094 virtual std::vector<int> get_neighbours(int chan_id);
piotrdda22272014-08-04 11:31:54 +020095 virtual void reset();
96 extract_system_info_impl();
97 ~extract_system_info_impl();
98 };
99 } // namespace gsm
100} // namespace gr
101
102#endif /* INCLUDED_GSM_EXTRACT_SYSTEM_INFO_IMPL_H */
103