Added option to enable/disable information printing in immediate assignment extractor, plus code cleanup
This commit is contained in:
parent
95c6f9dfba
commit
a212ca2dd7
|
@ -3,10 +3,36 @@
|
|||
<name>Extract immediate assignment</name>
|
||||
<key>gsm_extract_immediate_assignment</key>
|
||||
<import>import grgsm</import>
|
||||
<make>grgsm.extract_immediate_assignment()</make>
|
||||
<make>grgsm.extract_immediate_assignment($print_immediate_assignments)</make>
|
||||
|
||||
<param>
|
||||
<name>Print</name>
|
||||
<key>print_immediate_assignments</key>
|
||||
<value>False</value>
|
||||
<type>bool</type>
|
||||
<option>
|
||||
<name>False</name>
|
||||
<key>False</key>
|
||||
</option>
|
||||
<option>
|
||||
<name>True</name>
|
||||
<key>True</key>
|
||||
</option>
|
||||
</param>
|
||||
|
||||
<sink>
|
||||
<name>msgs</name>
|
||||
<type>message</type>
|
||||
</sink>
|
||||
</sink>
|
||||
|
||||
<doc>
|
||||
Extracts the assignment information from immediate assignments, i.e. timeslot, channel type, etc.
|
||||
|
||||
Input: decoded control channel messages
|
||||
|
||||
If "Print" is enabled, the information will be printed to output also,
|
||||
else the data can be retrieved using functions:
|
||||
|
||||
get_frame_numbers(), get_channel_types(), get_timeslots(), get_subchannels(), get_hopping(), get_maios(), get_hsns(), get_arfcns(), get_timing_advances(), get_mobile_allocations()
|
||||
</doc>
|
||||
</block>
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace gr {
|
|||
* class. gsm::extract_immediate_assignment::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make();
|
||||
static sptr make(bool print_immediate_assignments=false);
|
||||
virtual std::vector<int> get_frame_numbers() = 0;
|
||||
virtual std::vector<std::string> get_channel_types() = 0;
|
||||
virtual std::vector<int> get_timeslots() = 0;
|
||||
|
|
|
@ -27,11 +27,7 @@
|
|||
#include <gnuradio/io_signature.h>
|
||||
#include <grgsm/gsmtap.h>
|
||||
#include <unistd.h>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <endian.h>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
|
@ -51,13 +47,8 @@ namespace gr {
|
|||
if(msg_elements[2]==0x3f)
|
||||
{
|
||||
immediate_assignment current;
|
||||
std::cout << "\n------------------------------------------------------------------\n" << std::endl;
|
||||
std::cout << "FrameNr: " << (unsigned)frame_nr << std::endl;
|
||||
|
||||
current.frame_nr = frame_nr;
|
||||
|
||||
uint8_t mode = msg_elements[3] & (1 << 4);
|
||||
|
||||
/*
|
||||
channel description, see table 10.23 in GSM 04.08
|
||||
|
||||
|
@ -71,50 +62,37 @@ namespace gr {
|
|||
01TTT SDCCH/8, subchannel/TDMA offset TTT
|
||||
3 bits timeslot number TN
|
||||
*/
|
||||
current.timeslot = (msg_elements[4] & 7);
|
||||
|
||||
uint8_t channeltype = (msg_elements[4] >> 3);
|
||||
uint8_t timeslot = (msg_elements[4] & 7);
|
||||
uint8_t subchannel;
|
||||
std::string channel_type;
|
||||
|
||||
std::cout << "Timeslot: " << (unsigned)timeslot << std::endl;
|
||||
|
||||
uint8_t mode = msg_elements[3] & (1 << 4);
|
||||
if (mode == 0)
|
||||
{
|
||||
if (channeltype >= 8)
|
||||
{
|
||||
channel_type = "SDCCH/8";
|
||||
subchannel = (channeltype & 7);
|
||||
current.channel_type = "SDCCH/8";
|
||||
current.subchannel = (channeltype & 7);
|
||||
}
|
||||
else if (channeltype >= 4 && channeltype <= 7)
|
||||
{
|
||||
channel_type = "SDCCH/4";
|
||||
subchannel = (channeltype & 3);
|
||||
current.channel_type = "SDCCH/4";
|
||||
current.subchannel = (channeltype & 3);
|
||||
}
|
||||
else if (channeltype >= 2 && channeltype <= 3)
|
||||
{
|
||||
channel_type = "TCH/H";
|
||||
subchannel = (channeltype & 1);
|
||||
current.channel_type = "TCH/H";
|
||||
current.subchannel = (channeltype & 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel_type = "TCH/F";
|
||||
subchannel = 0;
|
||||
current.channel_type = "TCH/F";
|
||||
}
|
||||
|
||||
std::cout << "Channel type: " << channel_type << std::endl;
|
||||
std::cout << "Subchannel: " << (unsigned)subchannel << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
channel_type = "GPRS - Temporary Block Flow TBF";
|
||||
subchannel = 0;
|
||||
std::cout << "Channel type: " << "GPRS - Temporary Block Flow TBF" << std::endl;
|
||||
current.channel_type = "GPRS - Temporary Block Flow TBF";
|
||||
}
|
||||
|
||||
current.channel_type = channel_type;
|
||||
current.timeslot = timeslot;
|
||||
current.subchannel = subchannel;
|
||||
|
||||
/*
|
||||
msg_elements[5], msg_elements[6] are octets 3 and 4 in specs
|
||||
|
||||
|
@ -133,72 +111,73 @@ namespace gr {
|
|||
2 bit low part of MAIO
|
||||
6bit HSN
|
||||
*/
|
||||
uint8_t hopping = (msg_elements[5] >> 4) & 1;
|
||||
current.hopping = hopping;
|
||||
|
||||
std::cout << "Hopping: " << (unsigned)hopping << std::endl;
|
||||
|
||||
if (hopping)
|
||||
current.hopping = (msg_elements[5] >> 4) & 1;
|
||||
if (current.hopping)
|
||||
{
|
||||
uint8_t maio = (msg_elements[5] & 0xf) << 2;
|
||||
maio |= (msg_elements[6] >> 6);
|
||||
|
||||
uint8_t hsn = (msg_elements[6] & 0x3f);
|
||||
|
||||
current.maio = maio;
|
||||
current.hsn = hsn;
|
||||
|
||||
std::cout << "MAIO: " << (unsigned)maio << std::endl;
|
||||
std::cout << "HSN: " << (unsigned)hsn << std::endl;
|
||||
current.hsn = (msg_elements[6] & 0x3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t arfcn = (msg_elements[5] & 3) << 8;
|
||||
arfcn |= msg_elements[6];
|
||||
|
||||
current.arfcn = arfcn;
|
||||
|
||||
std::cout << "ARFCN: " << (unsigned)arfcn << std::endl;
|
||||
}
|
||||
|
||||
// request reference as ID in set, so we get only one immediate assignment per reference
|
||||
// TODO: add option where request reference is set as ID,
|
||||
// so we get only one immediate assignment per reference
|
||||
/*
|
||||
msg_elements[7 - 9], octets 5 - 7 in specs : request reference, maybe later
|
||||
|
||||
msg_elements[10]: timing advance
|
||||
*/
|
||||
uint8_t timing_advance = msg_elements[10];
|
||||
std::cout << "TA: " << (unsigned)timing_advance << std::endl;
|
||||
|
||||
current.timing_advance = timing_advance;
|
||||
|
||||
current.timing_advance = msg_elements[10];
|
||||
|
||||
/*
|
||||
msg_elements[11] - 20: mobile allocation, flexible length, see 10.5.2.21
|
||||
msg_elements[11 - 20]: mobile allocation, flexible length, see 10.5.2.21
|
||||
*/
|
||||
uint8_t mobile_allocation_len = msg_elements[11];
|
||||
if (mobile_allocation_len > 0)
|
||||
{
|
||||
uint8_t mobile_allocation[mobile_allocation_len];
|
||||
std::string ma;
|
||||
|
||||
for (int i=0; i<mobile_allocation_len; i++)
|
||||
{
|
||||
mobile_allocation[i] = msg_elements[12 + i];
|
||||
|
||||
for (int j=0; j<8; j++)
|
||||
{
|
||||
ma.push_back('0' + ((mobile_allocation[i] >> (7-j)) & 0x1));
|
||||
ma.push_back('0' + ((msg_elements[12 + i] >> (7-j)) & 0x1));
|
||||
}
|
||||
|
||||
// std::cout << "MA: " << (unsigned)mobile_allocation[i] << std::endl;
|
||||
std::cout << "MA: " << ma << std::endl;
|
||||
}
|
||||
|
||||
current.mobile_allocation = ma;
|
||||
}
|
||||
|
||||
d_assignment_map[current.frame_nr] = current;
|
||||
|
||||
if (d_print_immediate_assignments)
|
||||
{
|
||||
std::cout << "\n------------------------------------------------\n" << std::endl;
|
||||
std::cout << "FrameNr: " << (unsigned)current.frame_nr << std::endl;
|
||||
std::cout << "Channel type: " << current.channel_type << std::endl;
|
||||
std::cout << "Timeslot: " << (unsigned)current.timeslot << std::endl;
|
||||
// Dont print subchannel if mode == 1 or if the assigned channel is TCH/F
|
||||
if (mode == 0 && channeltype >= 2)
|
||||
{
|
||||
std::cout << "Subchannel: " << (unsigned)current.subchannel << std::endl;
|
||||
}
|
||||
std::cout << "Hopping: " << (unsigned)current.hopping << std::endl;
|
||||
if (current.hopping)
|
||||
{
|
||||
std::cout << "MAIO: " << (unsigned)current.maio << std::endl;
|
||||
std::cout << "HSN: " << (unsigned)current.hsn << std::endl;
|
||||
std::cout << "Mobile Allocation: " << current.mobile_allocation << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "ARFCN: " << (unsigned)current.arfcn << std::endl;
|
||||
}
|
||||
std::cout << "Timing Advance: " << (unsigned)current.timing_advance << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,20 +282,21 @@ namespace gr {
|
|||
}
|
||||
|
||||
extract_immediate_assignment::sptr
|
||||
extract_immediate_assignment::make()
|
||||
extract_immediate_assignment::make(bool print_immediate_assignments)
|
||||
{
|
||||
return gnuradio::get_initial_sptr
|
||||
(new extract_immediate_assignment_impl());
|
||||
(new extract_immediate_assignment_impl(print_immediate_assignments));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
extract_immediate_assignment_impl::extract_immediate_assignment_impl()
|
||||
extract_immediate_assignment_impl::extract_immediate_assignment_impl(bool print_immediate_assignments)
|
||||
: gr::block("extract_immediate_assignment",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(0, 0, 0))
|
||||
{
|
||||
d_print_immediate_assignments = print_immediate_assignments;
|
||||
message_port_register_in(pmt::mp("msgs"));
|
||||
set_msg_handler(pmt::mp("msgs"), boost::bind(&extract_immediate_assignment_impl::process_message, this, _1));
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define INCLUDED_GSM_EXTRACT_IMMEDIATE_ASSIGNMENT_IMPL_H
|
||||
|
||||
#include <grgsm/misc_utils/extract_immediate_assignment.h>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
@ -57,6 +56,7 @@ namespace gr {
|
|||
private:
|
||||
void process_message(pmt::pmt_t msg);
|
||||
immediate_assignment_map d_assignment_map;
|
||||
bool d_print_immediate_assignments;
|
||||
public:
|
||||
virtual std::vector<int> get_frame_numbers();
|
||||
virtual std::vector<std::string> get_channel_types();
|
||||
|
@ -68,7 +68,7 @@ namespace gr {
|
|||
virtual std::vector<int> get_arfcns();
|
||||
virtual std::vector<int> get_timing_advances();
|
||||
virtual std::vector<std::string> get_mobile_allocations();
|
||||
extract_immediate_assignment_impl();
|
||||
extract_immediate_assignment_impl(bool print_immediate_assignments=false);
|
||||
~extract_immediate_assignment_impl();
|
||||
};
|
||||
} // namespace gsm
|
||||
|
|
Loading…
Reference in New Issue