def __init__(self, chan_est=1, encoding=0, freq_offset=0, interval=500, nmessages=50, snr=10):
        gr.top_block.__init__(self, "Wifi Loopback Nogui")

        ##################################################
        # Parameters
        ##################################################
        self.chan_est = chan_est
        self.encoding = encoding
        self.freq_offset = freq_offset
        self.interval = interval
        self.nmessages = nmessages
        self.snr = snr

        ##################################################
        # Variables
        ##################################################
        self.out_buf_size = out_buf_size = 96000

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            encoding=encoding,
            chan_est=chan_est,
        )
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.intern("Hello World!"), interval, nmessages, True, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 1000, 1000)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=.5**.5,
        	frequency_offset=freq_offset,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, ))
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm_n" + str(nmessages) + "_s" + str(snr) + "_e" + str(encoding) + "_i" + str(interval) + ".pcap", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))    
    def __init__(self, chan_est=1, dopp=400, encoding=0, freq_offset=0, interval=500, nmessages=50, ntrials=0, resultdir="0", snr=10):
        gr.top_block.__init__(self, "Wifi Loopback Nogui")

        ##################################################
        # Parameters
        ##################################################
        self.chan_est = chan_est
        self.dopp = dopp
        self.encoding = encoding
        self.freq_offset = freq_offset
        self.interval = interval
        self.nmessages = nmessages
        self.ntrials = ntrials
        self.resultdir = resultdir
        self.snr = snr

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.out_buf_size = out_buf_size = 96000
        self.ndopp = ndopp = dopp/samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            encoding=encoding,
            chan_est=chan_est,
        )
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.intern("Hello World!"), interval, nmessages, True, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 1000, 1000)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ndopp, False, 4.0, ntrials, (0, 0.00003, 0.000064, 0.0032, 0.003232, 0.0064, 0.006432, 0.006464, 0.0096, 0.009632, 0.009664), (1, 1, 1, 0.234, 0.234, 0.003, 0.003, 0.003, 0.005, 0.005, 0.005), 8 )
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((((10**(snr/10.0))**0.5)/(2**0.5), ))
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "" + resultdir + "/ofdm_" + str(ntrials) + "_" + str(nmessages) + "_" + str(snr) + "_" + str(encoding) + "_" + str(interval) + ".pcap", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_selective_fading_model_0, 0))    
        self.connect((self.channels_selective_fading_model_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))    
Esempio n. 3
0
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.gain = gain = 50
        self.freq = freq = 2.45e9

        ##################################################
        # Blocks
        ##################################################
        self.rftap_rftap_encap_0 = rftap.rftap_encap(2, 195, "")
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(4e6)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.epy_block_0 = blk()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, zb_file, False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.epy_block_0, 'out'), (self.rftap_rftap_encap_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.epy_block_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))    
Esempio n. 4
0
    def __init__(self):
        gr.top_block.__init__(self, "TFG")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TFG")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "testNWK")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Blocks
        ##################################################
        self.tfg_test_nwk_0 = tfg.test_nwk()
        self.tfg_NWK_stack_0 = tfg.NWK_stack(True, True)
        self.tfg_MAC_stack_0 = tfg.MAC_stack(False, False)
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, True, 0.1, 2000, 2000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("A"), 1000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.tfg_test_nwk_0, 'entrada'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.tfg_MAC_stack_0, 'in(PHY)'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(PHY)'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(PHY)'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(NWK)'), (self.tfg_NWK_stack_0, 'in(MAC)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(MAC)'), (self.tfg_MAC_stack_0, 'in(NWK)'))    
        self.msg_connect((self.tfg_test_nwk_0, 'salida'), (self.tfg_NWK_stack_0, 'in(APS)'))    
        self.connect((self.foo_packet_pad_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.foo_packet_pad_0, 0))    
Esempio n. 5
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Rx")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 5e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 20
        self.freq = freq = 943000000.0
        self.chan_est = chan_est = 1

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [1e6, 5e6, 10e6, 20e6]
        self._samp_rate_labels = ["1 MHz", "5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self.qtgui_time_sink_x_1_0_0_0 = qtgui.time_sink_f(
            1024 * 16 * 4,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0_0.set_y_axis(-0.1, 1.4)

        self.qtgui_time_sink_x_1_0_0_0.set_y_label("Amplitude ----", "")

        self.qtgui_time_sink_x_1_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.63, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1_0_0_0.disable_legend()

        labels = ["RATIO", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_0_win)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f(
            1024 * 16 * 4,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-0.001, 0.2)

        self.qtgui_time_sink_x_1_0_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.05, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1_0_0.disable_legend()

        labels = ["Power av.", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
            1024 * 16 * 4,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-0.001, 0.2)

        self.qtgui_time_sink_x_1_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                    qtgui.TRIG_SLOPE_POS, 0.05,
                                                    0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

        labels = ["Correlation av.", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.nutaq_rtdex_source_0 = nutaq.rtdex_source(
            "nutaq_carrier_perseus_0", gr.sizeof_short, 1, 3)
        self.nutaq_rtdex_source_0.set_type(0)
        self.nutaq_rtdex_source_0.set_packet_size(8192)
        self.nutaq_rtdex_source_0.set_channels("1")
        self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx(
            "nutaq_carrier_perseus_0", 1, 0)
        self.nutaq_radio420_tx_0_0.set_default_enable(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_freq(943e6)
        self.nutaq_radio420_tx_0_0.set_default_reference(0)
        self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate * 2)
        self.nutaq_radio420_tx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0_0.set_default_band(0)
        self.nutaq_radio420_tx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(6)
        self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0)

        self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0",
                                                     1, 1)
        self.nutaq_radio420_rx_0.set_default_enable(1)
        self.nutaq_radio420_rx_0.set_default_rx_freq(943e6)
        self.nutaq_radio420_rx_0.set_default_reference(0)
        self.nutaq_radio420_rx_0.set_default_datarate(samp_rate * 2)
        self.nutaq_radio420_rx_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0.set_default_band(0)
        self.nutaq_radio420_rx_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(1)
        self.nutaq_radio420_rx_0.set_default_rx_gain2(16)
        self.nutaq_radio420_rx_0.set_default_rx_gain3(5)
        self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0)

        self.nutaq_custom_register_0_0 = nutaq.custom_register(
            "nutaq_carrier_perseus_0", 5)
        self.nutaq_custom_register_0_0.set_index(4)
        self.nutaq_custom_register_0_0.set_update_rate(1)

        self.nutaq_custom_register_0 = nutaq.custom_register(
            "nutaq_carrier_perseus_0", 4)
        self.nutaq_custom_register_0.set_index(1)
        self.nutaq_custom_register_0.set_default_value(6)
        self.nutaq_custom_register_0.set_update_rate(1)

        self.nutaq_carrier_perseus_0 = nutaq.carrier(
            0, "nutaq_carrier_perseus_0", "192.168.0.103")
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(
            0.85 * 0.75, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(
            sync_length, False, False)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(
            ieee802_11.LMS, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(
            False, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(
            True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self._gain_range = Range(0, 100, 1, 20, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain",
                                     "slider")
        self.top_layout.addWidget(self._gain_win)
        self._freq_options = [
            943000000.0, 2412000000.0, 2417000000.0, 2422000000.0,
            2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0,
            2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0,
            2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0,
            5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0,
            5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0,
            5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0,
            5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0,
            5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0,
            5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0,
            5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0,
            5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0,
            5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            '  0 | 943.0 | ??', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
            '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g',
            '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
            '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g',
            ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
            ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a',
            ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
            ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a',
            ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
            '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a',
            '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
            '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a',
            '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
            '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a',
            '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p',
            '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p',
            '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("Channel" + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 2**11 - 1)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 2**11 - 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 48)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           sync_length)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_short * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.ieee802_11_moving_average_xx_1, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.blocks_short_to_float_0_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.ieee802_11_ofdm_sync_long_0, 1))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 2))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.qtgui_time_sink_x_1_0_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_short_to_float_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_ofdm_equalize_symbols_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0),
                     (self.ieee802_11_ofdm_decode_mac_0, 0))
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0),
                     (self.ieee802_11_ofdm_decode_signal_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0),
                     (self.ieee802_11_ofdm_sync_long_0, 0))
        self.connect((self.nutaq_rtdex_source_0, 0),
                     (self.blocks_deinterleave_0, 0))
Esempio n. 6
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Rx")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 5e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 20
        self.freq = freq = 943000000.0
        self.chan_est = chan_est = 1

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [1e6, 5e6, 10e6, 20e6]
        self._samp_rate_labels = ["1 MHz",  "5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self.qtgui_time_sink_x_1_0_0_0 = qtgui.time_sink_f(
        	1024*16*4, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0_0.set_y_axis(-0.1, 1.4)
        
        self.qtgui_time_sink_x_1_0_0_0.set_y_label("Amplitude ----", "")
        
        self.qtgui_time_sink_x_1_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.63, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0_0_0.disable_legend()
        
        labels = ["RATIO", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [2.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_0_win)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f(
        	1024*16*4, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-0.001, 0.2)
        
        self.qtgui_time_sink_x_1_0_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.05, 0, 0, "")
        self.qtgui_time_sink_x_1_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0_0.disable_legend()
        
        labels = ["Power av.", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
        	1024*16*4, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-0.001, 0.2)
        
        self.qtgui_time_sink_x_1_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.05, 0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_1_0.disable_legend()
        
        labels = ["Correlation av.", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win)
        self.nutaq_rtdex_source_0 = nutaq.rtdex_source("nutaq_carrier_perseus_0",gr.sizeof_short,1,3)
        self.nutaq_rtdex_source_0.set_type(0)
        self.nutaq_rtdex_source_0.set_packet_size(8192)
        self.nutaq_rtdex_source_0.set_channels("1")
        self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_0", 1, 0)
        self.nutaq_radio420_tx_0_0.set_default_enable(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_freq(943e6)
        self.nutaq_radio420_tx_0_0.set_default_reference(0)
        self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0_0.set_default_band(0)
        self.nutaq_radio420_tx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(6)
        self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 1, 1)
        self.nutaq_radio420_rx_0.set_default_enable(1)
        self.nutaq_radio420_rx_0.set_default_rx_freq(943e6)
        self.nutaq_radio420_rx_0.set_default_reference(0)
        self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0.set_default_band(0)
        self.nutaq_radio420_rx_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(1)
        self.nutaq_radio420_rx_0.set_default_rx_gain2(16)
        self.nutaq_radio420_rx_0.set_default_rx_gain3(5)
        self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_0",5)
        self.nutaq_custom_register_0_0.set_index(4)
        self.nutaq_custom_register_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_0",4)
        self.nutaq_custom_register_0.set_index(1)
        self.nutaq_custom_register_0.set_default_value(6)
        self.nutaq_custom_register_0.set_update_rate(1)
          
        self.nutaq_carrier_perseus_0 = nutaq.carrier(0,"nutaq_carrier_perseus_0", "192.168.0.103")
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.85 * 0.75, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(ieee802_11.LMS, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size)
        self._gain_range = Range(0, 100, 1, 20, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "slider")
        self.top_layout.addWidget(self._gain_win)
        self._freq_options = [943000000.0, 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0]
        self._freq_labels = ['  0 | 943.0 | ??', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("Channel"+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 2**11-1)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 2**11-1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*48)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length)
        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_1_0, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_deinterleave_0, 0), (self.blocks_short_to_float_0, 0))    
        self.connect((self.blocks_deinterleave_0, 1), (self.blocks_short_to_float_0_0, 0))    
        self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1))    
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2))    
        self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_1_0_0_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_short_to_float_0_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.qtgui_time_sink_x_1_0_0, 0))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0))    
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))    
        self.connect((self.nutaq_rtdex_source_0, 0), (self.blocks_deinterleave_0, 0))    
