piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 2 | /* |
| 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 |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 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. |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 11 | * |
| 12 | * Gr-gsm is distributed in the hope that it will be useful, |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 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. |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 16 | * |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 17 | * You should have received a copy of the GNU General Public License |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 18 | * along with gr-gsm; see the file COPYING. If not, write to |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 19 | * 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 | |
ptrkrysik | 3be74a7 | 2014-12-13 10:11:00 +0100 | [diff] [blame] | 26 | #include <grgsm/misc_utils/extract_system_info.h> |
ptrkrysik | 3fe7584 | 2015-07-07 16:51:06 +0200 | [diff] [blame] | 27 | #include <set> |
| 28 | #include <map> |
ptrkrysik | 42411c6 | 2015-07-08 10:50:41 +0200 | [diff] [blame] | 29 | #include <vector> |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 30 | |
| 31 | namespace gr { |
| 32 | namespace gsm { |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 33 | class chan_info { |
| 34 | public: |
| 35 | unsigned int id; |
| 36 | int8_t pwr_db; |
| 37 | unsigned int arfcn; |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 38 | unsigned int lac; |
| 39 | unsigned int cell_id; |
Roman Khassraf | a1dd7ee | 2015-09-26 17:20:49 +0200 | [diff] [blame] | 40 | unsigned int mcc; |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 41 | unsigned int mnc; |
Roman Khassraf | 9f4feb5 | 2015-09-26 18:44:56 +0200 | [diff] [blame] | 42 | unsigned int ccch_conf; |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 43 | std::set<int> neighbour_cells; |
Roman Khassraf | 74efd10 | 2015-09-27 10:49:23 +0200 | [diff] [blame] | 44 | std::set<int> cell_arfcns; |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 45 | |
Roman Khassraf | 9f4feb5 | 2015-09-26 18:44:56 +0200 | [diff] [blame] | 46 | 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){} |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 48 | ~chan_info(){} |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 49 | void copy_nonzero_elements(const chan_info & info){ |
ptrkrysik | 5e37674 | 2015-08-06 10:02:04 +0200 | [diff] [blame] | 50 | id = info.id; |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 51 | 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 Khassraf | a1dd7ee | 2015-09-26 17:20:49 +0200 | [diff] [blame] | 55 | mcc = (info.mcc!=0) ? info.mcc : mcc; |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 56 | mnc = (info.mnc!=0) ? info.mnc : mnc; |
Roman Khassraf | 9f4feb5 | 2015-09-26 18:44:56 +0200 | [diff] [blame] | 57 | ccch_conf = (info.ccch_conf!=-1) ? info.ccch_conf : ccch_conf; |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 58 | } |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 59 | }; |
| 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 | |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 75 | typedef std::map<unsigned int, chan_info> chan_info_map; |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 76 | 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); |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 81 | chan_info_map d_c0_channels; |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 82 | bool after_reset; |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 83 | 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) |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 85 | public: |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 86 | 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 Khassraf | a1dd7ee | 2015-09-26 17:20:49 +0200 | [diff] [blame] | 90 | virtual std::vector<int> get_mcc(); |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 91 | virtual std::vector<int> get_mnc(); |
Roman Khassraf | 9f4feb5 | 2015-09-26 18:44:56 +0200 | [diff] [blame] | 92 | virtual std::vector<int> get_ccch_conf(); |
Roman Khassraf | 74efd10 | 2015-09-27 10:49:23 +0200 | [diff] [blame] | 93 | virtual std::vector<int> get_cell_arfcns(int chan_id); |
ptrkrysik | e9539c1 | 2015-07-06 08:34:22 +0200 | [diff] [blame] | 94 | virtual std::vector<int> get_neighbours(int chan_id); |
piotr | dda2227 | 2014-08-04 11:31:54 +0200 | [diff] [blame] | 95 | 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 | |