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))
Ejemplo n.º 2
0
    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))    
Ejemplo n.º 3
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))
Ejemplo n.º 4
0
    def __init__(self):
        global text_area
        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, 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._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_source_1 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_center_freq(frequency, 0)
        self.uhd_usrp_source_1.set_gain(rx_gain, 0)
        self.uhd_usrp_source_1.set_antenna("TX/RX", 0)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            frequency,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(bw / samp_rate,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        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_CLIENT", '127.0.0.1',
                                                     '52002', 10000, False)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            (2 * math.pi * offset) / samp_rate)
        self.blocks_message_debug_0 = blocks.message_debug()
        text_area = QPlainTextEdit()
        self.top_layout.addWidget(text_area)

        ##################################################
        # Connections
        ##################################################
        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, 'pdus'))
        self.msg_connect((self.lora_demod_0, 'out'),
                         (self.lora_decode_0, 'in'))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.lora_demod_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.qtgui_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_1, 0),
                     (self.blocks_rotator_cc_0, 0))
Ejemplo n.º 5
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))
Ejemplo n.º 6
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))
Ejemplo n.º 7
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))
Ejemplo n.º 8
0
    def __init__(self):
        gr.top_block.__init__(self, "Lora Reciever")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lora Reciever")
        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_reciever")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.spreading_factor = spreading_factor = 12
        self.samp_rate = samp_rate = 1e6
        self.rf_gain = rf_gain = 0
        self.offset = offset = -250e3
        self.ldr = ldr = False
        self.if_gain = if_gain = 4
        self.header = header = True
        self.frequency = frequency = 915e6
        self.code_rate = code_rate = 4
        self.bw = bw = 1 * 125e3 + 0 * 250e3 + 0 * 500e3
        self.bb_gain = bb_gain = 8

        ##################################################
        # Blocks
        ##################################################
        self._rf_gain_range = Range(0, 12, 1, 0, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain,
                                        "rf_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rf_gain_win)
        self._if_gain_range = Range(0, 40, 8, 4, 200)
        self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain,
                                        "if_gain", "counter_slider", float)
        self.top_layout.addWidget(self._if_gain_win)
        self._frequency_range = Range(400e6, 1e9, 100e3, 915e6, 200)
        self._frequency_win = RangeWidget(self._frequency_range,
                                          self.set_frequency, 'frequency',
                                          "counter_slider", float)
        self.top_layout.addWidget(self._frequency_win)
        self._bw_tool_bar = Qt.QToolBar(self)

        if None:
            self._bw_formatter = None
        else:
            self._bw_formatter = lambda x: x

        self._bw_tool_bar.addWidget(Qt.QLabel('bw' + ": "))
        self._bw_label = Qt.QLabel(str(self._bw_formatter(self.bw)))
        self._bw_tool_bar.addWidget(self._bw_label)
        self.top_layout.addWidget(self._bw_tool_bar)

        self._bb_gain_range = Range(0, 62, 2, 8, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        "bb_gain", "counter_slider", float)
        self.top_layout.addWidget(self._bb_gain_win)
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            frequency + 500e3,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0_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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_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(frequency, 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(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self._offset_range = Range(-samp_rate / 2, samp_rate / 2, 2, -250e3,
                                   200)
        self._offset_win = RangeWidget(self._offset_range, self.set_offset,
                                       'ofsett', "counter_slider", float)
        self.top_layout.addWidget(self._offset_win)
        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_CLIENT", '127.0.0.1',
                                                     '52002', 10000, False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 500e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.lora_decode_0, 'out'),
                         (self.blocks_message_debug_0, 'print'))
        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, 'pdus'))
        self.msg_connect((self.lora_demod_0, 'out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.lora_demod_0, 'out'),
                         (self.lora_decode_0, 'in'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.lora_demod_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))