Esempio n. 7
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver Csma Tuntap 4")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 750e-3
        self.samp_rate = samp_rate = 5e6
        self.rx_gain = rx_gain = 500e-3
        self.pdu_length = pdu_length = 500
        self.mac_dst = mac_dst = [0x12,0x34,0x56,0x78,0x90,0xaa]
        self.mac_addr = mac_addr = [0x12,0x34,0x56,0x78,0x90,0xae]
        self.lo_offset = lo_offset = 0
        self.interval = interval = 1e3
        self.freq = freq = 2.52e9
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0_0.set_normalized_gain(tx_gain, 0)
        self.toolkit_cs_0 = toolkit.cs()
        self.macprotocols_frame_buffer_0 = macprotocols.frame_buffer(256, True, 0, True)
        self.macprotocols_csma_ca_0 = macprotocols.csma_ca((mac_addr), 9, 16, 34, 1000, -60, True)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
        	sample_rate=samp_rate,
        	fft_size=64,
        	ref_scale=2,
        	frame_rate=30,
        	avg_alpha=1.0,
        	average=False,
        )
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, False)
        self.ieee802_11_mac_0_0 = ieee802_11.mac((mac_addr), (mac_dst), ([0xff, 0xff, 0xff, 0xff, 0xff, 255]))
        (self.ieee802_11_mac_0_0).set_min_output_buffer(256)
        (self.ieee802_11_mac_0_0).set_max_output_buffer(4096)
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(127, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, 64)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/wifi_rx.pcap", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/wifi_rx_all.pcap", False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_mac_0_0, 'app in'))    
        self.msg_connect((self.ieee802_11_mac_0_0, 'phy out'), (self.macprotocols_frame_buffer_0, 'app in'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to app'), (self.foo_wireshark_connector_0_0, 'in'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to app'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to app'), (self.ieee802_11_mac_0_0, 'phy in'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame request'), (self.macprotocols_frame_buffer_0, 'req in 0'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'request to cs'), (self.toolkit_cs_0, 'in_msg'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to phy'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.macprotocols_frame_buffer_0, 'frame out 0'), (self.macprotocols_csma_ca_0, 'frame from buffer'))    
        self.msg_connect((self.toolkit_cs_0, 'out_msg'), (self.macprotocols_csma_ca_0, 'cs in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_parse_mac_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.macprotocols_csma_ca_0, 'frame from phy'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.toolkit_cs_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0_0, 0), (self.blocks_file_sink_0_0, 0))    
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
Esempio n. 8
0
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")

        ##################################################
        # Variables
        ##################################################
        self.zigbee_channel = zigbee_channel = 15
        self.samp_rate = samp_rate = 4e6
        self.duration_seconds = duration_seconds = 10
        self.center_freq = center_freq = 2.405e9+5e6*(zigbee_channel-11)
        self.squelch_threshold = squelch_threshold = -70
        self.rf_gain = rf_gain = 10
        self.pcap_file = pcap_file = "zigbee.cap"
        self.num_samples = num_samples = duration_seconds*samp_rate
        self.iq_output = iq_output = "zigbee.sigmf-data"
        self.freq_channel = freq_channel = center_freq

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0.set_gain(rf_gain, 0)
        self.uhd_usrp_source_0.set_antenna('J2', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        # No synchronization enforced.
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1)
        self.ieee802_15_4_packet_sink_1 = ieee802_15_4.packet_sink(10)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, True)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.000225, 0.5, 0.03, 0.0002)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, int(num_samples))
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, 'zigbee.cap', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, iq_output, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_15_4_packet_sink_1, 'out'), (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_15_4_packet_sink_1, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_1, 'out'), (self.foo_wireshark_connector_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_head_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.ieee802_15_4_packet_sink_1, 0))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_head_0, 0))
Esempio n. 9
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "pure_sig")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = float(d_txdb)
        self.samp = samp = 4
        self.rx_gain = rx_gain = float(d_rxdb)
        self.freq = freq = float(d_freq)
        self.buf = buf = 0x8000
        self.bits = bits = 16
        self.samp_rate = samp_rate = 4e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(-20, 64, 0.01, tx_gain, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 72, 0.01, rx_gain, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._freq_options = [2450000000, 915000000, 430000000]
        self._freq_labels = ['2.45GHz', '915MHz', '430MHz']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._bits_range = Range(1, 127, 1, 16, 200)
        self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits",
                                     "counter_slider", int)
        self.top_layout.addWidget(self._bits_win)
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f(
            buf * 16,  #size
            samp_rate,  #samp_rate
            "HSS OQPSK",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(0, 2e-4)

        self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1_0.enable_tags(-1, False)
        self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1_0.enable_grid(False)
        self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_1_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win)
        self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6),
                                               int(20000000), buf * 16, True,
                                               True, True, "manual", rx_gain,
                                               '', True)
        self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6),
                                           int(20000000), buf, True, tx_gain,
                                           '', True)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy()
        if argv[7] == 'ook':
            self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy(
                threshold=float(argv[8]))
        if argv[7] == 'fsk':
            self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy()

        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '',
                                                       '52001', 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern('a' * bits), 10)
        self.blocks_file_sink_1_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/home/hrbenitez/Desktop/just_sig.bin', False)
        self.blocks_file_sink_1_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/hrbenitez/Desktop/2_pluto.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_file_sink_1_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 2),
                     (self.blocks_null_sink_0, 1))
        self.connect((self.ieee802_15_4_phy_0, 3),
                     (self.blocks_null_sink_0, 2))
        self.connect((self.ieee802_15_4_phy_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.pluto_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0, 0))
    def __init__(self, addr, no_usrp, initialFreq, otw, source, no_self_loop,
                 debug_MAC, wireshark):
        gr.top_block.__init__(
            self, "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "transceiver_OQPSK_Slave")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.addr = addr
        self.no_usrp = no_usrp
        self.freq = initialFreq
        self.otw = otw
        self.no_self_loop = no_self_loop
        self.debug_MAC = debug_MAC
        self.source = source
        self.wireshark = wireshark
        self.tx_gain = tx_gain = 0.25
        self.rx_gain = rx_gain = 0.25
        ##################################################
        # Blocks
        ##################################################
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     4 * 1e6, True)
            ## Using files instead of USRPs
            self.blocks_file_source_slave = blocks.file_source(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/masterFileSink"), True)
            self.blocks_file_sink_slave = blocks.file_sink(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/slaveFileSink"), False)
            self.blocks_file_sink_slave.set_unbuffered(False)
        else:
            ## usrp_source
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
            ## usrp_sink
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )

            # TODO Explain the usage
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                                uhd.ALL_MBOARDS)
            self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
            self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
            self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)

        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            4e6,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        # 802.15.4m MAC layer #
        #self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_mac_0 = mac_15_4m(self.debug_MAC, self.no_self_loop)
        # Ethernet Encapsulation #TODO explain its usage, Specific to 802.11 ?
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        self._freq_options = [
            TVWS_channelmap.get_TVWS_freq(i) for i in range(2, 69)
        ]
        self._freq_labels = [str(i) for i in range(2, 69)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))

        self.top_layout.addWidget(self._freq_tool_bar)

        ##################################################
        # Asynch Message Connections
        ##################################################
        if self.source == "tuntap":  # Tuntap Block to quantify the achievable throughput
            print "TUNTAP"
            self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap1", 440)
            self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                             self.blocks_tuntap_pdu_0, "pdus")
            self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                             self.ieee802_11_ether_encap_0, "from tap")

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.ieee802_11_ether_encap_0, "from wifi")
            self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "socket":  #using PDU Sockets instead #TODO Test ME !
            self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                "UDP_SERVER", "localhost", "52004", 10000)
            self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                "UDP_CLIENT", "localhost", "3333", 10000)

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.blocks_socket_pdu_0_Rx, "pdus")
            self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "strobe":
            self.blocks_message_strobe_0 = blocks.message_strobe(
                pmt.intern("Hello World!\n"), 1000)
            self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                             (self.ieee802_15_4_rime_stack_0, 'bcin'))

        if self.wireshark:
            self.foo_wireshark_connector_0 = foo.wireshark_connector(127, True)

            self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       "/tmp/ofdm.pcap", True)
            self.blocks_file_sink_0.set_unbuffered(True)

            self.connect((self.foo_wireshark_connector_0, 0),
                         (self.blocks_file_sink_0, 0))

            self.msg_connect(self.ieee802_15_4_mac_0, "PHY",
                             self.foo_wireshark_connector_0, "in")
            self.msg_connect(self.ieee802_15_4_oqpsk_phy_0, "mac_out",
                             self.foo_wireshark_connector_0, "in")

        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        if self.no_usrp:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.blocks_file_sink_slave, 0)))
            self.connect((self.blocks_file_source_slave, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
        else:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.uhd_usrp_sink_0, 0)))
            self.connect((self.uhd_usrp_source_0, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 40
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 40
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 2.412e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
Esempio n. 12
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.gain = gain = 50
        self.freq = freq = 2450000000

        ##################################################
        # Blocks
        ##################################################
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=1,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)],
            labels=[i for i in range(11, 27)],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._freq_chooser)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=4e6,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(2, 195, "")
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(4e6)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.epy_block_0 = blk()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/zigbee.pcap", False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.epy_block_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.epy_block_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
Esempio n. 13
0
    def __init__(self):
        gr.top_block.__init__(self, "zigbee_dual_channel_rx")

        ##################################################
        # Variables
        ##################################################
        self.transition_width = transition_width = 300e3
        self.sample_rate = sample_rate = 8e6
        self.cutoff_freq = cutoff_freq = 850e3
        self.channel_spacing = channel_spacing = 5e6
        self.channel = channel = 0
        self.base_freq = base_freq = int(2405e6)
        self.squelch_threshold = squelch_threshold = -75
        self.lowpass_filter = lowpass_filter = firdes.low_pass(
            1, sample_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING,
            6.76)
        self.gmsk_sps = gmsk_sps = 4
        self.gmsk_omega_limit = gmsk_omega_limit = 0.035
        self.gmsk_mu = gmsk_mu = 0.5
        self.gmsk_gain_mu = gmsk_gain_mu = 0.7
        self.freq_offset = freq_offset = 2.5e6
        self.freq = freq = (base_freq + (channel_spacing * channel))
        self.decim = decim = 4

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(freq + freq_offset, 0)
        self.uhd_usrp_source_0.set_rx_agc(True, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(sample_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1, decimation=decim, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1, decimation=decim, taps=None, fractional_bw=None)
        self.ieee802_15_4_packet_sink_0_0 = ieee802_15_4.packet_sink(10)
        self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, lowpass_filter, freq_offset, sample_rate)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, lowpass_filter, -freq_offset, sample_rate)
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(195, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(
            sample_rate / 2e6 / decim, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            sample_rate / 2e6 / decim, 0.000225, 0.5, 0.03, 0.0002)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       '/tmp/sensor11.pcap',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     '/tmp/sensor12.pcap',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(
            squelch_threshold, 0.1)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0_0, 'out'),
                         (self.foo_wireshark_connector_0_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.blocks_sub_xx_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.single_pole_iir_filter_xx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.ieee802_15_4_packet_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0),
                     (self.ieee802_15_4_packet_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_sub_xx_0_0, 1))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.analog_simple_squelch_cc_1, 0))
