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.freq = freq = 2480000000 ################################################## # Blocks ################################################## 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(4000000) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_normalized_gain(rx_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.futebol_msg_to_file_0 = futebol.msg_to_file() self.futebol_msg_rssi_msg_0 = futebol.msg_rssi_msg(-0.5) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, '/tmp/teste.csv', False) self.blocks_file_sink_0_0.set_unbuffered(True) self.RSSI_0 = RSSI() ################################################## # Connections ################################################## self.msg_connect((self.futebol_msg_rssi_msg_0, 'msg_out'), (self.futebol_msg_to_file_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.futebol_msg_rssi_msg_0, 'msg_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.RSSI_0, 0), (self.futebol_msg_rssi_msg_0, 0)) self.connect((self.futebol_msg_to_file_0, 0), (self.blocks_file_sink_0_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.RSSI_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, "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))
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): 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))
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))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="IEEE 802.15.4 Transceiver using CSS PHY") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.text_msg = text_msg = "This is a test message" self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg) + 15) self.samp_rate = samp_rate = 32e6 self.phi = phi = 10 self.pad_len = pad_len = c.nsamp_frame * 0 self.msg_interval = msg_interval = 1000 self.freq_off = freq_off = 0 self.enable = enable = 1.0 self.delay = delay = 0 self.ampl = ampl = 0 ################################################## # Blocks ################################################## _pad_len_sizer = wx.BoxSizer(wx.VERTICAL) self._pad_len_text_box = forms.text_box( parent=self.GetWin(), sizer=_pad_len_sizer, value=self.pad_len, callback=self.set_pad_len, label="Pad Length", converter=forms.float_converter(), proportion=0, ) self._pad_len_slider = forms.slider( parent=self.GetWin(), sizer=_pad_len_sizer, value=self.pad_len, callback=self.set_pad_len, minimum=0, maximum=10000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pad_len_sizer) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols") self.Add(self.nb) _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL) self._msg_interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, label="Message Interval [ms]", converter=forms.float_converter(), proportion=0, ) self._msg_interval_slider = forms.slider( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, minimum=1, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_msg_interval_sizer) _freq_off_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_off_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_off_sizer, value=self.freq_off, callback=self.set_freq_off, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._freq_off_slider = forms.slider( parent=self.GetWin(), sizer=_freq_off_sizer, value=self.freq_off, callback=self.set_freq_off, minimum=-1e5, maximum=1e5, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_off_sizer) _delay_sizer = wx.BoxSizer(wx.VERTICAL) self._delay_text_box = forms.text_box( parent=self.GetWin(), sizer=_delay_sizer, value=self.delay, callback=self.set_delay, label="Delay", converter=forms.float_converter(), proportion=0, ) self._delay_slider = forms.slider( parent=self.GetWin(), sizer=_delay_sizer, value=self.delay, callback=self.set_delay, minimum=0, maximum=100000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_delay_sizer) _ampl_sizer = wx.BoxSizer(wx.VERTICAL) self._ampl_text_box = forms.text_box( parent=self.GetWin(), sizer=_ampl_sizer, value=self.ampl, callback=self.set_ampl, label="Noise Amplitude", converter=forms.float_converter(), proportion=0, ) self._ampl_slider = forms.slider( parent=self.GetWin(), sizer=_ampl_sizer, value=self.ampl, callback=self.set_ampl, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_ampl_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="RX Waterfall", ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_3 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="RX Correlator Output", 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(3).Add(self.wxgui_scopesink2_3.win) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.nb.GetPage(2).GetWin(), title="RX Time Signal", 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(2).Add(self.wxgui_scopesink2_2.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="RX FFT", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) _phi_sizer = wx.BoxSizer(wx.VERTICAL) self._phi_text_box = forms.text_box( parent=self.GetWin(), sizer=_phi_sizer, value=self.phi, callback=self.set_phi, label="Phi", converter=forms.float_converter(), proportion=0, ) self._phi_slider = forms.slider( parent=self.GetWin(), sizer=_phi_sizer, value=self.phi, callback=self.set_phi, minimum=2, maximum=20, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_phi_sizer) 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) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self._enable_chooser = forms.button( parent=self.GetWin(), value=self.enable, callback=self.set_enable, label="TX Enable", choices=[1.0, 0.0], labels=['on', 'off'], ) self.Add(self._enable_chooser) self.blocks_vector_insert_x_0 = blocks.vector_insert_c( ([0 for i in range(pad_len)]), 3 * c.nsamp_frame, 3 * c.nsamp_frame) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern(text_msg), msg_interval) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, freq_off, 1, 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, ampl, 0, 8192) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 10) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_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_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, '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_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.analog_const_source_x_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_vector_insert_x_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.ieee802_15_4_css_phy_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 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))
def __init__(self, num_messages=1000000000, pad=0x00, preamble=0x000000a7, tx_gain=.75): gr.top_block.__init__(self, "IEEE 802.15.4 Transmitter using OQPSK PHY") Qt.QWidget.__init__(self) self.setWindowTitle("IEEE 802.15.4 Transmitter 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", "transmitter_OQPSK") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.num_messages = num_messages self.pad = pad self.preamble = preamble self.tx_gain = tx_gain ################################################## # Variables ################################################## self.ch = ch = 11 self.samp_rate = samp_rate = 4000000 self.freq = freq = 1000000 * (2400 + 5 * (ch - 10)) ################################################## # 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_mac_0 = ieee802_15_4.mac(True, 0x8841, 0, 0x1aaa, 0xffff, 0x3344) self.ieee802_15_4_access_code_prefixer_0 = ieee802_15_4.access_code_prefixer( pad, preamble) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( ([(1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j)]), 16) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc( (([])), 0, 4, False, "pdu_length") self._ch_range = Range(11, 26, 1, 11, 200) self._ch_win = RangeWidget(self._ch_range, self.set_ch, "ch", "counter_slider", float) self.top_grid_layout.addWidget(self._ch_win) self.blocks_vector_source_x_0 = blocks.vector_source_c( [0, sin(pi / 4), 1, sin(3 * pi / 4)], True, 1, []) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, 'pdu_length', 128) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_float * 1, False) self.blocks_tag_gate_0.set_single_key("") 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_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("Hello World!\n"), 1000) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 2) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # 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_access_code_prefixer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_access_code_prefixer_0, 'in')) 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_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) 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.uhd_usrp_sink_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_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_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))
def __init__(self): parser = OptionParser() parser.add_option("--length", type="int", dest="length", help="MAC payload length(1-112)", default="10") parser.add_option("--rate", type="float", dest="rate", help="Tx and Rx sample rate", default=4e6) parser.add_option("--period", type="int", dest="period", help="Message Source Period", default=500) (options, args) = parser.parse_args() 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", "transceiver_OQPSK") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tx_gain = tx_gain = 0.75 self.samp_rate = samp_rate = options.rate self.rx_gain = rx_gain = 0.75 self.freq = freq = 2480000000 ################################################## # 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_grid_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_grid_layout.addWidget(self._rx_gain_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size 4e6, #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) self.qtgui_time_sink_x_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.output_chain_0 = output_chain(samp_rate=samp_rate, ) self.limesdr_source_0_0 = limesdr.source( 0, 2, 1, 0, 0, '/home/saptarshi/Documents/MasterThesis@RISE/lime-gnuradio/src/limesuite/build/example', 2.48e9, samp_rate, 0, 1, samp_rate, 0, 10e6, 1, 2, 1, 1, 5e6 + samp_rate % 5e6 * int(samp_rate / 5e6), 0, 10e6, 0, samp_rate, 0, 0, 60, 60) self.limesdr_sink_1 = limesdr.sink( 0, 2, 1, 0, 0, '', 2.48e9, samp_rate, 0, 1, samp_rate, 0, 10e6, 1, 2, 1, 1, 5e6 + samp_rate % 5e6 * int(samp_rate / 5e6), 0, 10e6, 0, 4e6, 0, 0, 60, 60) self.input_chain_0 = input_chain(omega=samp_rate / 2e6, ) 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(False, 0x8841, 0, 0x1aaa, 0xffff, 0x3344) 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_grid_layout.addWidget(self._freq_tool_bar) self.foo_rtt_0 = foo.rtt(options.period, options.length) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, '/tmp/timings', False) self.blocks_file_sink_0_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.foo_rtt_0, 'out'), (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.output_chain_0, 'txin')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.foo_rtt_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.input_chain_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.connect((self.foo_rtt_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.limesdr_source_0_0, 0), (self.input_chain_0, 0)) #self.connect((self.limesdr_source_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.output_chain_0, 0), (self.limesdr_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.freq = freq = 2.48e9 ################################################## # Blocks ################################################## 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(0, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("J1", 0) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([130]), ([131]), ([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) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52001", 10000, False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_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_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, '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.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, 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): 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))
def __init__(self, freq=2480000000, gain=48, method=7): gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using OQPSK PHY") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.method = method ################################################## # Blocks ################################################## self.uhdgps_cpdu_average_power_0 = uhdgps.cpdu_average_power(-60) 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(5000000) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(5000000) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.lqe_powerControl_0 = lqe.powerControl( gain, '/home/wendley/SerieGanho100ms.txt', False) self.lqe_getRSSI_0 = lqe.getRSSI(False, 2, 2, 40, -108, -67, 0.500, 0.2, 0.1, 0.05) 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_periodic_msg_source_1 = foo.periodic_msg_source( pmt.intern( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ), 400, 1000, True, False) self.es_trigger_sample_timer_0 = es.trigger_sample_timer( gr.sizeof_gr_complex, int(2000), 2, int(4000000), 512) self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 8, 64, 0, 2, 0) self.es_handler_pdu_0 = es.es_make_handler_pdu( es.es_handler_print.TYPE_C32) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 2, 1000, 0.001) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_pdu_remove_0 = blocks.pdu_remove( pmt.intern("es::event_buffer")) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.ieee802_15_4_mac_0, 'cs in')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.lqe_getRSSI_0, 'SNR')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.uhdgps_cpdu_average_power_0, 'cpdus')) self.msg_connect( (self.es_trigger_sample_timer_0, 'sample_timer_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_sample_timer_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.foo_periodic_msg_source_1, 'out'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.foo_periodic_msg_source_1, 'out'), (self.lqe_getRSSI_0, 'sendOrder')) 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_mac_0, 'ackOut'), (self.lqe_getRSSI_0, 'Ackin')) self.msg_connect((self.ieee802_15_4_mac_0, 'packLost'), (self.lqe_getRSSI_0, 'lostPacks')) self.msg_connect((self.ieee802_15_4_mac_0, 'resendPck'), (self.lqe_getRSSI_0, 'sendPacks')) self.msg_connect((self.ieee802_15_4_mac_0, 'ackOut'), (self.lqe_powerControl_0, 'saveGain')) self.msg_connect((self.ieee802_15_4_mac_0, 'resendPck'), (self.lqe_powerControl_0, 'saveGain')) 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, '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.msg_connect((self.lqe_getRSSI_0, 'estimation'), (self.lqe_powerControl_0, 'estimation')) self.msg_connect((self.uhdgps_cpdu_average_power_0, 'cpdus'), (self.blocks_pdu_remove_0, 'pdus')) self.msg_connect((self.uhdgps_cpdu_average_power_0, 'rssi'), (self.lqe_getRSSI_0, 'RSSIin')) self.connect((self.es_trigger_sample_timer_0, 0), (self.es_sink_0, 0)) 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.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.es_trigger_sample_timer_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, "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))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="IEEE 802.15.4 Transceiver using CSS PHY") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.freq = freq = 2480000000 self.samp_rate = samp_rate = 1e6 self.msg_interval = msg_interval = 1000 self.gain = gain = 20 self.cur_freq = cur_freq = freq self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols") self.Add(self.nb) _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL) self._msg_interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, label="Message interval [ms]", converter=forms.float_converter(), proportion=0, ) self._msg_interval_slider = forms.slider( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, minimum=1, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_msg_interval_sizer) _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="TX/RX 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_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="RX Waterfall", ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_3 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="RX Correlator Output", 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(3).Add(self.wxgui_scopesink2_3.win) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.nb.GetPage(2).GetWin(), title="RX Time Signal", 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(2).Add(self.wxgui_scopesink2_2.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="RX FFT", peak_hold=False, ) self.nb.GetPage(1).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(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_gain(gain, 0) self.uhd_usrp_sink_1.set_antenna("TX/RX", 0) 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) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self._cur_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.cur_freq, callback=self.set_cur_freq, label="Current center frequency", converter=forms.float_converter(), ) self.Add(self._cur_freq_static_text) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "8048", 10000, False) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), msg_interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_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_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, '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_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.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using CSS PHY") Qt.QWidget.__init__(self) self.setWindowTitle("IEEE 802.15.4 Transceiver using CSS 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", "transceiver_CSS_USRP") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.tx_gain = tx_gain = 0.75 self.samp_rate = samp_rate = 1e6 self.rx_gain = rx_gain = 0.75 self.interval = interval = 300 self.freq = freq = 2480000000 self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15) ################################################## # 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._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._interval_range = Range(10, 1000, 1, 300, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int) self.top_layout.addWidget(self._interval_win) 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.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('addr=192.168.10.4', "")), 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(freq, 0) self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(('addr=192.168.10.6', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_normalized_gain(tx_gain, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #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 = ['', '', '', '', '', '', '', '', '', ''] 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_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #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_mac_0 = ieee802_15_4.mac(True) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), interval) ################################################## # 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_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, '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_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.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="IEEE 802.15.4 Transceiver using CSS PHY") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.freq = freq = 2480000000 self.samp_rate = samp_rate = 1e6 self.msg_interval = msg_interval = 1000 self.gain = gain = 20 self.cur_freq = cur_freq = freq self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg) + 15) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols") self.Add(self.nb) _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL) self._msg_interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, label="Message interval [ms]", converter=forms.float_converter(), proportion=0, ) self._msg_interval_slider = forms.slider( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, minimum=1, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_msg_interval_sizer) _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="TX/RX 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_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="RX Waterfall", ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_3 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="RX Correlator Output", 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(3).Add(self.wxgui_scopesink2_3.win) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.nb.GetPage(2).GetWin(), title="RX Time Signal", 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(2).Add(self.wxgui_scopesink2_2.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="RX FFT", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.4", "")), 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(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("J1", 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("addr=192.168.10.6", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_gain(gain, 0) self.trafficGenerator_Distribution_0 = trafficGenerator.Distribution( 0, 100, 4, 5, int) 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) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self._cur_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.cur_freq, callback=self.set_cur_freq, label="Current center frequency", converter=forms.float_converter(), ) self.Add(self._cur_freq_static_text) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern(text_msg), msg_interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_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_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, '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_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.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0)) self.connect((self.trafficGenerator_Distribution_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 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): 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", "transceiver_OQPSK") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tx_gain = tx_gain = 0.75 self.rx_gain = rx_gain = 0.75 self.freq = freq = 2480000000 ################################################## # 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_grid_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_grid_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_grid_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() self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True, 0x8841, 0, 0x1aaa, 0xffff, 0x3344) 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_grid_layout.addWidget(self._freq_tool_bar) 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"), 1000) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # 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.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, '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.ieee802_15_4_oqpsk_phy_0, 0), (self.foo_packet_pad_0, 0)) self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.qtgui_freq_sink_x_0, 0))