kopia lustrzana https://github.com/rpp0/gr-lora
				
				
				
			
		
			
				
	
	
		
			175 wiersze
		
	
	
		
			5.7 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			175 wiersze
		
	
	
		
			5.7 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
| #!/usr/bin/env python2
 | |
| # -*- coding: utf-8 -*-
 | |
| ##################################################
 | |
| # GNU Radio Python Flow Graph
 | |
| # Title: Lora Receive Realtime
 | |
| # Generated: Mon Jan  8 15:32:44 2018
 | |
| ##################################################
 | |
| 
 | |
| 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 eng_notation
 | |
| from gnuradio import gr
 | |
| from gnuradio import wxgui
 | |
| from gnuradio.eng_option import eng_option
 | |
| from gnuradio.fft import window
 | |
| from gnuradio.filter import firdes
 | |
| from gnuradio.wxgui import fftsink2
 | |
| from grc_gnuradio import wxgui as grc_wxgui
 | |
| from optparse import OptionParser
 | |
| import lora
 | |
| import osmosdr
 | |
| import wx
 | |
| 
 | |
| 
 | |
| class lora_receive_realtime(grc_wxgui.top_block_gui):
 | |
| 
 | |
|     def __init__(self):
 | |
|         grc_wxgui.top_block_gui.__init__(self, title="Lora Receive Realtime")
 | |
| 
 | |
|         ##################################################
 | |
|         # Variables
 | |
|         ##################################################
 | |
|         self.sf = sf = 11
 | |
|         self.samp_rate = samp_rate = 1e6
 | |
|         self.bw = bw = 125000
 | |
|         self.target_freq = target_freq = 868.1e6
 | |
|         self.symbols_per_sec = symbols_per_sec = float(bw) / (2**sf)
 | |
|         self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, bw, 10000, firdes.WIN_HAMMING, 6.67)
 | |
|         self.downlink = downlink = False
 | |
|         self.decimation = decimation = 1
 | |
|         self.capture_freq = capture_freq = 868e6
 | |
|         self.bitrate = bitrate = sf * (1 / (2**sf / float(bw)))
 | |
| 
 | |
|         ##################################################
 | |
|         # Blocks
 | |
|         ##################################################
 | |
|         self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
 | |
|         	self.GetWin(),
 | |
|         	baseband_freq=capture_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=False,
 | |
|         	avg_alpha=None,
 | |
|         	title='FFT Plot',
 | |
|         	peak_hold=False,
 | |
|         )
 | |
|         self.Add(self.wxgui_fftsink2_1.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(capture_freq, 0)
 | |
|         self.osmosdr_source_0.set_freq_corr(0, 0)
 | |
|         self.osmosdr_source_0.set_dc_offset_mode(0, 0)
 | |
|         self.osmosdr_source_0.set_iq_balance_mode(0, 0)
 | |
|         self.osmosdr_source_0.set_gain_mode(False, 0)
 | |
|         self.osmosdr_source_0.set_gain(10, 0)
 | |
|         self.osmosdr_source_0.set_if_gain(20, 0)
 | |
|         self.osmosdr_source_0.set_bb_gain(20, 0)
 | |
|         self.osmosdr_source_0.set_antenna('', 0)
 | |
|         self.osmosdr_source_0.set_bandwidth(0, 0)
 | |
| 
 | |
|         self.lora_message_socket_sink_0 = lora.message_socket_sink('127.0.0.1', 40868, 0)
 | |
|         self.lora_lora_receiver_0 = lora.lora_receiver(1e6, capture_freq, ([target_freq]), bw, sf, False, 4, True, False, downlink, decimation, False, False)
 | |
| 
 | |
|         ##################################################
 | |
|         # Connections
 | |
|         ##################################################
 | |
|         self.msg_connect((self.lora_lora_receiver_0, 'frames'), (self.lora_message_socket_sink_0, 'in'))
 | |
|         self.connect((self.osmosdr_source_0, 0), (self.lora_lora_receiver_0, 0))
 | |
|         self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_1, 0))
 | |
| 
 | |
|     def get_sf(self):
 | |
|         return self.sf
 | |
| 
 | |
|     def set_sf(self, sf):
 | |
|         self.sf = sf
 | |
|         self.set_symbols_per_sec(float(self.bw) / (2**self.sf))
 | |
|         self.lora_lora_receiver_0.set_sf(self.sf)
 | |
|         self.set_bitrate(self.sf * (1 / (2**self.sf / float(self.bw))))
 | |
| 
 | |
|     def get_samp_rate(self):
 | |
|         return self.samp_rate
 | |
| 
 | |
|     def set_samp_rate(self, samp_rate):
 | |
|         self.samp_rate = samp_rate
 | |
|         self.wxgui_fftsink2_1.set_sample_rate(self.samp_rate)
 | |
|         self.osmosdr_source_0.set_sample_rate(self.samp_rate)
 | |
|         self.set_firdes_tap(firdes.low_pass(1, self.samp_rate, self.bw, 10000, firdes.WIN_HAMMING, 6.67))
 | |
| 
 | |
|     def get_bw(self):
 | |
|         return self.bw
 | |
| 
 | |
|     def set_bw(self, bw):
 | |
|         self.bw = bw
 | |
|         self.set_symbols_per_sec(float(self.bw) / (2**self.sf))
 | |
|         self.set_firdes_tap(firdes.low_pass(1, self.samp_rate, self.bw, 10000, firdes.WIN_HAMMING, 6.67))
 | |
|         self.set_bitrate(self.sf * (1 / (2**self.sf / float(self.bw))))
 | |
| 
 | |
|     def get_target_freq(self):
 | |
|         return self.target_freq
 | |
| 
 | |
|     def set_target_freq(self, target_freq):
 | |
|         self.target_freq = target_freq
 | |
| 
 | |
|     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_firdes_tap(self):
 | |
|         return self.firdes_tap
 | |
| 
 | |
|     def set_firdes_tap(self, firdes_tap):
 | |
|         self.firdes_tap = firdes_tap
 | |
| 
 | |
|     def get_downlink(self):
 | |
|         return self.downlink
 | |
| 
 | |
|     def set_downlink(self, downlink):
 | |
|         self.downlink = downlink
 | |
| 
 | |
|     def get_decimation(self):
 | |
|         return self.decimation
 | |
| 
 | |
|     def set_decimation(self, decimation):
 | |
|         self.decimation = decimation
 | |
| 
 | |
|     def get_capture_freq(self):
 | |
|         return self.capture_freq
 | |
| 
 | |
|     def set_capture_freq(self, capture_freq):
 | |
|         self.capture_freq = capture_freq
 | |
|         self.wxgui_fftsink2_1.set_baseband_freq(self.capture_freq)
 | |
|         self.osmosdr_source_0.set_center_freq(self.capture_freq, 0)
 | |
| 
 | |
|     def get_bitrate(self):
 | |
|         return self.bitrate
 | |
| 
 | |
|     def set_bitrate(self, bitrate):
 | |
|         self.bitrate = bitrate
 | |
| 
 | |
| 
 | |
| def main(top_block_cls=lora_receive_realtime, options=None):
 | |
| 
 | |
|     tb = top_block_cls()
 | |
|     tb.Start(True)
 | |
|     tb.Wait()
 | |
| 
 | |
| 
 | |
| if __name__ == '__main__':
 | |
|     main()
 |