Esempio n. 14
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 80
        self.freq = freq = 5.18e9
        self.chan_est = chan_est = ieee802_11.LMS

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5 MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.Add(self.nb)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0,
                2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0,
                2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0,
                2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0,
                5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0,
                5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0,
                5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0,
                5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0,
                5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0,
                5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0,
                5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0,
                5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0,
                5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0,
                5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0,
                5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0,
                5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0,
                5900000000.0, 5910000000.0, 5920000000.0
            ],
            labels=[
                '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
                '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g',
                '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g',
                '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
                '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g',
                ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g',
                ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
                ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a',
                ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a',
                ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
                ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a',
                ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a',
                ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a',
                ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '102 | 5510.0 | 11a',
                '104 | 5520.0 | 11a', '106 | 5530.0 | 11a',
                '108 | 5540.0 | 11a', '110 | 5550.0 | 11a',
                '112 | 5560.0 | 11a', '114 | 5570.0 | 11a',
                '116 | 5580.0 | 11a', '118 | 5590.0 | 11a',
                '120 | 5600.0 | 11a', '122 | 5610.0 | 11a',
                '124 | 5620.0 | 11a', '126 | 5630.0 | 11a',
                '128 | 5640.0 | 11a', '132 | 5660.0 | 11a',
                '134 | 5670.0 | 11a', '136 | 5680.0 | 11a',
                '138 | 5690.0 | 11a', '140 | 5700.0 | 11a',
                '142 | 5710.0 | 11a', '144 | 5720.0 | 11a',
                '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)',
                '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)',
                '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)',
                '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)',
                '172 | 5860.0 | 11p', '174 | 5870.0 | 11p',
                '176 | 5880.0 | 11p', '178 | 5890.0 | 11p',
                '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
                '184 | 5920.0 | 11p'
            ],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chan_est,
            callback=self.set_chan_est,
            label='chan_est',
            choices=[
                ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
            ],
            labels=["LS", "LMS", "STA", "Linear Comb"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_scopesink1 = scopesink2.scope_sink_c(
            self.nb.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=12500,
            v_scale=0.5,
            v_offset=0,
            t_scale=0.5,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(0).Add(self.wxgui_scopesink1.win)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "")
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_sync_short_0 = ieee802_11.sync_short(
            0.56, 2, False, False)
        self.ieee802_11_sync_long_0 = ieee802_11.sync_long(
            sync_length, True, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, "packet_len")
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/wifi.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.ieee802_11_moving_average_xx_1, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.ieee802_11_sync_long_0, 1))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.ieee802_11_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 2))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.wxgui_scopesink1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.ieee802_11_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.ieee802_11_sync_long_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 15
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx")

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 20
        self.freq = freq = 2.412e9
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6, 10e6, 20e6],
        	labels=["5 MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label='gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chan_est,
        	callback=self.set_chan_est,
        	label='chan_est',
        	choices=[0, 1],
        	labels=["LMS", "Linear Comb"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.Add(self.nb)
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, False)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(False, False)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1))    
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0))    
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))    
Esempio n. 16
0
    def __init__(self, encoding=2, interference="ofdm", interval=50, messages=50, repetition=23, size=546, snr=20):
        gr.top_block.__init__(self, "Sim")

        self._lock = threading.RLock()

        ##################################################
        # Parameters
        ##################################################
        self.encoding = encoding
        self.interference = interference
        self.interval = interval
        self.messages = messages
        self.repetition = repetition
        self.size = size
        self.snr = snr

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.out_buf_size = out_buf_size = 960000
        self.filename = filename = "results/sim_%d_%.1f_%s_.pcap" % (repetition, snr, interference)

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0_0 = wifi_phy_hier(
            bandwidth=10e6,
            chan_est=ieee802_11.LS,
            encoding=encoding,
            frequency=5.89e9,
            sensitivity=0.56,
        )
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=10e6,
            chan_est=ieee802_11.LS,
            encoding=encoding,
            frequency=5.89e9,
            sensitivity=0.56,
        )
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(
        	  1 + 15e-6,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  1 + 15e-6,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.ieee802_11_mac_0_0 = ieee802_11.mac(([0x12, 0x12, 0x12, 0x12, 0x12, 0x12]), ([0x34, 0x34, 0x34, 0x34, 0x34, 0x34]), ([0x56, 0x56, 0x56, 0x56, 0x56, 0x56]))
        self.ieee802_11_mac_0 = ieee802_11.mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_random_periodic_msg_source_0_0 = foo.random_periodic_msg_source(ieee802_11.mac_payload_to_payload(size), interval, messages, True, False, repetition+123)
        self.foo_random_periodic_msg_source_0 = foo.random_periodic_msg_source(ieee802_11.mac_payload_to_payload(size), interval, messages, True, False, repetition+4242)
        self.foo_packet_pad2_0_0_0 = foo.packet_pad2(False, False, 0.001, 4000, 5000)
        (self.foo_packet_pad2_0_0_0).set_min_output_buffer(960000)
        self.foo_packet_pad2_0_0 = foo.packet_pad2(False, False, 0.001, 4000, 5000)
        (self.foo_packet_pad2_0_0).set_min_output_buffer(960000)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 4000, 5000)
        (self.foo_packet_pad2_0).set_min_output_buffer(960000)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(size), encoding), "packet_len")
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, 2400 + repetition * 4)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((0, ))
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1 if interference == "noise" else 0, ))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.00001, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1 if interference == "ofdm" else 0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, ))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, filename, False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, repetition+1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, repetition+12312)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.foo_random_periodic_msg_source_0, 'out'), (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.foo_random_periodic_msg_source_0_0, 'out'), (self.ieee802_11_mac_0_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.ieee802_11_mac_0_0, 'phy out'), (self.wifi_phy_hier_0_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.wifi_phy_hier_0_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.foo_packet_pad2_0_0_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.foo_packet_pad2_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.foo_packet_pad2_0_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_1_1, 0))
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
        self.connect((self.wifi_phy_hier_0_0, 0), (self.foo_packet_pad2_0_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Nodo Wifi")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Nodo Wifi")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "nodo_wifi")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.snr = snr = 1
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 0.75
        self.period = period = 100
        self.pdu_length = pdu_length = 500
        self.lo_offset = lo_offset = 0
        self.interval = interval = 4000
        self.freq = freq = 5890000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._snr_range = Range(1, 200, 1, 1, 200)
        self._snr_win = RangeWidget(self._snr_range, self.set_snr, "snr", "counter_slider", float)
        self.top_layout.addWidget(self._snr_win)
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._period_range = Range(1, 1000, 1, 100, 200)
        self._period_win = RangeWidget(self._period_range, self.set_period, "period", "counter_slider", float)
        self.top_layout.addWidget(self._period_win)
        self._lo_offset_options = (0, 6e6, 11e6, )
        self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self._freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0]
        self._freq_labels = ['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7]
        self._encoding_labels = ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"]
        self._encoding_group_box = Qt.QGroupBox("encoding")
        self._encoding_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._encoding_button_group = variable_chooser_button_group()
        self._encoding_group_box.setLayout(self._encoding_box)
        for i, label in enumerate(self._encoding_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._encoding_box.addWidget(radio_button)
        	self._encoding_button_group.addButton(radio_button, i)
        self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(self._encoding_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._encoding_options.index(i)))
        self._encoding_callback(self.encoding)
        self._encoding_button_group.buttonClicked[int].connect(
        	lambda i: self.set_encoding(self._encoding_options[i]))
        self.top_layout.addWidget(self._encoding_group_box)
        self._chan_est_options = [ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB]
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._chan_est_box.addWidget(radio_button)
        	self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
        	lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(('', "num_recv_frames=1024")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(('', '')),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	'packet_len',
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:A', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	48*10, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self._pdu_length_range = Range(0, 1500, 1, 500, 200)
        self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int)
        self.top_layout.addWidget(self._pdu_length_win)
        self._interval_range = Range(1, 10000, 100, 4000, 200)
        self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int)
        self.top_layout.addWidget(self._interval_win)
        self.ieee802_11_tx_mac_0 = ieee802_11.tx_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.ieee802_11_threshold_generator_0 = ieee802_11.threshold_generator(0.7,False,rx_gain)
        self.ieee802_11_rx_mac_0 = ieee802_11.rx_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, False)
        self.ieee802_11_message_handler_0 = ieee802_11.message_handler(False, False)
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(127, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len')
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((snr, ))
        (self.blocks_multiply_const_vxx_0_0).set_min_output_buffer(100000)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), period)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/wifi_out.pcap', True)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/wifi_in.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.Wifi_tx_PHY_0 = Wifi_tx_PHY(
            encoding=ieee802_11.BPSK_1_2,
        )
        self.Wifi_rx_PHY_0 = Wifi_rx_PHY(
            bandwidth=10e6,
            chan_est=ieee802_11.LS,
            frequency=5.89e9,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.Wifi_rx_PHY_0, 'carrier'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.Wifi_rx_PHY_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.Wifi_rx_PHY_0, 'mac_out'), (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.Wifi_rx_PHY_0, 'mac_out'), (self.ieee802_11_rx_mac_0, 'phy in'))
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_tx_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_message_handler_0, 'message out'), (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_11_message_handler_0, 'SNR out'), (self.ieee802_11_threshold_generator_0, 'SNR in'))
        self.msg_connect((self.ieee802_11_parse_mac_0, 'fer'), (self.ieee802_11_threshold_generator_0, 'FER in'))
        self.msg_connect((self.ieee802_11_rx_mac_0, 'app out'), (self.ieee802_11_message_handler_0, 'app in'))
        self.msg_connect((self.ieee802_11_threshold_generator_0, 'threshold out'), (self.Wifi_rx_PHY_0, 'in_threshold'))
        self.msg_connect((self.ieee802_11_tx_mac_0, 'phy out'), (self.Wifi_tx_PHY_0, 'mac_in'))
        self.msg_connect((self.ieee802_11_tx_mac_0, 'phy out'), (self.foo_wireshark_connector_0_0, 'in'))
        self.connect((self.Wifi_rx_PHY_0, 0), (self.ieee802_11_threshold_generator_0, 0))
        self.connect((self.Wifi_tx_PHY_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.Wifi_rx_PHY_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
Esempio n. 18
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.rx_gain = rx_gain = 0.75
        self.period = period = 10
        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            'pdu_length',
        )
        self.uhd_usrp_sink_0.set_samp_rate(4000000)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, 2000, 2000)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("Hello World!\n"), period)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.foo_packet_pad_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.foo_packet_pad_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.uhd_usrp_sink_0, 0))
