short: detect frames during copying and correct frequency offset
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<key>ieee802_11_ofdm_sync_short</key>
|
<key>ieee802_11_ofdm_sync_short</key>
|
||||||
<category>IEEE802.11</category>
|
<category>IEEE802.11</category>
|
||||||
<import>import ieee802_11</import>
|
<import>import ieee802_11</import>
|
||||||
<make>ieee802_11.ofdm_sync_short($threshold, $max_samples, $min_plateau, $log, $debug)</make>
|
<make>ieee802_11.ofdm_sync_short($threshold, $min_plateau, $log, $debug)</make>
|
||||||
|
|
||||||
<param>
|
<param>
|
||||||
<name>Log</name>
|
<name>Log</name>
|
||||||
@@ -46,13 +46,6 @@
|
|||||||
<type>real</type>
|
<type>real</type>
|
||||||
</param>
|
</param>
|
||||||
|
|
||||||
<param>
|
|
||||||
<name>Max Samples</name>
|
|
||||||
<key>max_samples</key>
|
|
||||||
<value>5200</value>
|
|
||||||
<type>int</type>
|
|
||||||
</param>
|
|
||||||
|
|
||||||
<param>
|
<param>
|
||||||
<name>Min Plateau</name>
|
<name>Min Plateau</name>
|
||||||
<key>min_plateau</key>
|
<key>min_plateau</key>
|
||||||
@@ -61,7 +54,6 @@
|
|||||||
</param>
|
</param>
|
||||||
|
|
||||||
<check>$threshold > 0</check>
|
<check>$threshold > 0</check>
|
||||||
<check>$max_samples > 400</check>
|
|
||||||
<check>$min_plateau > 0</check>
|
<check>$min_plateau > 0</check>
|
||||||
|
|
||||||
<sink>
|
<sink>
|
||||||
@@ -70,6 +62,12 @@
|
|||||||
<nports>1</nports>
|
<nports>1</nports>
|
||||||
</sink>
|
</sink>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>abs</name>
|
||||||
|
<type>complex</type>
|
||||||
|
<nports>1</nports>
|
||||||
|
</sink>
|
||||||
|
|
||||||
<sink>
|
<sink>
|
||||||
<name>cor</name>
|
<name>cor</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ class IEEE802_11_API ofdm_sync_short : virtual public block
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::shared_ptr<ofdm_sync_short> sptr;
|
typedef boost::shared_ptr<ofdm_sync_short> sptr;
|
||||||
static sptr make(double threshold, unsigned int max_samples,
|
static sptr make(double threshold, unsigned int min_plateau, bool log = false, bool debug = false);
|
||||||
unsigned int min_plateau, bool log = false, bool debug = false);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+32
-34
@@ -23,38 +23,38 @@
|
|||||||
using namespace gr::ieee802_11;
|
using namespace gr::ieee802_11;
|
||||||
|
|
||||||
static const int MIN_GAP = 480;
|
static const int MIN_GAP = 480;
|
||||||
|
static const int MAX_SAMPLES = 540 * 80;
|
||||||
|
|
||||||
class ofdm_sync_short_impl : public ofdm_sync_short {
|
class ofdm_sync_short_impl : public ofdm_sync_short {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ofdm_sync_short_impl(double threshold, unsigned int max_samples,
|
ofdm_sync_short_impl(double threshold, unsigned int min_plateau, bool log, bool debug) :
|
||||||
unsigned int min_plateau, bool log, bool debug) : block("ofdm_sync_short",
|
block("ofdm_sync_short",
|
||||||
gr::io_signature::make2(2, 2, sizeof(gr_complex), sizeof(float)),
|
gr::io_signature::make3(3, 3, sizeof(gr_complex), sizeof(gr_complex), sizeof(float)),
|
||||||
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
||||||
d_log(log),
|
d_log(log),
|
||||||
d_debug(debug),
|
d_debug(debug),
|
||||||
d_state(SEARCH),
|
d_state(SEARCH),
|
||||||
d_plateau(0),
|
d_plateau(0),
|
||||||
MAX_SAMPLES(max_samples),
|
d_freq_offset(0),
|
||||||
MIN_PLATEAU(min_plateau),
|
d_copied(0),
|
||||||
d_threshold(threshold) {
|
MIN_PLATEAU(min_plateau),
|
||||||
|
d_threshold(threshold) {
|
||||||
|
|
||||||
set_tag_propagation_policy(block::TPP_DONT);
|
set_tag_propagation_policy(block::TPP_DONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ofdm_sync_short_impl(){
|
|
||||||
}
|
|
||||||
|
|
||||||
int general_work (int noutput_items, gr_vector_int& ninput_items,
|
int general_work (int noutput_items, gr_vector_int& ninput_items,
|
||||||
gr_vector_const_void_star& input_items,
|
gr_vector_const_void_star& input_items,
|
||||||
gr_vector_void_star& output_items) {
|
gr_vector_void_star& output_items) {
|
||||||
|
|
||||||
const gr_complex *in = (const gr_complex*)input_items[0];
|
const gr_complex *in = (const gr_complex*)input_items[0];
|
||||||
const float *in2 = (const float*)input_items[1];
|
const gr_complex *in_abs = (const gr_complex*)input_items[1];
|
||||||
|
const float *in_cor = (const float*)input_items[2];
|
||||||
gr_complex *out = (gr_complex*)output_items[0];
|
gr_complex *out = (gr_complex*)output_items[0];
|
||||||
|
|
||||||
int noutput = noutput_items;
|
int noutput = noutput_items;
|
||||||
int ninput = std::min(ninput_items[0], ninput_items[1]);
|
int ninput = std::min(std::min(ninput_items[0], ninput_items[1]), ninput_items[2]);
|
||||||
|
|
||||||
// dout << "SHORT noutput : " << noutput << " ninput: " << ninput_items[0] << std::endl;
|
// dout << "SHORT noutput : " << noutput << " ninput: " << ninput_items[0] << std::endl;
|
||||||
|
|
||||||
@@ -64,13 +64,14 @@ int general_work (int noutput_items, gr_vector_int& ninput_items,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < ninput; i++) {
|
for(i = 0; i < ninput; i++) {
|
||||||
if(in2[i] > d_threshold) {
|
if(in_cor[i] > d_threshold) {
|
||||||
if(d_plateau < MIN_PLATEAU) {
|
if(d_plateau < MIN_PLATEAU) {
|
||||||
d_plateau++;
|
d_plateau++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
d_state = COPY;
|
d_state = COPY;
|
||||||
d_copy_left = MAX_SAMPLES;
|
d_copied = 0;
|
||||||
|
d_freq_offset = arg(in_abs[i]) / 16;
|
||||||
d_plateau = 0;
|
d_plateau = 0;
|
||||||
insert_tag(nitems_written(0));
|
insert_tag(nitems_written(0));
|
||||||
dout << "SHORT Frame!" << std::endl;
|
dout << "SHORT Frame!" << std::endl;
|
||||||
@@ -81,23 +82,23 @@ int general_work (int noutput_items, gr_vector_int& ninput_items,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
consume(0, i);
|
consume_each(i);
|
||||||
consume(1, i);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COPY: {
|
case COPY: {
|
||||||
|
|
||||||
int o = 0;
|
int o = 0;
|
||||||
while( (o < ninput) && (o < noutput) && d_copy_left) {
|
while( o < ninput && o < noutput && d_copied < MAX_SAMPLES) {
|
||||||
if(in2[o] > d_threshold) {
|
if(in_cor[o] > d_threshold) {
|
||||||
if(d_plateau < MIN_PLATEAU) {
|
if(d_plateau < MIN_PLATEAU) {
|
||||||
d_plateau++;
|
d_plateau++;
|
||||||
|
|
||||||
// there's another frame
|
// there's another frame
|
||||||
} else if((MAX_SAMPLES - d_copy_left) > MIN_GAP) {
|
} else if(d_copied > MIN_GAP) {
|
||||||
d_copy_left = MAX_SAMPLES;
|
d_copied = 0;
|
||||||
d_plateau = 0;
|
d_plateau = 0;
|
||||||
|
d_freq_offset = arg(in_abs[o]) / 16;
|
||||||
insert_tag(nitems_written(0) + o);
|
insert_tag(nitems_written(0) + o);
|
||||||
dout << "SHORT Frame!" << std::endl;
|
dout << "SHORT Frame!" << std::endl;
|
||||||
break;
|
break;
|
||||||
@@ -107,19 +108,18 @@ int general_work (int noutput_items, gr_vector_int& ninput_items,
|
|||||||
d_plateau = 0;
|
d_plateau = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
out[o] = in[o];
|
out[o] = in[o] * exp(gr_complex(0, -d_freq_offset * d_copied));
|
||||||
o++;
|
o++;
|
||||||
d_copy_left--;
|
d_copied++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!d_copy_left) {
|
if(d_copied == MAX_SAMPLES) {
|
||||||
d_state = SEARCH;
|
d_state = SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
dout << "SHORT copied " << o << std::endl;
|
dout << "SHORT copied " << o << std::endl;
|
||||||
|
|
||||||
consume(0, o);
|
consume_each(o);
|
||||||
consume(1, o);
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,18 +139,16 @@ void insert_tag(uint64_t item) {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
enum {SEARCH, COPY} d_state;
|
enum {SEARCH, COPY} d_state;
|
||||||
int d_copy_left;
|
int d_copied;
|
||||||
int d_plateau;
|
int d_plateau;
|
||||||
|
float d_freq_offset;
|
||||||
const double d_threshold;
|
const double d_threshold;
|
||||||
const bool d_log;
|
const bool d_log;
|
||||||
const bool d_debug;
|
const bool d_debug;
|
||||||
const unsigned int MAX_SAMPLES;
|
|
||||||
const unsigned int MIN_PLATEAU;
|
const unsigned int MIN_PLATEAU;
|
||||||
};
|
};
|
||||||
|
|
||||||
ofdm_sync_short::sptr
|
ofdm_sync_short::sptr
|
||||||
ofdm_sync_short::make(double threshold, unsigned int max_samples,
|
ofdm_sync_short::make(double threshold, unsigned int min_plateau, bool log, bool debug) {
|
||||||
unsigned int min_plateau, bool log, bool debug) {
|
return gnuradio::get_initial_sptr(new ofdm_sync_short_impl(threshold, min_plateau, log, debug));
|
||||||
return gnuradio::get_initial_sptr(new ofdm_sync_short_impl(threshold,
|
|
||||||
max_samples, min_plateau, log, debug));
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user