From 9f723fd77151aaf13d1c87b33e153776f6b49804 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Thu, 6 Aug 2015 10:23:52 +0200 Subject: Changed control channels demappers in order to support uplink. Values of parameters for uplink are incorrect at this stage. --- .../universal_ctrl_chans_demapper_impl.cc | 266 +++++++++++++++------ lib/demapping/universal_ctrl_chans_demapper_impl.h | 17 +- 2 files changed, 200 insertions(+), 83 deletions(-) (limited to 'lib/demapping') diff --git a/lib/demapping/universal_ctrl_chans_demapper_impl.cc b/lib/demapping/universal_ctrl_chans_demapper_impl.cc index 8a6bfb5..85cb0c6 100644 --- a/lib/demapping/universal_ctrl_chans_demapper_impl.cc +++ b/lib/demapping/universal_ctrl_chans_demapper_impl.cc @@ -34,16 +34,16 @@ namespace gr { namespace gsm { universal_ctrl_chans_demapper::sptr - universal_ctrl_chans_demapper::make(unsigned int timeslot_nr, const std::vector &starts_fn_mod51, const std::vector &channel_types) + universal_ctrl_chans_demapper::make(unsigned int timeslot_nr, const std::vector &downlink_starts_fn_mod51, const std::vector &downlink_channel_types, const std::vector &uplink_starts_fn_mod51, const std::vector &uplink_channel_types) { return gnuradio::get_initial_sptr - (new universal_ctrl_chans_demapper_impl(timeslot_nr, starts_fn_mod51, channel_types)); + (new universal_ctrl_chans_demapper_impl(timeslot_nr, downlink_starts_fn_mod51, downlink_channel_types, uplink_starts_fn_mod51, uplink_channel_types)); } /* * The private constructor */ - universal_ctrl_chans_demapper_impl::universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector &starts_fn_mod51, const std::vector &channel_types) + universal_ctrl_chans_demapper_impl::universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector &downlink_starts_fn_mod51, const std::vector &downlink_channel_types, const std::vector &uplink_starts_fn_mod51, const std::vector &uplink_channel_types) : gr::block("universal_ctrl_chans_demapper", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), @@ -54,75 +54,137 @@ namespace gr { for(int ii=0; ii<51; ii++) { - d_starts_fn_mod51[ii]=0; - d_channel_types[ii]=0; - d_subslots[ii] = 0; - d_subslots[ii+51] = 0; + d_downlink_starts_fn_mod51[ii]=0; + d_downlink_channel_types[ii]=0; + d_downlink_subslots[ii] = 0; + d_downlink_subslots[ii+51] = 0; + + d_uplink_starts_fn_mod51[ii]=0; + d_uplink_channel_types[ii]=0; + d_uplink_subslots[ii] = 0; + d_uplink_subslots[ii+51] = 0; } std::vector::const_iterator s; std::vector::const_iterator ch_type; - for(s=starts_fn_mod51.begin(), ch_type=channel_types.begin();s != starts_fn_mod51.end(); s++) + for(s=downlink_starts_fn_mod51.begin(), ch_type=downlink_channel_types.begin();s != downlink_starts_fn_mod51.end(); s++) { if((*s >= 0) and (*s <= (51-4))) { for(int ii=0; ii<4; ii++){ - d_starts_fn_mod51[*s+ii] = *s; - if(ch_type!=channel_types.end()) + d_downlink_starts_fn_mod51[*s+ii] = *s; + if(ch_type!=downlink_channel_types.end()) { - d_channel_types[*s+ii] = *ch_type; + d_downlink_channel_types[*s+ii] = *ch_type; } } - if(ch_type!=channel_types.end()) + if(ch_type!=downlink_channel_types.end()) { ch_type++; } } } - std::set distinct_channels(channel_types.begin(), channel_types.end()); - std::set::iterator it; + for(s=uplink_starts_fn_mod51.begin(), ch_type=uplink_channel_types.begin();s != uplink_starts_fn_mod51.end(); s++) + { + if((*s >= 0) and (*s <= (51-4))) + { + for(int ii=0; ii<4; ii++){ + d_uplink_starts_fn_mod51[*s+ii] = *s; + if(ch_type!=uplink_channel_types.end()) + { + d_uplink_channel_types[*s+ii] = *ch_type; + } + } + if(ch_type!=uplink_channel_types.end()) + { + ch_type++; + } + } + } + + std::set distinct_downlink_channels(downlink_channel_types.begin(), downlink_channel_types.end()); + std::set::iterator it; unsigned int subslot; - - for (it=distinct_channels.begin(); it != distinct_channels.end(); it++) - { - subslot = 0; - for(s=starts_fn_mod51.begin();s != starts_fn_mod51.end(); s++) - { - if ((d_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4))) - { - for(int ii=0; ii<4; ii++) - { - d_subslots[*s+ii] = subslot; - d_subslots[*s+ii+51] = subslot; - } - subslot++; - } - } - - if (*it == GSMTAP_CHANNEL_ACCH or - *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH) or - *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH4) or - *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH8) or - *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_F) or - *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_H) - ) - { - for(s=starts_fn_mod51.begin();s != starts_fn_mod51.end(); s++) - { - if ((d_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4))) - { - for(int ii=0; ii<4; ii++) - { - d_subslots[*s+ii+51] = subslot; - } - subslot++; - } - } - } - } + for (it=distinct_downlink_channels.begin(); it != distinct_downlink_channels.end(); it++) + { + subslot = 0; + for(s=downlink_starts_fn_mod51.begin();s != downlink_starts_fn_mod51.end(); s++) + { + if ((d_downlink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4))) + { + for(int ii=0; ii<4; ii++) + { + d_downlink_subslots[*s+ii] = subslot; + d_downlink_subslots[*s+ii+51] = subslot; + } + subslot++; + } + } + + if (*it == GSMTAP_CHANNEL_ACCH or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH4) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH8) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_F) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_H) + ) + { + for(s=downlink_starts_fn_mod51.begin();s != downlink_starts_fn_mod51.end(); s++) + { + if ((d_downlink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4))) + { + for(int ii=0; ii<4; ii++) + { + d_downlink_subslots[*s+ii+51] = subslot; + } + subslot++; + } + } + } + } + + std::set distinct_uplink_channels(uplink_channel_types.begin(), uplink_channel_types.end()); + for (it=distinct_uplink_channels.begin(); it != distinct_uplink_channels.end(); it++) + { + subslot = 0; + for(s=uplink_starts_fn_mod51.begin();s != uplink_starts_fn_mod51.end(); s++) + { + if ((d_uplink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4))) + { + for(int ii=0; ii<4; ii++) + { + d_uplink_subslots[*s+ii] = subslot; + d_uplink_subslots[*s+ii+51] = subslot; + } + subslot++; + } + } + + if (*it == GSMTAP_CHANNEL_ACCH or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH4) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_SDCCH8) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_F) or + *it == (GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_H) + ) + { + for(s=uplink_starts_fn_mod51.begin();s != uplink_starts_fn_mod51.end(); s++) + { + if ((d_uplink_channel_types[*s] == *it) and (*s >= 0) and (*s <= (51-4))) + { + for(int ii=0; ii<4; ii++) + { + d_uplink_subslots[*s+ii+51] = subslot; + } + subslot++; + } + } + } + } + message_port_register_in(pmt::mp("bursts")); set_msg_handler(pmt::mp("bursts"), boost::bind(&universal_ctrl_chans_demapper_impl::filter_ctrl_chans, this, _1)); @@ -143,41 +205,91 @@ namespace gr { uint32_t frame_nr = be32toh(header->frame_number); uint32_t fn_mod51 = frame_nr % 51; - uint32_t fn51_start = d_starts_fn_mod51[fn_mod51]; - uint32_t fn51_stop = fn51_start + 3; - uint32_t ch_type = d_channel_types[fn_mod51]; + bool uplink_burst = (be16toh(header->arfcn) & 0x4000) ? true : false; + if(header->timeslot==d_timeslot){ - header->sub_type = ch_type; - header->sub_slot = d_subslots[fn_mod51 + (51 * (frame_nr % 2))]; - - if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop) - { - uint32_t ii = fn_mod51 - fn51_start; - d_frame_numbers[ii] = frame_nr; - d_bursts[ii] = msg; - } - - if(fn_mod51==fn51_stop) + if(uplink_burst) { - //check for a situation where some bursts were lost - //in this situation frame numbers won't be consecutive - bool frames_are_consecutive = true; - for(int jj=1; jj<4; jj++) + uint32_t fn51_start = d_uplink_starts_fn_mod51[fn_mod51]; + uint32_t fn51_stop = fn51_start + 3; + uint32_t ch_type = d_uplink_channel_types[fn_mod51]; + + if(ch_type != 0) + { + header->sub_type = ch_type; + } + header->sub_slot = d_uplink_subslots[fn_mod51 + (51 * (frame_nr % 2))]; + + if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop) { - if((d_frame_numbers[jj]-d_frame_numbers[jj-1])!=1) + uint32_t ii = fn_mod51 - fn51_start; + d_uplink_frame_numbers[ii] = frame_nr; + d_uplink_bursts[ii] = msg; + } + + if(fn_mod51==fn51_stop) + { + //check for a situation where some bursts were lost + //in this situation frame numbers won't be consecutive + bool frames_are_consecutive = true; + for(int jj=1; jj<4; jj++) { - frames_are_consecutive = false; + if((d_uplink_frame_numbers[jj]-d_uplink_frame_numbers[jj-1])!=1) + { + frames_are_consecutive = false; + } } + if(frames_are_consecutive) + { + //send bursts to the output + for(int jj=0; jj<4; jj++) + { + message_port_pub(pmt::mp("bursts"), d_uplink_bursts[jj]); + } + } + } + } + else + { + uint32_t fn51_start = d_downlink_starts_fn_mod51[fn_mod51]; + uint32_t fn51_stop = fn51_start + 3; + uint32_t ch_type = d_downlink_channel_types[fn_mod51]; + + if(ch_type != 0) + { + header->sub_type = ch_type; } - if(frames_are_consecutive) + header->sub_slot = d_downlink_subslots[fn_mod51 + (51 * (frame_nr % 2))]; + + if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop) { - //send bursts to the output - for(int jj=0; jj<4; jj++) + uint32_t ii = fn_mod51 - fn51_start; + d_downlink_frame_numbers[ii] = frame_nr; + d_downlink_bursts[ii] = msg; + } + + if(fn_mod51==fn51_stop) + { + //check for a situation where some bursts were lost + //in this situation frame numbers won't be consecutive + bool frames_are_consecutive = true; + for(int jj=1; jj<4; jj++) { - message_port_pub(pmt::mp("bursts"), d_bursts[jj]); + if((d_downlink_frame_numbers[jj]-d_downlink_frame_numbers[jj-1])!=1) + { + frames_are_consecutive = false; + } } - } + if(frames_are_consecutive) + { + //send bursts to the output + for(int jj=0; jj<4; jj++) + { + message_port_pub(pmt::mp("bursts"), d_downlink_bursts[jj]); + } + } + } } } } diff --git a/lib/demapping/universal_ctrl_chans_demapper_impl.h b/lib/demapping/universal_ctrl_chans_demapper_impl.h index d4e1440..0316bf4 100644 --- a/lib/demapping/universal_ctrl_chans_demapper_impl.h +++ b/lib/demapping/universal_ctrl_chans_demapper_impl.h @@ -32,14 +32,19 @@ namespace gr { class universal_ctrl_chans_demapper_impl : public universal_ctrl_chans_demapper { private: - unsigned int d_starts_fn_mod51[51]; - unsigned int d_channel_types[51]; - unsigned int d_subslots[102]; + unsigned int d_downlink_starts_fn_mod51[51]; + unsigned int d_uplink_starts_fn_mod51[51]; + unsigned int d_downlink_channel_types[51]; + unsigned int d_uplink_channel_types[51]; + unsigned int d_downlink_subslots[102]; + unsigned int d_uplink_subslots[102]; unsigned int d_timeslot; - uint32_t d_frame_numbers[4]; - pmt::pmt_t d_bursts[4]; + uint32_t d_downlink_frame_numbers[4]; + uint32_t d_uplink_frame_numbers[4]; + pmt::pmt_t d_downlink_bursts[4]; + pmt::pmt_t d_uplink_bursts[4]; public: - universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector &starts_fn_mod51, const std::vector &channel_types); + universal_ctrl_chans_demapper_impl(unsigned int timeslot_nr, const std::vector &downlink_starts_fn_mod51, const std::vector &downlink_channel_types, const std::vector &uplink_starts_fn_mod51, const std::vector &uplink_channel_types); ~universal_ctrl_chans_demapper_impl(); void filter_ctrl_chans(pmt::pmt_t msg); -- cgit v1.2.3