Esempio n. 19
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Rx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 5e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 0.75
        self.freq = freq = 2484000000
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self._gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain",
                                     "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self._freq_options = [
            2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0,
            2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0,
            2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0,
            2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0,
            5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0,
            5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0,
            5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0,
            5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0,
            5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0,
            5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0,
            5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0,
            5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0,
            5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0,
            5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0,
            5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0,
            5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0,
            5900000000.0, 5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g',
            '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g',
            '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g',
            ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g',
            ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a',
            ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a',
            ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a',
            ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a',
            ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a',
            ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a',
            '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a',
            '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a',
            '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a',
            '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a',
            '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a',
            '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a',
            '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a',
            '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)',
            '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)',
            '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)',
            '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)',
            '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p',
            '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p',
            '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._chan_est_options = [
            ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
        ]
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
            radio_button = Qt.QRadioButton(label)
            self._chan_est_box.addWidget(radio_button)
            self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._chan_est_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
            lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(gain, 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            48 * 10,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.ieee802_11_sync_short_0 = ieee802_11.sync_short(2, False, False)
        self.ieee802_11_sync_long_0 = ieee802_11.sync_long(
            sync_length, True, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/wifi2.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.ieee802_11_moving_average_xx_1, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.ieee802_11_sync_long_0, 1))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.ieee802_11_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 2))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.ieee802_11_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.ieee802_11_sync_long_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 20
