def __init__(self, rx_callback, SNR): """ @param options Optparse option field for command line arguments. @param rx_callback Callback function for the event when a packet is received. """ gr.flow_graph.__init__(self) self.samples_per_symbol = 2 self.data_rate = 2000000 payload_size = 128 # bytes self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts( self, spb=self.samples_per_symbol, msgq_limit=2) # add some noise print " Setting SNR to ", SNR add = gr.add_cc() noise = gr.noise_source_c(gr.GR_GAUSSIAN, pow(10.0, -SNR / 20.0)) self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.connect(self.packet_transmitter, (add, 0)) self.connect(noise, (add, 1)) self.connect(add, self.packet_receiver)
def __init__(self, rx_callback, SNR): """ @param options Optparse option field for command line arguments. @param rx_callback Callback function for the event when a packet is received. """ gr.flow_graph.__init__(self) self.samples_per_symbol = 2 self.data_rate = 2000000 payload_size = 128 # bytes self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2) # add some noise print " Setting SNR to ", SNR add = gr.add_cc() noise = gr.noise_source_c(gr.GR_GAUSSIAN, pow(10.0,-SNR/20.0)) self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.connect (self.packet_transmitter, (add,0)) self.connect (noise, (add,1)) self.connect(add, self.packet_receiver)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) print "cordic_freq = %s" % (eng_notation.num_to_str (options.cordic_freq)) # ---------------------------------------------------------------- self.data_rate = options.data_rate self.samples_per_symbol = 2 self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) samp_rate=1e6 u = uhd.usrp_source( device_addr="serial=4c758445", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) u.set_subdev_spec("A:0", 0) u.set_samp_rate(samp_rate) u.set_center_freq(options.cordic_freq, 0) u.set_gain(options.gain, 0) #u = usrp.source_c (0, self.usrp_decim) #if options.rx_subdev_spec is None: # options.rx_subdev_spec = pick_subdevice(u) #u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) #subdev = usrp.selected_subdev(u, options.rx_subdev_spec) # print "Using RX d'board %s" % (subdev.side_and_name(),) # u.tune(0, subdev, options.cordic_freq) #u.set_pga(0, options.gain) #u.set_pga(1, options.gain) self.u = u self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver)
def __init__(self, options, rx_callback): """ @param options Optparse option field for command line arguments. @param rx_callback Callback function for the event when a packet is received. """ gr.flow_graph.__init__(self) print "cordic_freq = %s" % (eng_notation.num_to_str (options.cordic_freq_rx)) # ---------------------------------------------------------------- self.data_rate = options.data_rate self.samples_per_symbol = 2 self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c (0, self.usrp_decim) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (self.subdev.side_and_name(),) #self.subdev.select_rx_antenna('RX2') u.tune(0, self.subdev, options.cordic_freq_rx) u.set_pga(0, options.gain) u.set_pga(1, options.gain) self.u = u self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) #self.file_sink = gr.file_sink(gr.sizeof_gr_complex, "/dev/null") self.connect(self.u, self.squelch, self.packet_receiver) #self.connect(self.u, self.file_sink) self.set_auto_tr(True) # enable Auto Transmit/Receive switching
def __init__(self, options, rx_callback): gr.top_block.__init__(self) print "cordic_freq = %s" % (eng_notation.num_to_str( options.cordic_freq)) # ---------------------------------------------------------------- self.data_rate = options.data_rate self.samples_per_symbol = 2 self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c(0, self.usrp_decim) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (subdev.side_and_name(), ) u.tune(0, subdev, options.cordic_freq) u.set_pga(0, options.gain) u.set_pga(1, options.gain) self.u = u self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) if options.infile is None: # Initialize USRP2 block u = usrp2.source_32fc(options.interface, options.mac_addr) self.samples_per_symbol = 2 self.chan_num = options.channel self.data_rate = int(u.adc_rate() / self.samples_per_symbol / options.decim_rate) u.set_center_freq(ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num]) u.set_decim(options.decim_rate) u.set_gain(options.gain) print "cordic_freq = %s" % (eng_notation.num_to_str(ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num])) print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", options.decim_rate self.src = u else: self.src = gr.file_source(gr.sizeof_gr_complex, options.infile) self.samples_per_symbol = 2 self.data_rate = 2000000 self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, channel=self.chan_num, threshold=options.threshold, ) # self.squelch = gr.pwr_squelch_cc(-65, gate=True) self.connect( self.src, # self.squelch, self.packet_receiver, )
def __init__(self, options, rx_callback): gr.top_block.__init__(self) print "cordic_freq = %s" % (eng_notation.num_to_str (options.cordic_freq)) # ---------------------------------------------------------------- self.data_rate = options.data_rate self.samples_per_symbol = 2 self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c (0, self.usrp_decim) if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(u) u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec)) subdev = usrp.selected_subdev(u, options.rx_subdev_spec) print "Using RX d'board %s" % (subdev.side_and_name(),) u.tune(0, subdev, options.cordic_freq) u.set_pga(0, options.gain) u.set_pga(1, options.gain) self.u = u #self.u = gr.file_source(gr.sizeof_gr_complex, 'rx_test.dat') self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver)
def __init__(self, rx_callback): gr.top_block.__init__(self) self.data_rate = 2000000 self.samples_per_symbol = 2 self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) self.u = usrp.source_c(0, self.usrp_decim) self.picksubdev = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.picksubdev)) self.subdev = usrp.selected_subdev(self.u, pick_subdevice(self.u)) print "Using RX d'board %s" % (self.subdev.side_and_name(), ) #self.u.tune(0, self.subdev, 2475000000) #self.u.tune(0, self.subdev, 2480000000) self.u.tune(0, self.subdev, 2425000000) self.u.set_pga(0, 0) self.u.set_pga(1, 0) # receiver self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver) # enable Auto Transmit/Receive switching self.set_auto_tr(True)
def __init__(self, rx_callback): gr.top_block.__init__(self) self.data_rate = 2000000 self.samples_per_symbol = 2 self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) self.u = usrp.source_c (0, self.usrp_decim) self.picksubdev = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.picksubdev)) self.subdev = usrp.selected_subdev(self.u, pick_subdevice(self.u)) print "Using RX d'board %s" % (self.subdev.side_and_name(),) #self.u.tune(0, self.subdev, 2475000000) #self.u.tune(0, self.subdev, 2480000000) self.u.tune(0, self.subdev, 2425000000) self.u.set_pga(0, 0) self.u.set_pga(1, 0) # receiver self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect(self.u, self.squelch, self.packet_receiver) # enable Auto Transmit/Receive switching self.set_auto_tr(True)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) if options.infile is not None: self.chan_num = options.channel u = gr.file_source(gr.sizeof_gr_complex, options.infile) elif (options.rx_freq) is not None or (options.channel is not None): if options.channel is not None: self.chan_num = options.channel options.rx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[ self.chan_num] u = uhd_receiver(options.rx_args, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose, options.external) else: sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.samples_per_symbol = 2 self.data_rate = options.bandwidth / self.samples_per_symbol self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, channel=self.chan_num, threshold=options.threshold, log=options.log) self.src = u #self.squelch = gr.pwr_squelch_cc(-65, gate=True) self.connect( self.src, # self.squelch, self.packet_receiver)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) if options.infile is None: # Initialize USRP2 block u = usrp2.source_32fc(options.interface, options.mac_addr) self.samples_per_symbol = 2 self.chan_num = options.channel self.data_rate = int (u.adc_rate() / self.samples_per_symbol / options.decim_rate) u.set_center_freq(ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num]) u.set_decim(options.decim_rate) u.set_gain(options.gain) print "cordic_freq = %s" % (eng_notation.num_to_str(ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num])) print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", options.decim_rate self.src = u else: self.src = gr.file_source(gr.sizeof_gr_complex, options.infile); self.samples_per_symbol = 2 self.data_rate = 2000000 self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, channel=self.chan_num, threshold=options.threshold) #self.squelch = gr.pwr_squelch_cc(-65, gate=True) self.connect(self.src, # self.squelch, self.packet_receiver)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) if options.infile is not None: self.chan_num = options.channel u = gr.file_source(gr.sizeof_gr_complex, options.infile) elif (options.rx_freq) is not None or (options.channel is not None): if options.channel is not None: self.chan_num = options.channel options.rx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num] u = uhd_receiver(options.rx_args, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose, options.external) else: sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.samples_per_symbol = 2 self.data_rate = options.bandwidth / self.samples_per_symbol self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback, sps=self.samples_per_symbol, symbol_rate=self.data_rate, channel=self.chan_num, threshold=options.threshold, log=options.log) self.src = u #self.squelch = gr.pwr_squelch_cc(-65, gate=True) self.connect(self.src, # self.squelch, self.packet_receiver)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) u = usrp2.source_32fc(options.interface, options.mac_addr) self.usrp_decim = 4 self.samples_per_symbol = 2 self.filter_decim = 5 self.resamp_interp = 4 self.resamp_decim = 5 self.data_rate = int (u.adc_rate() / self.samples_per_symbol / self.usrp_decim / self.filter_decim * self.resamp_interp / self.resamp_decim) self.sampling_rate = int (u.adc_rate() / self.usrp_decim) print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "usrp2_gain = ", options.gain print "Squelch filter = ", options.squelch self.chan1_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[options.channel1] self.chan1_num = options.channel1 self.chan2_num = self.chan1_num + 1 self.chan3_num = self.chan2_num + 1 self.chan4_num = self.chan3_num + 1 self.chan5_num = self.chan4_num + 1 self.chan5_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan5_num] self.usrp_freq = (self.chan1_freq + self.chan5_freq) / 2 self.chan1_offset = self.usrp_freq - self.chan1_freq self.chan2_offset = self.chan1_offset - 5000000 self.chan3_offset = self.chan2_offset - 5000000 self.chan4_offset = self.chan3_offset - 5000000 self.chan5_offset = self.chan4_offset - 5000000 print "Centering USRP2 at = ", self.usrp_freq print "Channel ", self.chan1_num, " freq = ", self.usrp_freq - self.chan1_offset print "Channel ", self.chan2_num, " freq = ", self.usrp_freq - self.chan2_offset print "Channel ", self.chan3_num, " freq = ", self.usrp_freq - self.chan3_offset print "Channel ", self.chan4_num, " freq = ", self.usrp_freq - self.chan4_offset print "Channel ", self.chan5_num, " freq = ", self.usrp_freq - self.chan5_offset u.set_center_freq(self.usrp_freq) u.set_decim(self.usrp_decim) u.set_gain(options.gain) # Creating a filter for channel selection chan_coeffs = gr.firdes.low_pass( 1.0, # filter gain self.sampling_rate, # sampling rate 2e6, # cutoff frequency 2e6, # bandwidth gr.firdes.WIN_HANN) # filter type print "Length of chan_coeffs = ", len(chan_coeffs) # Decimating channel filters self.ddc1 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan1_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.ddc2 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan2_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.ddc3 = gr.fir_filter_ccf(self.filter_decim, chan_coeffs) self.ddc4 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan4_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.ddc5 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan5_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.packet_receiver1 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan1_num, threshold=-1) self.packet_receiver2 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan2_num, threshold=-1) self.packet_receiver3 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan3_num, threshold=-1) self.packet_receiver4 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan4_num, threshold=-1) self.packet_receiver5 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan5_num, threshold=-1) self.resampler1 = blks2.rational_resampler_ccf(self.resamp_interp,self.resamp_decim) self.resampler2 = blks2.rational_resampler_ccf(self.resamp_interp,self.resamp_decim) self.resampler3 = blks2.rational_resampler_ccf(self.resamp_interp,self.resamp_decim) self.resampler4 = blks2.rational_resampler_ccf(self.resamp_interp,self.resamp_decim) self.resampler5 = blks2.rational_resampler_ccf(self.resamp_interp,self.resamp_decim) self.u = u self.squelch = gr.pwr_squelch_cc(options.squelch, gate=True) self.connect(self.u,self.squelch) self.connect(self.squelch, self.ddc1, self.resampler1, self.packet_receiver1) self.connect(self.squelch, self.ddc2, self.resampler2, self.packet_receiver2) self.connect(self.squelch, self.ddc3, self.resampler3, self.packet_receiver3) self.connect(self.squelch, self.ddc4, self.resampler4, self.packet_receiver4) self.connect(self.squelch, self.ddc5, self.resampler5, self.packet_receiver5)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) u = uhd.usrp_source(device_addr="addr0=192.168.20.4", stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1))) self.usrp_decim = 5 self.sampling_rate = 100e6 / self.usrp_decim u.set_samp_rate(self.sampling_rate) # WiFi Channel 6 self.usrp_freq = 2.437e9 u.set_center_freq(self.usrp_freq) options.gain = 20 u.set_gain(options.gain) u.set_subdev_spec("A:0", 0) u.set_antenna("TX/RX", 0) self.samples_per_symbol = 2 self.filter_decim = 5 self.data_rate = int(self.sampling_rate / self.samples_per_symbol / self.filter_decim) print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "usrp2_gain = ", options.gain # ZigBee Channel 17 self.chan1_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[ options.channel1] self.chan1_num = options.channel1 self.chan1_offset = self.usrp_freq - self.chan1_freq print "Centering USRP2 at = ", self.usrp_freq print "Channel ", self.chan1_num, " freq = ", self.usrp_freq - self.chan1_offset # Creating a filter for channel selection chan_coeffs = gr.firdes.low_pass( 1.0, # filter gain self.sampling_rate, # sampling rate 2e6, # cutoff frequency 2e6, # bandwidth gr.firdes.WIN_HANN) # filter type #print "Length of chan_coeffs = ", len(chan_coeffs) #print chan_coeffs # Decimating channel filters self.ddc1 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan1_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.packet_receiver1 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan1_num, threshold=-1, log=options.log) self.u = u self.squelch = gr.pwr_squelch_cc(options.squelch, gate=True) self.connect(self.u, self.squelch) self.connect(self.squelch, self.ddc1, self.packet_receiver1) self.connect(self.ddc1, gr.file_sink(gr.sizeof_gr_complex, 'wifi-zigbee-ddc.dat'))
def __init__(self, rx_callback_cc2420, rx_callback_cc1k): gr.flow_graph.__init__(self) cc2420_cordic_freq = 2475000000 cc2420_data_rate = 2000000 cc1k_cordic_freq = 434845200 cc1k_data_rate = 38400 cc1k_sps = 8 payload_size = 128 print "cc2420_cordic_freq = %s" % ( eng_notation.num_to_str(cc2420_cordic_freq)) print "cc1k_cordic_freq = %s" % ( eng_notation.num_to_str(cc1k_cordic_freq)) # ---------------------------------------------------------------- self.data_rate = cc2420_data_rate self.samples_per_symbol = 2 self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c(0, nchan=2) u.set_decim_rate(self.usrp_decim) self.subdev = (u.db[0][0], u.db[1][0]) print "Using RX d'board %s" % (self.subdev[0].side_and_name(), ) print "Using RX d'board %s" % (self.subdev[1].side_and_name(), ) u.set_mux(0x2301) width = 8 shift = 8 format = u.make_format(width, shift) r = u.set_format(format) #this is the cc2420 code u.tune(self.subdev[0]._which, self.subdev[0], cc2420_cordic_freq) u.tune(self.subdev[1]._which, self.subdev[1], cc1k_cordic_freq) u.set_pga(0, 0) u.set_pga(1, 0) self.u = u # deinterleave two channels from FPGA di = gr.deinterleave(gr.sizeof_gr_complex) # wire up the head of the chain self.connect(self.u, di) #self.u = gr.file_source(gr.sizeof_gr_complex, 'rx_test.dat') # CC2420 receiver self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback_cc2420, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect((di, 0), self.squelch, self.packet_receiver) # CC1K receiver gain_mu = 0.002 * self.samples_per_symbol self.packet_receiver_cc1k = cc1k_sos_pkt.cc1k_demod_pkts( self, callback=rx_callback_cc1k, sps=cc1k_sps, symbol_rate=cc1k_data_rate, p_size=payload_size, threshold=-1) #self.squelch2 = gr.pwr_squelch_cc(50, 1, 0, True) keep = gr.keep_one_in_n(gr.sizeof_gr_complex, 13) #self.connect((di, 1), keep, self.squelch2, self.packet_receiver_cc1k) self.connect((di, 1), keep, self.packet_receiver_cc1k)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) u = uhd.usrp_source(device_addr="addr0=192.168.20.4",stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1))) self.usrp_decim = 5 self.sampling_rate = 100e6 / self.usrp_decim u.set_samp_rate(self.sampling_rate) # WiFi Channel 6 self.usrp_freq = 2.437e9 u.set_center_freq(self.usrp_freq) options.gain = 20 u.set_gain(options.gain) u.set_subdev_spec("A:0", 0) u.set_antenna("TX/RX", 0) self.samples_per_symbol = 2 self.filter_decim = 5 self.data_rate = int (self.sampling_rate / self.samples_per_symbol / self.filter_decim) print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "usrp2_gain = ", options.gain # ZigBee Channel 17 self.chan1_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[options.channel1] self.chan1_num = options.channel1 self.chan1_offset = self.usrp_freq - self.chan1_freq print "Centering USRP2 at = ", self.usrp_freq print "Channel ", self.chan1_num, " freq = ", self.usrp_freq - self.chan1_offset # Creating a filter for channel selection chan_coeffs = gr.firdes.low_pass( 1.0, # filter gain self.sampling_rate, # sampling rate 2e6, # cutoff frequency 2e6, # bandwidth gr.firdes.WIN_HANN) # filter type #print "Length of chan_coeffs = ", len(chan_coeffs) #print chan_coeffs # Decimating channel filters self.ddc1 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan1_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.packet_receiver1 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan1_num, threshold=-1, log=options.log) self.u = u self.squelch = gr.pwr_squelch_cc(options.squelch, gate=True) self.connect(self.u,self.squelch) self.connect(self.squelch, self.ddc1, self.packet_receiver1) self.connect(self.ddc1, gr.file_sink(gr.sizeof_gr_complex, 'wifi-zigbee-ddc.dat'))
def __init__(self, rx_callback_cc2420, rx_callback_cc1k): gr.flow_graph.__init__(self) cc2420_cordic_freq = 2475000000 cc2420_data_rate = 2000000 cc1k_cordic_freq = 434845200 cc1k_data_rate = 38400 cc1k_sps = 8 payload_size = 128 print "cc2420_cordic_freq = %s" % (eng_notation.num_to_str (cc2420_cordic_freq)) print "cc1k_cordic_freq = %s" % (eng_notation.num_to_str (cc1k_cordic_freq)) # ---------------------------------------------------------------- self.data_rate = cc2420_data_rate self.samples_per_symbol = 2 self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate) self.fs = self.data_rate * self.samples_per_symbol payload_size = 128 # bytes print "usrp_decim = ", self.usrp_decim print "fs = ", eng_notation.num_to_str(self.fs) u = usrp.source_c (0, nchan=2) u.set_decim_rate(self.usrp_decim) self.subdev = (u.db[0][0], u.db[1][0]) print "Using RX d'board %s" % (self.subdev[0].side_and_name(),) print "Using RX d'board %s" % (self.subdev[1].side_and_name(),) u.set_mux(0x2301) width = 8 shift = 8 format = u.make_format(width, shift) r = u.set_format(format) #this is the cc2420 code u.tune(self.subdev[0]._which, self.subdev[0], cc2420_cordic_freq) u.tune(self.subdev[1]._which, self.subdev[1], cc1k_cordic_freq) u.set_pga(0, 0) u.set_pga(1, 0) self.u = u # deinterleave two channels from FPGA di = gr.deinterleave(gr.sizeof_gr_complex) # wire up the head of the chain self.connect(self.u, di) #self.u = gr.file_source(gr.sizeof_gr_complex, 'rx_test.dat') # CC2420 receiver self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self, callback=rx_callback_cc2420, sps=self.samples_per_symbol, symbol_rate=self.data_rate, threshold=-1) self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) self.connect((di,0), self.squelch, self.packet_receiver) # CC1K receiver gain_mu = 0.002*self.samples_per_symbol self.packet_receiver_cc1k = cc1k_sos_pkt.cc1k_demod_pkts(self, callback=rx_callback_cc1k, sps=cc1k_sps, symbol_rate=cc1k_data_rate, p_size=payload_size, threshold=-1) #self.squelch2 = gr.pwr_squelch_cc(50, 1, 0, True) keep = gr.keep_one_in_n(gr.sizeof_gr_complex, 13) #self.connect((di, 1), keep, self.squelch2, self.packet_receiver_cc1k) self.connect((di, 1), keep, self.packet_receiver_cc1k)
def __init__(self, options, rx_callback): gr.top_block.__init__(self) u = usrp2.source_32fc(options.interface, options.mac_addr) self.usrp_decim = 4 self.samples_per_symbol = 2 self.filter_decim = 5 self.resamp_interp = 4 self.resamp_decim = 5 self.data_rate = int(u.adc_rate() / self.samples_per_symbol / self.usrp_decim / self.filter_decim * self.resamp_interp / self.resamp_decim) self.sampling_rate = int(u.adc_rate() / self.usrp_decim) print "data_rate = ", eng_notation.num_to_str(self.data_rate) print "samples_per_symbol = ", self.samples_per_symbol print "usrp_decim = ", self.usrp_decim print "usrp2_gain = ", options.gain print "Squelch filter = ", options.squelch self.chan1_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[ options.channel1] self.chan1_num = options.channel1 self.chan2_num = self.chan1_num + 1 self.chan3_num = self.chan2_num + 1 self.chan4_num = self.chan3_num + 1 self.chan5_num = self.chan4_num + 1 self.chan5_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[ self.chan5_num] self.usrp_freq = (self.chan1_freq + self.chan5_freq) / 2 self.chan1_offset = self.usrp_freq - self.chan1_freq self.chan2_offset = self.chan1_offset - 5000000 self.chan3_offset = self.chan2_offset - 5000000 self.chan4_offset = self.chan3_offset - 5000000 self.chan5_offset = self.chan4_offset - 5000000 print "Centering USRP2 at = ", self.usrp_freq print "Channel ", self.chan1_num, " freq = ", self.usrp_freq - self.chan1_offset print "Channel ", self.chan2_num, " freq = ", self.usrp_freq - self.chan2_offset print "Channel ", self.chan3_num, " freq = ", self.usrp_freq - self.chan3_offset print "Channel ", self.chan4_num, " freq = ", self.usrp_freq - self.chan4_offset print "Channel ", self.chan5_num, " freq = ", self.usrp_freq - self.chan5_offset u.set_center_freq(self.usrp_freq) u.set_decim(self.usrp_decim) u.set_gain(options.gain) # Creating a filter for channel selection chan_coeffs = gr.firdes.low_pass( 1.0, # filter gain self.sampling_rate, # sampling rate 2e6, # cutoff frequency 2e6, # bandwidth gr.firdes.WIN_HANN) # filter type print "Length of chan_coeffs = ", len(chan_coeffs) # Decimating channel filters self.ddc1 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan1_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.ddc2 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan2_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.ddc3 = gr.fir_filter_ccf(self.filter_decim, chan_coeffs) self.ddc4 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan4_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.ddc5 = gr.freq_xlating_fir_filter_ccf( self.filter_decim, # decimation rate chan_coeffs, # taps self.chan5_offset, # frequency translation amount self.sampling_rate) # input sampling rate self.packet_receiver1 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan1_num, threshold=-1) self.packet_receiver2 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan2_num, threshold=-1) self.packet_receiver3 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan3_num, threshold=-1) self.packet_receiver4 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan4_num, threshold=-1) self.packet_receiver5 = ieee802_15_4_pkt.ieee802_15_4_demod_pkts( self, callback=rx_callback, sps=self.samples_per_symbol, channel=self.chan5_num, threshold=-1) self.resampler1 = blks2.rational_resampler_ccf(self.resamp_interp, self.resamp_decim) self.resampler2 = blks2.rational_resampler_ccf(self.resamp_interp, self.resamp_decim) self.resampler3 = blks2.rational_resampler_ccf(self.resamp_interp, self.resamp_decim) self.resampler4 = blks2.rational_resampler_ccf(self.resamp_interp, self.resamp_decim) self.resampler5 = blks2.rational_resampler_ccf(self.resamp_interp, self.resamp_decim) self.u = u self.squelch = gr.pwr_squelch_cc(options.squelch, gate=True) self.connect(self.u, self.squelch) self.connect(self.squelch, self.ddc1, self.resampler1, self.packet_receiver1) self.connect(self.squelch, self.ddc2, self.resampler2, self.packet_receiver2) self.connect(self.squelch, self.ddc3, self.resampler3, self.packet_receiver3) self.connect(self.squelch, self.ddc4, self.resampler4, self.packet_receiver4) self.connect(self.squelch, self.ddc5, self.resampler5, self.packet_receiver5)