GNU Radio's FOOT Package
bluetooth_multi_block.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008, 2009 Dominic Spill, Michael Ossmann
4  * Copyright 2007 Dominic Spill
5  * Copyright 2005, 2006 Free Software Foundation, Inc.
6  *
7  * This file is part of gr-bluetooth
8  *
9  * gr-bluetooth is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * gr-bluetooth is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with gr-bluetooth; see the file COPYING. If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street,
22  * Boston, MA 02110-1301, USA.
23  */
24 //FIXME this file should not be here - copied from gr-bluetooth/src/lib
25 #ifndef INCLUDED_BLUETOOTH_MULTI_BLOCK_H
26 #define INCLUDED_BLUETOOTH_MULTI_BLOCK_H
27 
28 #include <gnuradio/sync_block.h>
29 #include <stdint.h>
30 #include <gnuradio/analog/pwr_squelch_cc.h>
31 #include <gnuradio/filter/freq_xlating_fir_filter_ccf.h>
32 #include <gnuradio/analog/quadrature_demod_cf.h>
33 #include <gnuradio/digital/clock_recovery_mm_ff.h>
34 #include <gnuradio/digital/binary_slicer_fb.h>
35 #include <gnuradio/filter/mmse_fir_interpolator_ff.h>
36 
37 /*!
38  * \brief Bluetooth multi-channel parent class.
39  * \ingroup block
40  */
41 class bluetooth_multi_block : public gr::sync_block
42 {
43 protected:
44  /* constructor */
45  bluetooth_multi_block(double sample_rate, double center_freq, double squelch_threshold);
46 
47  /* symbols per second */
48  static const int SYMBOL_RATE = 1000000;
49 
50  /* length of time slot in symbols */
51  static const int SYMBOLS_PER_SLOT = 625;
52 
53  /* channel 0 in Hz */
54  static const uint32_t BASE_FREQUENCY = 2402000000UL;
55 
56  /* channel width in Hz */
57  static const int CHANNEL_WIDTH = 1000000;
58 
59  /* total number of samples elapsed */
61 
62  /* sample rate of raw input stream */
63  double d_sample_rate;
64 
65  /* number of raw samples per symbol */
67 
68  /* number of raw samples per time slot (625 microseconds) */
70 
71  /* center frequency of input stream */
72  double d_center_freq;
73 
74  /* lowest channel (0-78) we can decode */
76 
77  /* highest channel (0-78) we can decode */
79 
80  /* power squelch threshold normalized for comparison in channel_symbols() */
82 
83  /* decimation rate of digital downconverter */
85 
86  /* mm_cr variables */
87  float d_gain_mu; // gain for adjusting mu
88  float d_mu; // fractional sample position [0.0, 1.0]
89  float d_omega_relative_limit; // used to compute min and max omega
90  float d_omega; // nominal frequency
91  float d_gain_omega; // gain for adjusting omega
92  float d_omega_mid; // average omega
94 
95  /* channel filter coefficients for digital downconverter */
96  std::vector<float> d_channel_filter;
97 
98  /* quadrature frequency demodulator sensitivity */
99  float d_demod_gain;
100 
101  /* interpolator M&M clock recovery block */
102  gr::filter::mmse_fir_interpolator_ff *d_interp;
103 
104  /* M&M clock recovery, adapted from gr_clock_recovery_mm_ff */
105  int mm_cr(const float *in, int ninput_items, float *out, int noutput_items);
106 
107  /* fm demodulation, taken from gr_quadrature_demod_cf */
108  void demod(const gr_complex *in, float *out, int noutput_items);
109 
110  /* binary slicer, similar to gr_binary_slicer_fb */
111  void slicer(const float *in, char *out, int noutput_items);
112 
113  /* produce symbols stream for a particular channel pulled out of the raw samples */
114  int channel_symbols(int channel, gr_vector_const_void_star &in, char *out, int ninput_items);
115 
116  /* add some number of symbols to the block's history requirement */
117  void set_symbol_history(int num_symbols);
118 
119  /* set available channels based on d_center_freq and d_sample_rate */
120  void set_channels();
121 
122  /* returns relative (with respect to d_center_freq) frequency in Hz of given channel */
123  double channel_freq(int channel);
124 };
125 
126 #endif /* INCLUDED_BLUETOOTH_MULTI_BLOCK_H */
double channel_freq(int channel)
float d_omega
Definition: bluetooth_multi_block.h:90
gr::filter::mmse_fir_interpolator_ff * d_interp
Definition: bluetooth_multi_block.h:102
bluetooth_multi_block(double sample_rate, double center_freq, double squelch_threshold)
double d_center_freq
Definition: bluetooth_multi_block.h:72
int mm_cr(const float *in, int ninput_items, float *out, int noutput_items)
void slicer(const float *in, char *out, int noutput_items)
static const uint32_t BASE_FREQUENCY
Definition: bluetooth_multi_block.h:54
float d_omega_relative_limit
Definition: bluetooth_multi_block.h:89
Bluetooth multi-channel parent class.
Definition: bluetooth_multi_block.h:41
double d_samples_per_slot
Definition: bluetooth_multi_block.h:69
uint64_t d_cumulative_count
Definition: bluetooth_multi_block.h:60
int d_high_channel
Definition: bluetooth_multi_block.h:78
float d_omega_mid
Definition: bluetooth_multi_block.h:92
double d_squelch_threshold
Definition: bluetooth_multi_block.h:81
static const int SYMBOLS_PER_SLOT
Definition: bluetooth_multi_block.h:51
float d_demod_gain
Definition: bluetooth_multi_block.h:99
int channel_symbols(int channel, gr_vector_const_void_star &in, char *out, int ninput_items)
static const int SYMBOL_RATE
Definition: bluetooth_multi_block.h:48
float d_gain_omega
Definition: bluetooth_multi_block.h:91
float d_last_sample
Definition: bluetooth_multi_block.h:93
float d_mu
Definition: bluetooth_multi_block.h:88
std::vector< float > d_channel_filter
Definition: bluetooth_multi_block.h:96
float d_gain_mu
Definition: bluetooth_multi_block.h:87
void demod(const gr_complex *in, float *out, int noutput_items)
double d_sample_rate
Definition: bluetooth_multi_block.h:63
void set_symbol_history(int num_symbols)
static const int CHANNEL_WIDTH
Definition: bluetooth_multi_block.h:57
int d_low_channel
Definition: bluetooth_multi_block.h:75
int d_ddc_decimation_rate
Definition: bluetooth_multi_block.h:84
double d_samples_per_symbol
Definition: bluetooth_multi_block.h:66