0
    def __init__(self, ant_msg='RX2', gain_msg=0.8, lo_msg=0):
        gr.top_block.__init__(self, "UHD Message Tuner")

        ##################################################
        # Parameters
        ##################################################
        self.ant_msg = ant_msg
        self.gain_msg = gain_msg
        self.lo_msg = lo_msg

        ##################################################
        # Variables
        ##################################################
        self.channel = channel = 11
        self.freq_msg = freq_msg = 1000000 * (2400 + 5 * (channel - 10))
        self.samp_rate = samp_rate = 4e6
        self.initial_fc = initial_fc = 1000000 * (2400 + 5 * (11 - 10))
        self.gain = gain = 0.8
        self.cmd_msg = cmd_msg = pmt.to_pmt({'antenna': ant_msg, 'gain': gain_msg, 'chan': 0, 'freq': freq_msg, 'lo_offset': lo_msg})

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('127.0.0.1', 57000), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(initial_fc, 0)
        self.uhd_usrp_source_0.set_rx_agc(True, 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True,0x8841,0,0x1aaa,0xffff,0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_0 = blocks.message_strobe(cmd_msg, 500)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.uhd_usrp_source_0, 'command'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Uniflex Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5890000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/wifi.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.ieee802_11_ether_encap_0, 'from tap'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Esempio n. 22
0
    def __init__(self):
        gr.top_block.__init__(self, "TFG")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TFG")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "SDR_QT")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.profileID = profileID = 0xDCBA
        self.profile = profile = ""
        self.payload = payload = "EJEMPLO"
        self.nseq = nseq = ""
        self.label_payload = label_payload = ""
        self.label_nwk_src = label_nwk_src = ""
        self.label_nwk_dst = label_nwk_dst = ""
        self.gain = gain = 30
        self.freq = freq = 2480000000
        self.enviar = enviar = False
        self.endpoint_src = endpoint_src = ""
        self.endpoint_dst = endpoint_dst = ""
        self.clusterID = clusterID = 0xABCD
        self.cluster = cluster = ""
        self.NWK_add_src = NWK_add_src = 0xABCD
        self.NWK_add_dst = NWK_add_dst = 0xDCBA
        self.Endpoint_src = Endpoint_src = 10
        self.Endpoint_dst = Endpoint_dst = 20

        ##################################################
        # Blocks
        ##################################################
        self.Tab = Qt.QTabWidget()
        self.Tab_widget_0 = Qt.QWidget()
        self.Tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tab_widget_0)
        self.Tab_grid_layout_0 = Qt.QGridLayout()
        self.Tab_layout_0.addLayout(self.Tab_grid_layout_0)
        self.Tab.addTab(self.Tab_widget_0, 'Transmision')
        self.Tab_widget_1 = Qt.QWidget()
        self.Tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tab_widget_1)
        self.Tab_grid_layout_1 = Qt.QGridLayout()
        self.Tab_layout_1.addLayout(self.Tab_grid_layout_1)
        self.Tab.addTab(self.Tab_widget_1, 'Recepcion')
        self.top_layout.addWidget(self.Tab)
        self._NWK_add_src_tool_bar = Qt.QToolBar(self)
        self._NWK_add_src_tool_bar.addWidget(Qt.QLabel("Direccion NWK origen"+": "))
        self._NWK_add_src_line_edit = Qt.QLineEdit(str(self.NWK_add_src))
        self._NWK_add_src_tool_bar.addWidget(self._NWK_add_src_line_edit)
        self._NWK_add_src_line_edit.returnPressed.connect(
        	lambda: self.set_NWK_add_src(int(str(self._NWK_add_src_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._NWK_add_src_tool_bar,  1,0,1,1)
        self.tfg_translation_block_0 = tfg.translation_block()
        self.tfg_NWK_stack_0 = tfg.NWK_stack(True, False)
        self.tfg_Aplication_0 = tfg.Aplication()
        self.tfg_APS_stack_0 = tfg.APS_stack(True, False)
        self._profileID_tool_bar = Qt.QToolBar(self)
        self._profileID_tool_bar.addWidget(Qt.QLabel("ID de perfil"+": "))
        self._profileID_line_edit = Qt.QLineEdit(str(self.profileID))
        self._profileID_tool_bar.addWidget(self._profileID_line_edit)
        self._profileID_line_edit.returnPressed.connect(
        	lambda: self.set_profileID(int(str(self._profileID_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._profileID_tool_bar,  3,2,1,1)
        self._profile_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._profile_formatter = None
        else:
          self._profile_formatter = lambda x: x
        
        self._profile_tool_bar.addWidget(Qt.QLabel('ID de perfil'+": "))
        self._profile_label = Qt.QLabel(str(self._profile_formatter(self.profile)))
        self._profile_tool_bar.addWidget(self._profile_label)
        self.Tab_grid_layout_1 .addWidget(self._profile_tool_bar,  3,2,1,1)
          
        self.perfl_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "perfil")
        self._perfl_r_win = sip.wrapinstance(self.perfl_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._perfl_r_win,  3,3,1,1)
        self.payload_r = qtgui.edit_box_msg(qtgui.STRING, '', '', True, True, "payload")
        self._payload_r_win = sip.wrapinstance(self.payload_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._payload_r_win,  0,1,1,3)
        self._payload_tool_bar = Qt.QToolBar(self)
        self._payload_tool_bar.addWidget(Qt.QLabel('Carga del mensaje'+": "))
        self._payload_line_edit = Qt.QLineEdit(str(self.payload))
        self._payload_tool_bar.addWidget(self._payload_line_edit)
        self._payload_line_edit.returnPressed.connect(
        	lambda: self.set_payload(str(str(self._payload_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._payload_tool_bar,  0,0,1,3)
        self.nseq_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "nseq")
        self._nseq_r_win = sip.wrapinstance(self.nseq_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._nseq_r_win,  4,1,1,1)
        self._nseq_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._nseq_formatter = None
        else:
          self._nseq_formatter = lambda x: x
        
        self._nseq_tool_bar.addWidget(Qt.QLabel('Numero de secuencia'+": "))
        self._nseq_label = Qt.QLabel(str(self._nseq_formatter(self.nseq)))
        self._nseq_tool_bar.addWidget(self._nseq_label)
        self.Tab_grid_layout_1 .addWidget(self._nseq_tool_bar,  4,0,1,1)
          
        self._label_payload_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_payload_formatter = None
        else:
          self._label_payload_formatter = lambda x: x
        
        self._label_payload_tool_bar.addWidget(Qt.QLabel('Carga'+": "))
        self._label_payload_label = Qt.QLabel(str(self._label_payload_formatter(self.label_payload)))
        self._label_payload_tool_bar.addWidget(self._label_payload_label)
        self.Tab_grid_layout_1 .addWidget(self._label_payload_tool_bar,  0,0,1,1)
          
        self._label_nwk_src_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_nwk_src_formatter = None
        else:
          self._label_nwk_src_formatter = lambda x: x
        
        self._label_nwk_src_tool_bar.addWidget(Qt.QLabel('Direccion NWK origen'+": "))
        self._label_nwk_src_label = Qt.QLabel(str(self._label_nwk_src_formatter(self.label_nwk_src)))
        self._label_nwk_src_tool_bar.addWidget(self._label_nwk_src_label)
        self.Tab_grid_layout_1 .addWidget(self._label_nwk_src_tool_bar,  1,0,1,1)
          
        self._label_nwk_dst_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_nwk_dst_formatter = None
        else:
          self._label_nwk_dst_formatter = lambda x: x
        
        self._label_nwk_dst_tool_bar.addWidget(Qt.QLabel('Direccion NWK destino'+": "))
        self._label_nwk_dst_label = Qt.QLabel(str(self._label_nwk_dst_formatter(self.label_nwk_dst)))
        self._label_nwk_dst_tool_bar.addWidget(self._label_nwk_dst_label)
        self.Tab_grid_layout_1 .addWidget(self._label_nwk_dst_tool_bar,  1,2,1,1)
          
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False)
        self._gain_range = Range(1, 100, 1, 30, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Ganancia TX', "counter_slider", int)
        self.top_grid_layout.addWidget(self._gain_win, 0,0,1,1)
        self._freq_options = [1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)]
        self._freq_labels = ["11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27"]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Canal'+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_grid_layout.addWidget(self._freq_tool_bar, 0,1,1,1)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, True, 10, 2000, 2000)
        _enviar_push_button = Qt.QPushButton('Enviar')
        self._enviar_choices = {'Pressed': True, 'Released': False}
        _enviar_push_button.pressed.connect(lambda: self.tfg_Aplication_0.send())
        _enviar_push_button.released.connect(lambda: self.set_enviar(self._enviar_choices['Released']))
        self.Tab_grid_layout_0 .addWidget(_enviar_push_button,  7,0,1,3)
        self.endpoint_src_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "endpoint_src")
        self._endpoint_src_r_win = sip.wrapinstance(self.endpoint_src_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_src_r_win,  2,1,1,1)
        self._endpoint_src_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._endpoint_src_formatter = None
        else:
          self._endpoint_src_formatter = lambda x: x
        
        self._endpoint_src_tool_bar.addWidget(Qt.QLabel('Enpoint origen'+": "))
        self._endpoint_src_label = Qt.QLabel(str(self._endpoint_src_formatter(self.endpoint_src)))
        self._endpoint_src_tool_bar.addWidget(self._endpoint_src_label)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_src_tool_bar,  2,0,1,1)
          
        self.endpoint_dst_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "endpoint_dst")
        self._endpoint_dst_r_win = sip.wrapinstance(self.endpoint_dst_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_dst_r_win,  2,3,1,1)
        self._endpoint_dst_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._endpoint_dst_formatter = None
        else:
          self._endpoint_dst_formatter = lambda x: x
        
        self._endpoint_dst_tool_bar.addWidget(Qt.QLabel('Endpoint destino'+": "))
        self._endpoint_dst_label = Qt.QLabel(str(self._endpoint_dst_formatter(self.endpoint_dst)))
        self._endpoint_dst_tool_bar.addWidget(self._endpoint_dst_label)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_dst_tool_bar,  2,2,1,1)
          
        self.cluster_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "cluster")
        self._cluster_r_win = sip.wrapinstance(self.cluster_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._cluster_r_win,  3,1,1,1)
        self._clusterID_tool_bar = Qt.QToolBar(self)
        self._clusterID_tool_bar.addWidget(Qt.QLabel("ID de cluster"+": "))
        self._clusterID_line_edit = Qt.QLineEdit(str(self.clusterID))
        self._clusterID_tool_bar.addWidget(self._clusterID_line_edit)
        self._clusterID_line_edit.returnPressed.connect(
        	lambda: self.set_clusterID(int(str(self._clusterID_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._clusterID_tool_bar,  3,0,1,1)
        self._cluster_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._cluster_formatter = None
        else:
          self._cluster_formatter = lambda x: x
        
        self._cluster_tool_bar.addWidget(Qt.QLabel('ID de cluster'+": "))
        self._cluster_label = Qt.QLabel(str(self._cluster_formatter(self.cluster)))
        self._cluster_tool_bar.addWidget(self._cluster_label)
        self.Tab_grid_layout_1 .addWidget(self._cluster_tool_bar,  3,0,1,1)
          
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.NWK_add_src_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "NWK_add_src")
        self._NWK_add_src_r_win = sip.wrapinstance(self.NWK_add_src_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._NWK_add_src_r_win,  1,1,1,1)
        self.NWK_add_dst_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "NWK_add_dst")
        self._NWK_add_dst_r_win = sip.wrapinstance(self.NWK_add_dst_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._NWK_add_dst_r_win,  1,3,1,1)
        self._NWK_add_dst_tool_bar = Qt.QToolBar(self)
        self._NWK_add_dst_tool_bar.addWidget(Qt.QLabel("Direccion NWK destino"+": "))
        self._NWK_add_dst_line_edit = Qt.QLineEdit(str(self.NWK_add_dst))
        self._NWK_add_dst_tool_bar.addWidget(self._NWK_add_dst_line_edit)
        self._NWK_add_dst_line_edit.returnPressed.connect(
        	lambda: self.set_NWK_add_dst(int(str(self._NWK_add_dst_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._NWK_add_dst_tool_bar,  1,2,1,1)
        self._Endpoint_src_tool_bar = Qt.QToolBar(self)
        self._Endpoint_src_tool_bar.addWidget(Qt.QLabel("Endpoint origen"+": "))
        self._Endpoint_src_line_edit = Qt.QLineEdit(str(self.Endpoint_src))
        self._Endpoint_src_tool_bar.addWidget(self._Endpoint_src_line_edit)
        self._Endpoint_src_line_edit.returnPressed.connect(
        	lambda: self.set_Endpoint_src(int(str(self._Endpoint_src_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._Endpoint_src_tool_bar,  2,0,1,1)
        self._Endpoint_dst_tool_bar = Qt.QToolBar(self)
        self._Endpoint_dst_tool_bar.addWidget(Qt.QLabel("Endpoint destino"+": "))
        self._Endpoint_dst_line_edit = Qt.QLineEdit(str(self.Endpoint_dst))
        self._Endpoint_dst_tool_bar.addWidget(self._Endpoint_dst_line_edit)
        self._Endpoint_dst_line_edit.returnPressed.connect(
        	lambda: self.set_Endpoint_dst(int(str(self._Endpoint_dst_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._Endpoint_dst_tool_bar,  2,2,1,1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.tfg_translation_block_0, 'in(bastibl)'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))    
        self.msg_connect((self.tfg_APS_stack_0, 'out(ZCL)'), (self.tfg_Aplication_0, 'in'))    
        self.msg_connect((self.tfg_APS_stack_0, 'out(NWK)'), (self.tfg_NWK_stack_0, 'in(APS)'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.NWK_add_dst_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.NWK_add_src_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.cluster_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.endpoint_dst_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.endpoint_src_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.nseq_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.payload_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.perfl_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.tfg_APS_stack_0, 'in(ZCL)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(APS)'), (self.tfg_APS_stack_0, 'in(NWK)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(MAC)'), (self.tfg_translation_block_0, 'in(david)'))    
        self.msg_connect((self.tfg_translation_block_0, 'out(bastibl)'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.msg_connect((self.tfg_translation_block_0, 'out(david)'), (self.tfg_NWK_stack_0, 'in(MAC)'))    
        self.connect((self.foo_packet_pad_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.foo_packet_pad_0, 0))    
Esempio n. 23
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "ber_ser")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = float(d_txdb)
        self.samp = samp = 4
        self.rx_gain = rx_gain = float(d_rxdb)
        self.freq = freq = float(d_freq)
        self.buf = buf = 0x8000
        self.bits = bits = 16

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(-20, 64, 0.01, float(d_txdb), 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 72, 0.01, float(d_rxdb), 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._freq_options = [2450000000, 915000000, 430000000]
        self._freq_labels = ['2.45GHz', '915MHz', '430MHz']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._bits_range = Range(1, 127, 1, 43, 200)
        self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits",
                                     "counter_slider", int)
        self.top_layout.addWidget(self._bits_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 1,
                                                     qtgui.NUM_GRAPH_HORIZ, 2)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = [
            'BER', 'SER', 'Latency', 'Bit Error Rate', 'Symbol Error Rate',
            'SNR', '', '', '', ''
        ]
        units = ['', '', 'ms', '', '', 'dB', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(2):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6),
                                               int(20000000), buf * 16, True,
                                               True, True, "manual", rx_gain,
                                               '', True)
        self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6),
                                           int(20000000), buf, False, tx_gain,
                                           '', True)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        self.ieee802_15_4_phy_0_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy()
        if argv[7] == 'ook':
            exec "d_thr = " + argv[8] in locals()
            self.ieee802_15_4_phy_0_0 = ieee802_15_4_ook_phy(threshold=d_thr)
            self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy(threshold=d_thr)
            print "Modulation: OOK\nThreshold: " + str(d_thr) + "\n"
        elif argv[7] == 'fsk':
            self.ieee802_15_4_phy_0_0 = ieee802_15_4_cpfsk_phy()
            self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy()
            print "Modulation: FSK\n"

        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, buf, buf)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '',
                                                       '52001', 10000, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern(''.join(chr(e) for e in range(65, 65 + bits))), 500)
        self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     d_dir + '/ser.bin', False)
        self.blocks_file_sink_1_0.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1,
                                                   d_dir + '/ber.bin', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/hrbenitez/Desktop/output_padded.pcap',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_error_rate_0_0 = grc_blks2.error_rate(
            type='SER',
            win_size=2**20,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=2**20,
            bits_per_symbol=1,
        )
        self.bar_out_sync_0 = bar.out_sync(10)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_phy_0_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_phy_0_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.bar_out_sync_0, 0), (self.blks2_error_rate_0, 0))
        self.connect((self.bar_out_sync_0, 2), (self.blks2_error_rate_0, 1))
        self.connect((self.bar_out_sync_0, 1), (self.blks2_error_rate_0_0, 0))
        self.connect((self.bar_out_sync_0, 3), (self.blks2_error_rate_0_0, 1))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.blocks_file_sink_1_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.qtgui_number_sink_0, 1))
        self.connect((self.foo_packet_pad_0, 0), (self.ieee802_15_4_phy_0, 0))
        self.connect((self.foo_packet_pad_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))

        self.connect((self.ieee802_15_4_phy_0, 2), (self.bar_out_sync_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 3), (self.bar_out_sync_0, 1))
        self.connect((self.ieee802_15_4_phy_0, 1), (self.bar_out_sync_0, 2))
        self.connect((self.ieee802_15_4_phy_0, 0), (self.foo_packet_pad_0, 0))
        self.connect((self.ieee802_15_4_phy_0_0, 2), (self.bar_out_sync_0, 3))
        self.connect((self.ieee802_15_4_phy_0_0, 3), (self.bar_out_sync_0, 4))
        self.connect((self.ieee802_15_4_phy_0_0, 1), (self.bar_out_sync_0, 5))
        self.connect((self.ieee802_15_4_phy_0_0, 0),
                     (self.blocks_null_sink_0_0, 0))

        self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0_0, 0))
