3 # Copyright 2007 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
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)
12 # GNU Radio is distributed in the hope that it will be useful,
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.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, optfir, blks2
24 from usrp_source import usrp_source_c
26 _dect_symbol_rate = 1.152e6
27 _dect_occupied_bandwidth = _dect_symbol_rate * 1.03 # BT=0.5
28 _dect_channel_bandwidth = 1.728e6
30 # Top-level hierarchical block that implements DECT demodulation and
32 class dect_receiver(gr.top_block):
33 def __init__(self, options):
34 gr.top_block.__init__(self, "dect_receiver")
35 self._options = options
37 # Need greater than 2 samples per symbol. This makes a decimation
38 # rate of 26 and a samples per symbol of 2.136752
40 self._usrp = usrp_source_c(which=0,
41 subdev_spec=options.rx_subdev_spec,
45 calibration=options.calibration,
46 verbose=options.verbose)
48 # Filter baseband to 1.186 MHz passband, 1.728 MHz stopband
49 chan_taps = optfir.low_pass(1.0, # Gain
50 if_rate, # Sample rate
51 _dect_occupied_bandwidth/2, # One sided modulation bandwidth
52 _dect_channel_bandwidth/2, # One sided channel bandwidth
53 1.0, # Passband ripple (db)
54 60) # Stopband attenuation (db)
55 if self._options.verbose:
56 print "Channel filter has", len(chan_taps), "taps"
57 self._channel_filter = gr.freq_xlating_fir_filter_ccf(1, # Decimation rate
58 chan_taps, # Filter taps
59 0.0, # Offset frequency
60 if_rate) # Sample rate
62 self._demod = blks2.gmsk_demod(samples_per_symbol=if_rate/_dect_symbol_rate,
63 verbose=options.verbose)
65 self._sink = gr.null_sink(gr.sizeof_char)
66 self.connect(self._usrp, self._channel_filter, self._demod, self._sink)
68 # Log baseband to file if requested
69 if options.log_baseband is not None:
71 print "Logging baseband to file", options.log_baseband
72 self.baseband_log = gr.file_sink(gr.sizeof_gr_complex, options.log_baseband)
73 self.connect(self._channel_filter, self.baseband_log)
75 # Log demodulator output to file if requested
76 if options.log_demod is not None:
78 print "Logging demodulator to file", options.log_demod
79 self.demod_log = gr.file_sink(gr.sizeof_char, options.log_demod)
80 self.connect(self._demod, self.demod_log)