kopia lustrzana https://github.com/rpp0/gr-lora
141 wiersze
4.4 KiB
Python
Executable File
141 wiersze
4.4 KiB
Python
Executable File
#!/usr/bin/env python2
|
|
# -*- coding: utf-8 -*-
|
|
##################################################
|
|
# GNU Radio Python Flow Graph
|
|
# Title: Lora Receive File
|
|
# Generated: Wed Jun 22 19:59:10 2016
|
|
##################################################
|
|
|
|
if __name__ == '__main__':
|
|
import ctypes
|
|
import sys
|
|
if sys.platform.startswith('linux'):
|
|
try:
|
|
x11 = ctypes.cdll.LoadLibrary('libX11.so')
|
|
x11.XInitThreads()
|
|
except:
|
|
print "Warning: failed to XInitThreads()"
|
|
|
|
from gnuradio import blocks
|
|
from gnuradio import eng_notation
|
|
from gnuradio import gr
|
|
from gnuradio.eng_option import eng_option
|
|
from gnuradio.filter import firdes
|
|
from grc_gnuradio import wxgui as grc_wxgui
|
|
from optparse import OptionParser
|
|
import lora
|
|
import wx
|
|
|
|
|
|
class lora_receive_file(grc_wxgui.top_block_gui):
|
|
|
|
def __init__(self):
|
|
grc_wxgui.top_block_gui.__init__(self, title="Lora Receive File")
|
|
|
|
##################################################
|
|
# Variables
|
|
##################################################
|
|
self.target_freq = target_freq = 868.1e6
|
|
self.sf = sf = 12
|
|
self.samp_rate = samp_rate = 10e6
|
|
self.capture_freq = capture_freq = 866.0e6
|
|
self.bw = bw = 125e3
|
|
self.symbols_per_sec = symbols_per_sec = bw / (2**sf)
|
|
self.offset = offset = -(capture_freq - target_freq)
|
|
self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, bw, 10000, firdes.WIN_HAMMING, 6.67)
|
|
self.decimation = decimation = 10
|
|
self.bitrate = bitrate = sf * (1 / (2**sf / bw))
|
|
|
|
##################################################
|
|
# Blocks
|
|
##################################################
|
|
self.lora_lora_receiver_0 = lora.lora_receiver(samp_rate, capture_freq, offset)
|
|
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
|
|
self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "counting_cr4_sf7.cfile", True)
|
|
|
|
##################################################
|
|
# Connections
|
|
##################################################
|
|
self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
|
|
self.connect((self.blocks_throttle_0, 0), (self.lora_lora_receiver_0, 0))
|
|
|
|
def get_target_freq(self):
|
|
return self.target_freq
|
|
|
|
def set_target_freq(self, target_freq):
|
|
self.target_freq = target_freq
|
|
self.set_offset(-(self.capture_freq - self.target_freq))
|
|
|
|
def get_sf(self):
|
|
return self.sf
|
|
|
|
def set_sf(self, sf):
|
|
self.sf = sf
|
|
self.set_bitrate(self.sf * (1 / (2**self.sf / self.bw)))
|
|
self.set_symbols_per_sec(self.bw / (2**self.sf))
|
|
|
|
def get_samp_rate(self):
|
|
return self.samp_rate
|
|
|
|
def set_samp_rate(self, samp_rate):
|
|
self.samp_rate = samp_rate
|
|
self.set_firdes_tap(firdes.low_pass(1, self.samp_rate, self.bw, 10000, firdes.WIN_HAMMING, 6.67))
|
|
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
|
|
|
|
def get_capture_freq(self):
|
|
return self.capture_freq
|
|
|
|
def set_capture_freq(self, capture_freq):
|
|
self.capture_freq = capture_freq
|
|
self.set_offset(-(self.capture_freq - self.target_freq))
|
|
|
|
def get_bw(self):
|
|
return self.bw
|
|
|
|
def set_bw(self, bw):
|
|
self.bw = bw
|
|
self.set_bitrate(self.sf * (1 / (2**self.sf / self.bw)))
|
|
self.set_firdes_tap(firdes.low_pass(1, self.samp_rate, self.bw, 10000, firdes.WIN_HAMMING, 6.67))
|
|
self.set_symbols_per_sec(self.bw / (2**self.sf))
|
|
|
|
def get_symbols_per_sec(self):
|
|
return self.symbols_per_sec
|
|
|
|
def set_symbols_per_sec(self, symbols_per_sec):
|
|
self.symbols_per_sec = symbols_per_sec
|
|
|
|
def get_offset(self):
|
|
return self.offset
|
|
|
|
def set_offset(self, offset):
|
|
self.offset = offset
|
|
|
|
def get_firdes_tap(self):
|
|
return self.firdes_tap
|
|
|
|
def set_firdes_tap(self, firdes_tap):
|
|
self.firdes_tap = firdes_tap
|
|
|
|
def get_decimation(self):
|
|
return self.decimation
|
|
|
|
def set_decimation(self, decimation):
|
|
self.decimation = decimation
|
|
|
|
def get_bitrate(self):
|
|
return self.bitrate
|
|
|
|
def set_bitrate(self, bitrate):
|
|
self.bitrate = bitrate
|
|
|
|
|
|
def main(top_block_cls=lora_receive_file, options=None):
|
|
|
|
tb = top_block_cls()
|
|
tb.Start(True)
|
|
tb.Wait()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|