Esempio n. 24
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Rx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_rx")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 2e6
        self.rf = rf = 14
        self.lo_offset = lo_offset = 0
        self.gain = gain = 0.75
        self.freqq = freqq = 2.412e6
        self.freq = freq = 2412000000.0
        self.device_6 = device_6 = "hackrf=26b468dc3540b58f"
        self.device_5 = device_5 = "hackrf=88869dc38686a1b"
        self.device_4 = device_4 = "hackrf=88869dc2930b41b"
        self.device_3 = device_3 = "hackrf=88869dc3347501b"
        self.device_2 = device_2 = "hackrf=88869dc3918701b"
        self.device_1 = device_1 = "hackrf=88869dc3397a01b"
        self.chan_est = chan_est = 0
        self.bb = bb = 20
        self.IF = IF = 30

        ##################################################
        # Blocks
        ##################################################
        # Create the options list
        self._samp_rate_options = [
            2000000.0, 5000000.0, 10000000.0, 20000000.0
        ]
        # Create the labels list
        self._samp_rate_labels = ['2MHz', '5 MHz', '10 MHz', '20 MHz']
        # Create the combo box
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate: "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for _label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(_label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        # Create the radio buttons
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._rf_range = Range(0, 50, 1, 14, 200)
        self._rf_win = RangeWidget(self._rf_range, self.set_rf, 'rf',
                                   "counter_slider", int)
        self.top_layout.addWidget(self._rf_win)
        # Create the options list
        self._chan_est_options = [0, 1, 3, 2]
        # Create the labels list
        self._chan_est_labels = ['LS', 'LMS', 'STA', 'Linear Comb']
        # Create the combo box
        # Create the radio buttons
        self._chan_est_group_box = Qt.QGroupBox('chan_est' + ": ")
        self._chan_est_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, _label in enumerate(self._chan_est_labels):
            radio_button = Qt.QRadioButton(_label)
            self._chan_est_box.addWidget(radio_button)
            self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._chan_est_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
            lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self._bb_range = Range(0, 70, 1, 20, 200)
        self._bb_win = RangeWidget(self._bb_range, self.set_bb, 'bb',
                                   "counter_slider", int)
        self.top_layout.addWidget(self._bb_win)
        self._IF_range = Range(0, 50, 1, 30, 200)
        self._IF_win = RangeWidget(self._IF_range, self.set_IF, 'IF',
                                   "counter_slider", int)
        self.top_layout.addWidget(self._IF_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            48 * 10,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               device_5)
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(2.45e9, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(rf, 0)
        self.osmosdr_source_0.set_if_gain(IF, 0)
        self.osmosdr_source_0.set_bb_gain(bb, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
        # Create the options list
        self._lo_offset_options = [0, 6000000.0, 11000000.0]
        # Create the labels list
        self._lo_offset_labels = ['0', '6000000.0', '11000000.0']
        # Create the combo box
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset: "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for _label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(_label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        # Create the radio buttons
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self.ieee802_11_sync_short_0 = ieee802_11.sync_short(
            0.56, 2, False, False)
        self.ieee802_11_sync_long_0 = ieee802_11.sync_long(
            sync_length, True, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, 2.45e9, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False)
        self._gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain',
                                     "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        # Create the options list
        self._freqq_options = [2437000.0, 2462000.0, 2412000.0]
        # Create the labels list
        self._freqq_labels = ['ch6', 'ch11', 'ch1']
        # Create the combo box
        self._freqq_tool_bar = Qt.QToolBar(self)
        self._freqq_tool_bar.addWidget(Qt.QLabel("freqq: "))
        self._freqq_combo_box = Qt.QComboBox()
        self._freqq_tool_bar.addWidget(self._freqq_combo_box)
        for _label in self._freqq_labels:
            self._freqq_combo_box.addItem(_label)
        self._freqq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freqq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freqq_options.index(i)))
        self._freqq_callback(self.freqq)
        self._freqq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freqq(self._freqq_options[i]))
        # Create the radio buttons
        self.top_layout.addWidget(self._freqq_tool_bar)
        # Create the options list
        self._freq_options = [
            2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0,
            2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0,
            2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0,
            2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0,
            5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0,
            5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0,
            5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0,
            5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0,
            5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0,
            5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0,
            5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0,
            5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0,
            5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0,
            5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0,
            5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0,
            5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0,
            5900000000.0, 5910000000.0, 5920000000.0
        ]
        # Create the labels list
        self._freq_labels = [
            '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g',
            '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g',
            '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g',
            ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g',
            ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a',
            ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a',
            ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a',
            ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a',
            ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a',
            ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a',
            '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a',
            '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a',
            '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a',
            '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a',
            '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a',
            '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a',
            '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a',
            '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)',
            '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)',
            '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)',
            '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)',
            '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p',
            '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p',
            '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'
        ]
        # Create the combo box
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq: "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for _label in self._freq_labels:
            self._freq_combo_box.addItem(_label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        # Create the radio buttons
        self.top_layout.addWidget(self._freq_tool_bar)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, window.rectangular(64), True, 1)
        self.correctiq_correctiq_0 = correctiq.correctiq()
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_xx_1 = blocks.moving_average_cc(
            window_size, 1, 4000, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            window_size + 16, 1, 4000, 1)
        self.blocks_file_sink_2 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/erc/SDN/symbols_5_1.bin', False)
        self.blocks_file_sink_2.set_unbuffered(True)
        self.blocks_file_sink_1_1 = blocks.file_sink(
            gr.sizeof_gr_complex * 64, '/home/erc/SDN/before_fft_5_1.bin',
            False)
        self.blocks_file_sink_1_1.set_unbuffered(True)
        self.blocks_file_sink_1_0 = blocks.file_sink(
            gr.sizeof_char * 48, '/home/erc/SDN/output_equ_5_1.bin', False)
        self.blocks_file_sink_1_0.set_unbuffered(True)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_gr_complex * 64, '/home/erc/SDN/after_fft_5_1.bin',
            False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/erc/SDN/wifi_5_1.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.ieee802_11_sync_long_0, 1))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.ieee802_11_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 2))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_moving_average_xx_1, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.blocks_file_sink_2, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_file_sink_1_1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.blocks_file_sink_1_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_sync_short_0, 0),
                     (self.ieee802_11_sync_long_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.correctiq_correctiq_0, 0))
