def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 250e3 self.ldr = ldr = True self.header = header = False self.code_rate = code_rate = 4 ################################################## # Blocks ################################################## self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52002", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "52001", 10000, False) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.blocks_throttle_0_0, 0), (self.lora_demod_0, 0)) self.connect((self.lora_mod_0, 0), (self.blocks_throttle_0_0, 0))
def __init__(self, ansibleFreqRx=2.4555e9, ansibleFreqTx=2.4505e9, ansibleID='1', ansibleIP='notValid', bw=250e3, offset=-250e3): gr.top_block.__init__(self, "Ansible Hydra Gr Client 1Tx 1Rx") ################################################## # Parameters ################################################## self.ansibleFreqRx = ansibleFreqRx self.ansibleFreqTx = ansibleFreqTx self.ansibleID = ansibleID self.ansibleIP = ansibleIP self.bw = bw self.offset = offset ################################################## # Variables ################################################## self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 1e6 self.ldr = ldr = True self.header = header = False self.code_rate = code_rate = 4 ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( bw/samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate/bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.hydra_gr_sink_0 = hydra.hydra_gr_client_sink(int(ansibleID), ansibleIP, 5000) self.hydra_gr_sink_0.start_client(ansibleFreqTx + samp_rate/2 + (samp_rate * int(ansibleID)), samp_rate, 1000) self.hydra_gr__source_0 = hydra.hydra_gr_client_source(int(ansibleID), ansibleIP, ansibleIP, 5000) self.hydra_gr__source_0.start_client(ansibleFreqRx + samp_rate/2 + (samp_rate * int(ansibleID)), samp_rate, 1000) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap0', 1000, False) self.blocks_message_debug_0_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.hydra_gr__source_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.lora_mod_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.hydra_gr_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0))
def __init__(self, ansibleFreqRx=919.75e6, ansibleFreqTx=919.75e6, ansibleID='1', bw=250e3, offset=-250e3): gr.top_block.__init__(self, "Ansible Usrp 1Tx 1Rx") ################################################## # Parameters ################################################## self.ansibleFreqRx = ansibleFreqRx self.ansibleFreqTx = ansibleFreqTx self.ansibleID = ansibleID self.bw = bw self.offset = offset ################################################## # Variables ################################################## self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 1e6 self.ldr = ldr = True self.header = header = False self.code_rate = code_rate = 4 ################################################## # 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( ansibleFreqRx + samp_rate / 2 + (samp_rate * int(ansibleID)), 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 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( ansibleFreqTx + samp_rate / 2 + (samp_rate * int(ansibleID)), 0) self.uhd_usrp_sink_0.set_gain(0.7, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(bw / samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(samp_rate / bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap + ansibleID', 1000, False) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( (2 * math.pi * offset) / samp_rate) self.blocks_rotator_cc_0 = blocks.rotator_cc( (2 * math.pi * offset) / samp_rate) self.blocks_message_debug_0_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.blocks_rotator_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.lora_mod_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_rotator_cc_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") 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 = 0 self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 250e3 self.offset = offset = 0 self.ldr = ldr = True self.header = header = False self.frequency = frequency = 868.1e6 self.code_rate = code_rate = 4 self.bw = bw = 125000 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 50, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'Gain', "counter", int) self.top_grid_layout.addWidget(self._tx_gain_win, 1, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self._spreading_factor_range = Range(7, 12, 1, 8, 200) self._spreading_factor_win = RangeWidget(self._spreading_factor_range, self.set_spreading_factor, "spreading_factor", "counter_slider", int) self.top_layout.addWidget(self._spreading_factor_win) self._offset_range = Range(-samp_rate / 2, samp_rate / 2, 1000, 0, 200) self._offset_win = RangeWidget(self._offset_range, self.set_offset, 'offset', "counter", float) self.top_grid_layout.addWidget(self._offset_win, 2, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self._frequency_options = ( 868.1e6, 433e6, ) self._frequency_labels = ( '868.1 Mhz', '433 Mhz', ) self._frequency_group_box = Qt.QGroupBox('Frequency') self._frequency_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._frequency_button_group = variable_chooser_button_group() self._frequency_group_box.setLayout(self._frequency_box) for i, label in enumerate(self._frequency_labels): radio_button = Qt.QRadioButton(label) self._frequency_box.addWidget(radio_button) self._frequency_button_group.addButton(radio_button, i) self._frequency_callback = lambda i: Qt.QMetaObject.invokeMethod( self._frequency_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._frequency_options.index(i))) self._frequency_callback(self.frequency) self._frequency_button_group.buttonClicked[int].connect( lambda i: self.set_frequency(self._frequency_options[i])) self.top_grid_layout.addWidget(self._frequency_group_box, 2, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self._bw_range = Range(0, 150000, 1000, 125000, 200) self._bw_win = RangeWidget(self._bw_range, self.set_bw, 'bw', "counter", int) self.top_grid_layout.addWidget(self._bw_win, 1, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] 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(frequency, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(samp_rate / bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '52001', 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc( (2 * math.pi * offset) / samp_rate) messageBox = QLineEdit() self.top_layout.addWidget(messageBox) button = QPushButton('Send Message') def on_click(self): message = messageBox.text() new = wrap(message, 3) chunks = [message[i:i + 3] for i in range(0, len(message), 3)] allCharactere = "" for part in chunks: if len(part) == 1: allCharactere = allCharactere + part + '\0' if len(part) == 2: allCharactere = allCharactere + part + '\0' if len(part) == 3: allCharactere = allCharactere + part message_to_send = (allCharactere + '\n').encode() serverIn.send(message_to_send) if len(allCharactere) % 3 == 0: serverIn.send(('\0' + '\0' + '\n').encode()) messageBox.setText("") button.clicked.connect(on_click) self.top_layout.addWidget(button) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.blocks_rotator_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.lora_mod_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self, MTU=10000, bw=100e3, frequency_rx=2.4505e9 + 1e6, frequency_tx=2.4505e9, ip_pub='tcp://192.168.5.134:7001', ip_sub='tcp://192.168.5.109:7000', offset=-250e3): gr.top_block.__init__(self, "Lora Side1") ################################################## # Parameters ################################################## self.MTU = MTU self.bw = bw self.frequency_rx = frequency_rx self.frequency_tx = frequency_tx self.ip_pub = ip_pub self.ip_sub = ip_sub self.offset = offset ################################################## # Variables ################################################## self.rep = rep = 3 self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 500e3 self.ldr = ldr = True self.header = header = False self.enc_rep = enc_rep = fec.repetition_encoder_make(480, rep) self.enc_dummy = enc_dummy = fec.dummy_encoder_make(MTU*8) self.enc_ccsds = enc_ccsds = fec.ccsds_encoder_make(MTU*8, 0, fec.CC_TERMINATED) self.dec_rep = dec_rep = fec.repetition_decoder.make(480, rep, 0.5) self.dec_dummy = dec_dummy = fec.dummy_decoder.make(MTU*8) self.dec_cc = dec_cc = fec.cc_decoder.make(8000, 7, 2, ([109,79]), 0, -1, fec.CC_TERMINATED, False) self.code_rate = code_rate = 4 ################################################## # Blocks ################################################## self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, ip_pub, 100, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, ip_sub, 100, False, -1) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( bw/samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate/bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap0', MTU, False) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.lora_mod_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0))
def __init__(self, bw=100e3, frequency=2.4505e9): gr.top_block.__init__(self, "Lora Usrp") Qt.QWidget.__init__(self) self.setWindowTitle("Lora Usrp") 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", "lora_usrp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.bw = bw self.frequency = frequency ################################################## # Variables ################################################## self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 500e3 self.offset = offset = 0 self.ldr = ldr = True self.header = header = False self.gain = gain = 0.8 self.code_rate = code_rate = 4 ################################################## # Blocks ################################################## self._offset_range = Range(-500e3, 500e3, 1e3, 0, 200) self._offset_win = RangeWidget(self._offset_range, self.set_offset, 'offset', "counter_slider", float) self.top_layout.addWidget(self._offset_win) self._gain_range = Range(0, 1, 0.01, 0.8, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain', "counter_slider", float) self.top_layout.addWidget(self._gain_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(frequency, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 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(frequency, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(bw / samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(samp_rate / bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '11111', 10000, False) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( (2 * math.pi * offset) / samp_rate) self.blocks_rotator_cc_0 = blocks.rotator_cc( (2 * math.pi * offset) / samp_rate) self.blocks_message_debug_0_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_message_debug_0_0, 'print')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.blocks_rotator_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.lora_mod_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_rotator_cc_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") 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.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 250e3 self.rx_gain = rx_gain = 0 self.offset = offset = 0 self.ldr = ldr = True self.header = header = False self.frequency = frequency = 868.1e6 self.code_rate = code_rate = 4 self.bw = bw = 125000 ################################################## # Blocks ################################################## self._spreading_factor_range = Range(7, 12, 1, 8, 200) self._spreading_factor_win = RangeWidget(self._spreading_factor_range, self.set_spreading_factor, "spreading_factor", "counter_slider", int) self.top_layout.addWidget(self._spreading_factor_win) self._rx_gain_range = Range(0, 50, 1, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'Gain', "counter", int) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self._offset_range = Range(-samp_rate / 2, samp_rate / 2, 1000, 0, 200) self._offset_win = RangeWidget(self._offset_range, self.set_offset, 'offset', "counter", float) self.top_grid_layout.addWidget(self._offset_win, 1, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self._frequency_options = ( 868.1e6, 433e6, ) self._frequency_labels = ( '868.1 Mhz', '433 Mhz', ) self._frequency_group_box = Qt.QGroupBox('Frequency') self._frequency_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._frequency_button_group = variable_chooser_button_group() self._frequency_group_box.setLayout(self._frequency_box) for i, label in enumerate(self._frequency_labels): radio_button = Qt.QRadioButton(label) self._frequency_box.addWidget(radio_button) self._frequency_button_group.addButton(radio_button, i) self._frequency_callback = lambda i: Qt.QMetaObject.invokeMethod( self._frequency_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._frequency_options.index(i))) self._frequency_callback(self.frequency) self._frequency_button_group.buttonClicked[int].connect( lambda i: self.set_frequency(self._frequency_options[i])) self.top_grid_layout.addWidget(self._frequency_group_box, 1, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self._bw_range = Range(0, 150000, 1000, 125000, 200) self._bw_win = RangeWidget(self._bw_range, self.set_bw, 'bw', "counter", int) self.top_grid_layout.addWidget(self._bw_win, 0, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_CLIENT", '127.0.0.1', '52002', 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '52001', 10000, False) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.blocks_throttle_0_0, 0), (self.lora_demod_0, 0)) self.connect((self.lora_mod_0, 0), (self.blocks_throttle_0_0, 0))