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
24 from usrp_source import usrp_source_c
25 from gmsk2 import gmsk2_demod
27 _dect_symbol_rate = 1.152e6
28 _dect_occupied_bandwidth = _dect_symbol_rate * 1.03 # BT=0.5
29 _dect_channel_bandwidth = 1.728e6
31 # Top-level hierarchical block that implements DECT demodulation and
33 class dect_receiver(gr.top_block):
34 def __init__(self, options):
35 gr.top_block.__init__(self, "dect_receiver")
36 self._options = options
38 # Need greater than 2 samples per symbol. This makes a decimation
39 # rate of 26 and a samples per symbol of 2.136752
41 self._usrp = usrp_source_c(which=0,
42 subdev_spec=options.rx_subdev_spec,
46 calibration=options.calibration,
47 verbose=options.verbose)
49 # Filter baseband to 1.186 MHz passband, 1.728 MHz stopband
50 chan_taps = optfir.low_pass(1.0, # Gain
51 if_rate, # Sample rate
52 _dect_occupied_bandwidth/2, # One sided modulation bandwidth
53 _dect_channel_bandwidth/2, # One sided channel bandwidth
54 1.0, # Passband ripple (db)
55 60) # Stopband attenuation (db)
56 if self._options.verbose:
57 print "Channel filter has", len(chan_taps), "taps"
58 self._channel_filter = gr.freq_xlating_fir_filter_ccf(1, # Decimation rate
59 chan_taps, # Filter taps
60 0.0, # Offset frequency
61 if_rate) # Sample rate
63 self._demod = gmsk2_demod(samples_per_symbol=if_rate/_dect_symbol_rate,
64 verbose=options.verbose)
66 self._sink = gr.null_sink(gr.sizeof_char)
67 self.connect(self._usrp, self._channel_filter, self._demod, self._sink)
69 # Log baseband to file if requested
70 if options.log_baseband is not None:
72 print "Logging baseband to file", options.log_baseband
73 self.baseband_log = gr.file_sink(gr.sizeof_gr_complex, options.log_baseband)
74 self.connect(self._channel_filter, self.baseband_log)
76 # Log demodulator output to file if requested
77 if options.log_demod is not None:
79 print "Logging demodulator to file", options.log_demod
80 self.demod_log = gr.file_sink(gr.sizeof_char, options.log_demod)
81 self.connect(self._demod, self.demod_log)