Esempio n. 25
0
    def __init__(self, chan_est=1, encoding=0, freq_offset=0, interval=500, pdu_length=500, snr=10):
        gr.top_block.__init__(self, "Wifi Loopback")

        ##################################################
        # Parameters
        ##################################################
        self.chan_est = chan_est
        self.encoding = encoding
        self.freq_offset = freq_offset
        self.interval = interval
        self.pdu_length = pdu_length
        self.snr = snr

        ##################################################
        # Variables
        ##################################################
        self.out_buf_size = out_buf_size = 96000

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            encoding=encoding,
            chan_est=chan_est,
        )
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=.5**.5,
        	frequency_offset=freq_offset,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len")
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, ))
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), interval)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/sim.csv", False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_null_sink_1, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Uniflex Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5890000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/wifi.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 to Wireshark")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 to Wireshark")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "IEEE_802_15_4_Wireshark")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.ComFreqStruct = ComFreqStruct = struct({
            'Ch11': 2.405,
            'Ch12': 2.410,
            'Ch13': 2.415,
            'Ch14': 2.420,
            'Ch15': 2.425,
            'Ch16': 2.430,
            'Ch17': 2.435,
            'Ch18': 2.440,
            'Ch19': 2.445,
            'Ch20': 2.450,
            'Ch21': 2.455,
            'Ch22': 2.460,
            'Ch23': 2.465,
            'Ch24': 2.470,
            'Ch25': 2.475,
            'Ch26': 2.480,
        })
        self.CH = CH = "Ch24"
        self.freq = freq = getattr(ComFreqStruct, CH) * 1000000000
        self.samp_rate = samp_rate = 4000000
        self.rx_gain = rx_gain = 25
        self.if_gain = if_gain = 20
        self.comm_freq_label = comm_freq_label = freq
        self.bb_gain = bb_gain = 20

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 50, 1, 25, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 96, 0, 1, 1)
        for r in range(96, 97):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._if_gain_range = Range(0, 50, 1, 20, 200)
        self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain,
                                        'if_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._if_gain_win, 97, 0, 1, 1)
        for r in range(97, 98):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._bb_gain_range = Range(0, 50, 1, 20, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        'BB', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 98, 0, 1, 1)
        for r in range(98, 99):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(3, -1, 'wpan')
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate / 2,  #bw
            "raw",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['Raw', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 7,
                                       0, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Rx",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-0.5, 0.5)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, 0.2, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(True)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(True)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = [
            'Raw DC Blocked R', 'Raw DC Blocked I', 'dqpsk R', 'dqpsk I',
            'Sub i', 'Sub q', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "yellow", "blue", "cyan", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 5, 0, 1,
                                       4)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_1_1 = qtgui.const_sink_c(
            1024,  #size
            "Rx",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1_1.set_update_time(0.1)
        self.qtgui_const_sink_x_1_1.set_y_axis(-0.4, 0.4)
        self.qtgui_const_sink_x_1_1.set_x_axis(-0.4, 0.4)
        self.qtgui_const_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                     qtgui.TRIG_SLOPE_POS, 0.4,
                                                     0, "")
        self.qtgui_const_sink_x_1_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1_1.enable_grid(False)
        self.qtgui_const_sink_x_1_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_1_1.disable_legend()

        labels = [
            'Rx raw', 'DQPSK Soft', 'MPSK', 'Unbuf', '', '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "Dark Blue", "red", "yellow", "cyan", "red", "red", "red", "red",
            "red", "red"
        ]
        styles = [1, 0, 4, 5, 0, 0, 0, 0, 0, 0]
        markers = [9, 7, 6, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_1_win, 1, 0,
                                       1, 4)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'soapy=0,driver=lime')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(rx_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('LNAH', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2, 0.000225, 0.5, 0.03, 0.0002)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self._comm_freq_label_tool_bar = Qt.QToolBar(self)

        if None:
            self._comm_freq_label_formatter = None
        else:
            self._comm_freq_label_formatter = lambda x: eng_notation.num_to_str(
                x)

        self._comm_freq_label_tool_bar.addWidget(Qt.QLabel('Com Freq:' + ": "))
        self._comm_freq_label_label = Qt.QLabel(
            str(self._comm_freq_label_formatter(self.comm_freq_label)))
        self._comm_freq_label_tool_bar.addWidget(self._comm_freq_label_label)
        self.top_grid_layout.addWidget(self._comm_freq_label_tool_bar, 99, 1,
                                       1, 1)
        for r in range(99, 100):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", '127.0.0.1',
                                                     '52006', 10000, False)
        self.blocks_pdu_set_0 = blocks.pdu_set(pmt.to_pmt("nomfreq"),
                                               pmt.to_pmt(freq))
        self.blocks_message_debug_1_0 = blocks.message_debug()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self._CH_options = (
            "Ch24",
            "Ch25",
            "Ch26",
            "Ch11",
            "Ch12",
        )
        self._CH_labels = (
            '24',
            '25',
            '26',
            '11',
            '12',
        )
        self._CH_group_box = Qt.QGroupBox('802.15.4 Channel')
        self._CH_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._CH_button_group = variable_chooser_button_group()
        self._CH_group_box.setLayout(self._CH_box)
        for i, label in enumerate(self._CH_labels):
            radio_button = Qt.QRadioButton(label)
            self._CH_box.addWidget(radio_button)
            self._CH_button_group.addButton(radio_button, i)
        self._CH_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._CH_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._CH_options.index(i)))
        self._CH_callback(self.CH)
        self._CH_button_group.buttonClicked[int].connect(
            lambda i: self.set_CH(self._CH_options[i]))
        self.top_grid_layout.addWidget(self._CH_group_box, 99, 0, 1, 1)
        for r in range(99, 100):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_pdu_set_0, 'pdus'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.epy_block_0, 'out'),
                         (self.blocks_pdu_set_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.blocks_message_debug_1_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.epy_block_0, 'in'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.qtgui_const_sink_x_1_1, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.ieee802_15_4_packet_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
Esempio n. 28
0
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 RX")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "Zigbee_RX")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4e06
        self.rx_gain = rx_gain = 0.75
        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self._freq_options = [
            1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)
        ]
        self._freq_labels = [str(i) for i in range(11, 27)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_RX_0 = ieee802_15_4_oqpsk_phy_RX()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, True)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT",
                                                     '151.97.13.245', '33333',
                                                     10000, False)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/lab/Progetti_Gnuradio/Brincat/802.15.4/zigbee.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_RX_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_RX_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_RX_0, 0))
Esempio n. 29
0
    def __init__(self):
        gr.top_block.__init__(self, "Traffic Monitor")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 90
        self.samp_rate = samp_rate = 2 * 10e5
        self.rx_gain = rx_gain = 50
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(encoding=0, )
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq - lo_offset, lo_offset), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(freq - lo_offset, lo_offset), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x30, 0x30, 0x30, 0x30, 0x30, 0x30]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]),
            ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 0, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        # self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        #self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("     Laptop3     "), 100)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        #Add  by Xuepeng Xu
        self.controller = Controller(self)
        self.transmitter = DsrcServer(controller=self.controller)
        #self.message_generator = message_generator()
        #self.message_collector = message_collector()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(self.transmitter, 'received out',
                         self.ieee802_11_ofdm_mac_0, 'app in')
        #self.msg_connect((self.transmitter,'received out'), (self.blocks_message_strobe_0, 'set_msg'))
        #self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in'))
        self.msg_connect(self.ieee802_11_ofdm_mac_0, 'app out',
                         self.transmitter, 'send in')
        #self.msg_connect((self.ieee802_11_ofdm_mac_0, 'app out'),(self.message_collector, 'message_stream in'))
        #self.msg_connect((self.message_collector,'message_to_collect out'),(self.transmitter,'send in'))
        self.msg_connect(self.ieee802_11_ofdm_mac_0, 'phy out',
                         self.foo_wireshark_connector_0, 'in')
        self.msg_connect(self.ieee802_11_ofdm_mac_0, 'phy out',
                         self.wifi_phy_hier_0, 'mac_in')
        self.msg_connect(self.wifi_phy_hier_0, 'mac_out',
                         self.foo_wireshark_connector_0, 'in')
        self.msg_connect(self.wifi_phy_hier_0, 'mac_out',
                         self.ieee802_11_ofdm_mac_0, 'phy in')
        self.msg_connect(self.wifi_phy_hier_0, 'mac_out',
                         self.ieee802_11_ofdm_parse_mac_0, 'in')
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        #self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))

        self.controller.start()
Esempio n. 30
0
    def __init__(self, ant_msg='RX2', gain_msg=0.8, lo_msg=0):
        gr.top_block.__init__(self, "zigbee_dual_channel_scan")

        ##################################################
        # Parameters
        ##################################################
        self.ant_msg = ant_msg
        self.gain_msg = gain_msg
        self.lo_msg = lo_msg

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 5e6
        self.channel = channel = 11
        self.transition_width = transition_width = 300e3
        self.sample_rate = sample_rate = 8e6
        self.freq_msg = freq_msg = 1000000 * (2400 + self.channel_spacing * (channel - 10))
        self.cutoff_freq = cutoff_freq = 850e3
        self.base_freq = base_freq = int(2405e6)
        self.squelch_threshold = squelch_threshold = -75
        self.lowpass_filter = lowpass_filter = firdes.low_pass(1, sample_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING, 6.76)
        self.gmsk_sps = gmsk_sps = 4
        self.gmsk_omega_limit = gmsk_omega_limit = 0.035
        self.gmsk_mu = gmsk_mu = 0.5
        self.gmsk_gain_mu = gmsk_gain_mu = 0.7
        self.freq_offset = freq_offset = 2.5e6
        self.freq = freq = (base_freq+(channel_spacing*(channel-11)))
        self.decim = decim = int(sample_rate/2000000)
        self.cmd_msg = cmd_msg = pmt.to_pmt({'antenna': ant_msg, 'gain': gain_msg, 'chan': 0, 'freq': freq_msg, 'lo_offset': lo_msg})

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('127.0.0.1', 57000), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(freq+freq_offset, 0)
        self.uhd_usrp_source_0.set_rx_agc(True, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(sample_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff(0.00016, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None)
        self.ieee802_15_4_packet_sink_0_0 = ieee802_15_4.packet_sink(10)
        self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(1, lowpass_filter, freq_offset, sample_rate)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, lowpass_filter, -freq_offset, sample_rate)
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(195, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(sample_rate/2e6/decim, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sample_rate/2e6/decim, 0.000225, 0.5, 0.03, 0.0002)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_message_strobe_0 = blocks.message_strobe(cmd_msg, 1000000)
        self.blocks_message_debug_0_0 = blocks.message_debug()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor12.pcap', False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor11.pcap', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(squelch_threshold, 0.1)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.uhd_usrp_source_0, 'command'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'), (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0_0, 'out'), (self.blocks_message_debug_0_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0_0, 'out'), (self.foo_wireshark_connector_0_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.blocks_sub_xx_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.single_pole_iir_filter_xx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.ieee802_15_4_packet_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.ieee802_15_4_packet_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0_0, 0), (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0), (self.blocks_sub_xx_0_0, 1))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_simple_squelch_cc_1, 0))
Esempio n. 31
0
    def __init__(self):
        gr.top_block.__init__(self, "zigbee_simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("zigbee_simulation")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "zigbee_demod_fsk")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.zigbee_channel = zigbee_channel = 11
        self.transition_width = transition_width = 100e3
        self.samp_rate = samp_rate = 5000000
        self.cutoff_freq = cutoff_freq = 750e3
        self.channel_spacing = channel_spacing = 5e6
        self.central_frequency = central_frequency = 2405e6
        self.squelch_threshold = squelch_threshold = -80
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.lowpass_filter = lowpass_filter = firdes.low_pass(1, samp_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING, 6.76)
        self.iq_output = iq_output = "ble2.iq"
        self.half_preamble_len = half_preamble_len = 2*32*2
        self.freq_channel = freq_channel = central_frequency+(zigbee_channel-11)*channel_spacing
        self.dsss_mode = dsss_mode = 32
        self.dsss_4_8 = dsss_4_8 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (1+1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j)]
        self.dsss_4_64 = dsss_4_64 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]
        self.dsss_4_32_LSB = dsss_4_32_LSB = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]
        self.dsss_4_32 = dsss_4_32 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]
        self.dsss_4_16 = dsss_4_16 = [(-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j)]
        self.csv_file = csv_file = "packet_index2.csv"

        ##################################################
        # Blocks
        ##################################################
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c(
        	1024, #size
        	"after filtering", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_1.enable_autoscale(True)
        self.qtgui_const_sink_x_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_1.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win)
        self.qtgui_const_sink_x_0_0_1 = qtgui.const_sink_c(
        	1024, #size
        	"after filter", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_1.enable_autoscale(True)
        self.qtgui_const_sink_x_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_1.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_0_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_1_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"after filter", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(True)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"after noise", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(True)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.oqpsk_dsss_packet_sink_0 = oqpsk_dsss.packet_sink(12, dsss_mode, 0, 0,csv_file,zigbee_channel,int(samp_rate))
        self.oqpsk_dsss_access_code_prefixer_0 = oqpsk_dsss.access_code_prefixer(0x00,0x000000a7)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True,0x8841,0,0x1aaa,0x0000,0x1780)
        self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(1, (lowpass_filter), 0, samp_rate)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((dsss_4_32), 16)
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((([])), 0, 4, False, "pdu_length")
        self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'pdu_length', 512)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_float * 1, False)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4)
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pdu_length')
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(4, gr.GR_LSB_FIRST)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("Hello World!\n"), 120)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/home/ousseynou/ZIGBEE.pcap', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.5, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.oqpsk_dsss_access_code_prefixer_0, 'in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.oqpsk_dsss_access_code_prefixer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.foo_wireshark_connector_0, 'in'))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_repeat_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_lp, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.oqpsk_dsss_packet_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.freq_xlating_fir_filter_lp, 0), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_lp, 0), (self.qtgui_const_sink_x_0_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Only Power")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 11e6
        self.gain = gain = 20
        self.freq = freq = 5.805e9
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6, 10e6, 20e6],
        	labels=["5 MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "FFT")
        self.Add(self.nb)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label='gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chan_est,
        	callback=self.set_chan_est,
        	label='chan_est',
        	choices=[0, 1],
        	labels=["LMS", "Linear Comb"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.nb.GetPage(1).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_scopesink1 = scopesink2.scope_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	title="Scope Plot",
        	sample_rate=12500,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(0).Add(self.wxgui_scopesink1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="%",
        	minval=0,
        	maxval=100,
        	factor=1.0,
        	decimal_places=2,
        	ref_level=0,
        	sample_rate=1,
        	number_rate=15,
        	average=True,
        	avg_alpha=0.02,
        	label="Frame Error Rate",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(2).GetWin(),
        	baseband_freq=580.5*10e6,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=gain,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=64,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, True, False)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(True, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 64)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 48)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len")
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/furonics/GNURadio/25Feb2016DataTransfer.dat", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/furonics/GNURadio/11thFeb2016_AtHome.pcap", False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1))    
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2))    
        self.connect((self.blocks_divide_xx_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink1, 0))    
        self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_vector_to_stream_1, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_1, 0))    
        self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0))    
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver Flexdatalink 4")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 1000e-3
        self.samp_rate = samp_rate = 5e6
        self.rx_gain = rx_gain = 1000e-3
        self.pdu_length = pdu_length = 500
        self.mac_dst = mac_dst = [0x12, 0x34, 0x56, 0x78, 0x90, 0xaa]
        self.mac_coord = mac_coord = [0x12, 0x34, 0x56, 0x78, 0x90, 0xaa]
        self.mac_addr = mac_addr = [0x12, 0x34, 0x56, 0x78, 0x90, 0xae]
        self.lo_offset = lo_offset = 0
        self.interval = interval = 1e3
        self.freq = freq = 2.52e9
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(10e6, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            'packet_len',
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0_0.set_normalized_gain(tx_gain, 0)
        self.uhd_usrp_sink_0_0.set_bandwidth(10e6, 0)
        self.somac_sensor_0 = somac.sensor((mac_addr), False, False)
        self.somac_metrics_gen_0 = somac.metrics_gen(False)
        self.somac_decision_0 = somac.decision(False, 60, 5, 30, 1, 0, 1, 1,
                                               '/tmp/backlog_file.npy')
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(127, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.data_link_0 = data_link(
            alpha=1000,
            coord=False,
            csma_threshold=-35,
            debug=False,
            mac_bss=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff],
            mac_coord=mac_coord,
            mac_dst=mac_dst,
            mac_src=mac_addr,
            portid=255,
            samp_rate=5e6,
        )
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap0', 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     '/tmp/wifi_tx_all.pcap',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/wifi_rx_all.pcap',
                                                   False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.data_link_0, 'tap in'))
        self.msg_connect((self.data_link_0, 'tap out'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.data_link_0, 'phy out'),
                         (self.foo_wireshark_connector_0_0, 'in'))
        self.msg_connect((self.data_link_0, 'buff size'),
                         (self.somac_metrics_gen_0, 'bsz in'))
        self.msg_connect((self.data_link_0, 'buffer out'),
                         (self.somac_metrics_gen_0, 'buffer in'))
        self.msg_connect((self.data_link_0, 'new frame out'),
                         (self.somac_metrics_gen_0, 'new frame in'))
        self.msg_connect((self.data_link_0, 'phy out'),
                         (self.somac_metrics_gen_0, 'mac in'))
        self.msg_connect((self.data_link_0, 'snr out'),
                         (self.somac_metrics_gen_0, 'snr in'))
        self.msg_connect((self.data_link_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.somac_decision_0, 'broad out'),
                         (self.data_link_0, 'broad in'))
        self.msg_connect((self.somac_decision_0, 'ctrl out'),
                         (self.data_link_0, 'prot switch'))
        self.msg_connect((self.somac_decision_0, 'metrics out'),
                         (self.somac_metrics_gen_0, 'ctrl in'))
        self.msg_connect((self.somac_metrics_gen_0, 'broad out'),
                         (self.data_link_0, 'metrics in'))
        self.msg_connect((self.somac_sensor_0, 'act prot out'),
                         (self.somac_decision_0, 'act prot in'))
        self.msg_connect((self.somac_sensor_0, 'met buffsize'),
                         (self.somac_decision_0, 'met in8'))
        self.msg_connect((self.somac_sensor_0, 'met contention'),
                         (self.somac_decision_0, 'met in6'))
        self.msg_connect((self.somac_sensor_0, 'met interpkt'),
                         (self.somac_decision_0, 'met in4'))
        self.msg_connect((self.somac_sensor_0, 'met jit'),
                         (self.somac_decision_0, 'met in2'))
        self.msg_connect((self.somac_sensor_0, 'met lat'),
                         (self.somac_decision_0, 'met in1'))
        self.msg_connect((self.somac_sensor_0, 'met non'),
                         (self.somac_decision_0, 'met in7'))
        self.msg_connect((self.somac_sensor_0, 'met pkt_thr'),
                         (self.somac_decision_0, 'met in9'))
        self.msg_connect((self.somac_sensor_0, 'met rnp'),
                         (self.somac_decision_0, 'met in3'))
        self.msg_connect((self.somac_sensor_0, 'met snr'),
                         (self.somac_decision_0, 'met in5'))
        self.msg_connect((self.somac_sensor_0, 'met thr'),
                         (self.somac_decision_0, 'met in0'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.data_link_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.somac_metrics_gen_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.somac_sensor_0, 'phy in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.data_link_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Esempio n. 34
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Transceiver")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 3500000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._freq_options = [
            3500000000.0, 2412000000.0, 2417000000.0, 2422000000.0,
            2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0,
            2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0,
            2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0,
            5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0,
            5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0,
            5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0,
            5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0,
            5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0,
            5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0,
            5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0,
            5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0,
            5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0,
            5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0,
            5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0,
            5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0,
            5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            ' 0|3.5G', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
            '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g',
            '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
            '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g',
            ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
            ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a',
            ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
            ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a',
            ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a',
            ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a',
            ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a',
            '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a',
            '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a',
            '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a',
            '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a',
            '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a',
            '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a',
            '142 | 5710.0 | 11a', '144 | 5720.0 | 11a',
            '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)',
            '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)',
            '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)',
            '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)',
            '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p',
            '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
            '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7]
        self._encoding_labels = [
            "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
            "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        ]
        self._encoding_group_box = Qt.QGroupBox("encoding")
        self._encoding_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._encoding_button_group = variable_chooser_button_group()
        self._encoding_group_box.setLayout(self._encoding_box)
        for i, label in enumerate(self._encoding_labels):
            radio_button = Qt.QRadioButton(label)
            self._encoding_box.addWidget(radio_button)
            self._encoding_button_group.addButton(radio_button, i)
        self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._encoding_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._encoding_options.index(i)))
        self._encoding_callback(self.encoding)
        self._encoding_button_group.buttonClicked[int].connect(
            lambda i: self.set_encoding(self._encoding_options[i]))
        self.top_layout.addWidget(self._encoding_group_box)
        self._chan_est_options = [
            ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
        ]
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
            radio_button = Qt.QRadioButton(label)
            self._chan_est_box.addWidget(radio_button)
            self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._chan_est_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
            lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            48 * 10,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pluto_source_0 = iio.pluto_source('', 3500000000, 10000000,
                                               20000000, 0x8000, True, True,
                                               True, "manual", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink('', 3500000000, 10000000, 20000000,
                                           0x8000, False, 10.0, '', True)
        self._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/wifi.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'carrier'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.pluto_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))