dev
parent
461cae49a6
commit
cfb5021a1b
@ -0,0 +1,607 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?grc format='1' created='3.7.11'?>
|
||||
<flow_graph>
|
||||
<timestamp>Thu Jan 16 23:43:45 2020</timestamp>
|
||||
<block>
|
||||
<key>options</key>
|
||||
<param>
|
||||
<key>author</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>window_size</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>category</key>
|
||||
<value>[GRC Hier Blocks]</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>description</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(8, 8)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>generate_options</key>
|
||||
<value>wx_gui</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>hier_block_src_path</key>
|
||||
<value>.:</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>iq_transmitter</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>max_nouts</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>qt_qss_theme</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>realtime_scheduling</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>run_command</key>
|
||||
<value>{python} -u {filename}</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>run_options</key>
|
||||
<value>prompt</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>run</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>thread_safe_setters</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>title</key>
|
||||
<value>IQ Transmitter</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>variable</key>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(8, 76)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>samp_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>2e6</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>blocks_file_source</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>file</key>
|
||||
<value>/home/user/Dev/Git Repos/ism-band-trollkit-spoofer/output.complex</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(8, 140)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>blocks_file_source_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>maxoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>minoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>complex</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>repeat</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>vlen</key>
|
||||
<value>1</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>blocks_multiply_const_vxx</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>const</key>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(208, 148)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>blocks_multiply_const_vxx_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>complex</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>maxoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>minoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>vlen</key>
|
||||
<value>1</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>blocks_throttle</key>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(384, 148)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>blocks_throttle_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>ignoretag</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>maxoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>minoutbuf</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>samples_per_second</key>
|
||||
<value>samp_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>complex</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>vlen</key>
|
||||
<value>1</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>limesdr_sink</key>
|
||||
<param>
|
||||
<key>allow_tcxo_dac</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>analog_bandw_ch0</key>
|
||||
<value>5e6</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>calibr_bandw_ch0</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>digital_bandw_ch0</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>gain_dB_ch0</key>
|
||||
<value>60</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>nco_freq_ch0</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>pa_path_ch0</key>
|
||||
<value>255</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>analog_bandw_ch1</key>
|
||||
<value>5e6</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>calibr_bandw_ch1</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>digital_bandw_ch1</key>
|
||||
<value>100e3</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>gain_dB_ch1</key>
|
||||
<value>60</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>nco_freq_ch1</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>pa_path_ch1</key>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>channel_mode</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>serial</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>filename</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(600, 276)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>limesdr_sink_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>length_tag_name</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>oversample</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>rf_freq</key>
|
||||
<value>433.92e6</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>samp_rate</key>
|
||||
<value>samp_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>dacVal</key>
|
||||
<value>125</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>wxgui_fftsink2</key>
|
||||
<param>
|
||||
<key>avg_alpha</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>average</key>
|
||||
<value>False</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>baseband_freq</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>fft_size</key>
|
||||
<value>1024</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>freqvar</key>
|
||||
<value>None</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(600, 104)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>grid_pos</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>wxgui_fftsink2_0_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>notebook</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>peak_hold</key>
|
||||
<value>False</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>ref_level</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>ref_scale</key>
|
||||
<value>2.0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>fft_rate</key>
|
||||
<value>15</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>samp_rate</key>
|
||||
<value>samp_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>title</key>
|
||||
<value>FFT Plot</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>complex</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>win_size</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>win</key>
|
||||
<value>None</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>y_divs</key>
|
||||
<value>10</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>y_per_div</key>
|
||||
<value>10</value>
|
||||
</param>
|
||||
</block>
|
||||
<block>
|
||||
<key>wxgui_scopesink2</key>
|
||||
<param>
|
||||
<key>ac_couple</key>
|
||||
<value>False</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>alias</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>comment</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>affinity</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
<value>(600, 16)</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_rotation</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>grid_pos</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>wxgui_scopesink2_0_0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>notebook</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>num_inputs</key>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>samp_rate</key>
|
||||
<value>samp_rate</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>t_scale</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>title</key>
|
||||
<value>Scope Plot</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>trig_mode</key>
|
||||
<value>wxgui.TRIG_MODE_AUTO</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>type</key>
|
||||
<value>complex</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>v_offset</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>v_scale</key>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>win_size</key>
|
||||
<value></value>
|
||||
</param>
|
||||
<param>
|
||||
<key>xy_mode</key>
|
||||
<value>False</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>y_axis_label</key>
|
||||
<value>Counts</value>
|
||||
</param>
|
||||
</block>
|
||||
<connection>
|
||||
<source_block_id>blocks_file_source_0</source_block_id>
|
||||
<sink_block_id>blocks_multiply_const_vxx_0</sink_block_id>
|
||||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
<connection>
|
||||
<source_block_id>blocks_multiply_const_vxx_0</source_block_id>
|
||||
<sink_block_id>blocks_throttle_0</sink_block_id>
|
||||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
<connection>
|
||||
<source_block_id>blocks_throttle_0</source_block_id>
|
||||
<sink_block_id>limesdr_sink_0</sink_block_id>
|
||||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
<connection>
|
||||
<source_block_id>blocks_throttle_0</source_block_id>
|
||||
<sink_block_id>wxgui_fftsink2_0_0</sink_block_id>
|
||||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
<connection>
|
||||
<source_block_id>blocks_throttle_0</source_block_id>
|
||||
<sink_block_id>wxgui_scopesink2_0_0</sink_block_id>
|
||||
<source_key>0</source_key>
|
||||
<sink_key>0</sink_key>
|
||||
</connection>
|
||||
</flow_graph>
|
@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
##################################################
|
||||
# GNU Radio Python Flow Graph
|
||||
# Title: IQ Transmitter
|
||||
# Generated: Sat Jan 18 21:31:42 2020
|
||||
##################################################
|
||||
|
||||
|
||||
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 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 gnuradio.wxgui import scopesink2
|
||||
from grc_gnuradio import wxgui as grc_wxgui
|
||||
from optparse import OptionParser
|
||||
import limesdr
|
||||
import wx
|
||||
|
||||
|
||||
class iq_transmitter(grc_wxgui.top_block_gui):
|
||||
|
||||
def __init__(self):
|
||||
grc_wxgui.top_block_gui.__init__(self, title="IQ Transmitter")
|
||||
_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
|
||||
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
|
||||
|
||||
##################################################
|
||||
# Variables
|
||||
##################################################
|
||||
self.samp_rate = samp_rate = 2e6
|
||||
|
||||
##################################################
|
||||
# Blocks
|
||||
##################################################
|
||||
self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
|
||||
self.GetWin(),
|
||||
title='Scope Plot',
|
||||
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.Add(self.wxgui_scopesink2_0_0.win)
|
||||
self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
|
||||
self.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=False,
|
||||
avg_alpha=None,
|
||||
title='FFT Plot',
|
||||
peak_hold=False,
|
||||
)
|
||||
self.Add(self.wxgui_fftsink2_0_0.win)
|
||||
self.limesdr_sink_0 = limesdr.sink('', 0, '', '')
|
||||
self.limesdr_sink_0.set_sample_rate(samp_rate)
|
||||
self.limesdr_sink_0.set_center_freq(433.92e6, 0)
|
||||
self.limesdr_sink_0.set_bandwidth(5e6,0)
|
||||
self.limesdr_sink_0.set_gain(60,0)
|
||||
self.limesdr_sink_0.set_antenna(255,0)
|
||||
|
||||
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
|
||||
self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, ))
|
||||
self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/user/Dev/Git Repos/ism-band-trollkit-spoofer/output.complex', True)
|
||||
|
||||
##################################################
|
||||
# Connections
|
||||
##################################################
|
||||
self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
|
||||
self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0))
|
||||
self.connect((self.blocks_throttle_0, 0), (self.limesdr_sink_0, 0))
|
||||
self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0))
|
||||
self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0_0, 0))
|
||||
|
||||
def get_samp_rate(self):
|
||||
return self.samp_rate
|
||||
|
||||
def set_samp_rate(self, samp_rate):
|
||||
self.samp_rate = samp_rate
|
||||
self.wxgui_scopesink2_0_0.set_sample_rate(self.samp_rate)
|
||||
self.wxgui_fftsink2_0_0.set_sample_rate(self.samp_rate)
|
||||
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
|
||||
|
||||
|
||||
def main(top_block_cls=iq_transmitter, options=None):
|
||||
|
||||
tb = top_block_cls()
|
||||
tb.Start(True)
|
||||
tb.Wait()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,4 +1,49 @@
|
||||
import time
|
||||
import numpy as np
|
||||
import SoapySDR
|
||||
from SoapySDR import * #SOAPY_SDR_* constants
|
||||
|
||||
# Protocol part
|
||||
import protocols.Nexus
|
||||
|
||||
nexus = protocols.Nexus.Nexus_TempHumidity()
|
||||
print(nexus.generate(244, 1, 55, 100))
|
||||
data = nexus.generateData(244, 1, 0, 100)
|
||||
print([int(x) for x in data])
|
||||
samples = nexus.generateSamples(244, 1, 0, 100)
|
||||
f = open("test.cu8", "w")
|
||||
f.write(bytearray(samples))
|
||||
f.close()
|
||||
|
||||
## Transmit Part
|
||||
SDR_ARGS = {'driver': 'lime'}
|
||||
|
||||
sdr = SoapySDR.Device(SDR_ARGS)
|
||||
|
||||
sdr.setSampleRate(SOAPY_SDR_TX, 0, 2e6)
|
||||
sdr.setAntenna(SOAPY_SDR_TX, 0, 'Auto')
|
||||
sdr.setFrequency(SOAPY_SDR_TX, 0, 433.92e6)
|
||||
#sdr.setGain(SOAPY_SDR_TX, 0, 10)
|
||||
print(sdr.listAntennas(SOAPY_SDR_TX, 0))
|
||||
print("Actual Tx Rate %f Msps"%(sdr.getSampleRate(SOAPY_SDR_TX, 0) / 1e6))
|
||||
|
||||
txStream = sdr.setupStream(SOAPY_SDR_TX, SOAPY_SDR_CF32 , [0])
|
||||
sdr.activateStream(txStream)
|
||||
|
||||
t0 = sdr.getHardwareTime()
|
||||
tLate = t0 + int(1e8)
|
||||
stream_mtu = sdr.getStreamMTU(txStream)
|
||||
buff0 = np.ones(1024, np.complex64)
|
||||
print(buff0)
|
||||
buff1 = np.zeros(stream_mtu, np.complex64)
|
||||
flags = SOAPY_SDR_HAS_TIME | SOAPY_SDR_END_BURST
|
||||
time.sleep(1.0) #make sure the writeStream is late
|
||||
sdr.writeStream(txStream,
|
||||
[buff0, buff1], 1024,
|
||||
flags=flags,
|
||||
timeNs=tLate,
|
||||
timeoutUs=int(1e6))
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
sdr.deactivateStream(txStream)
|
||||
sdr.closeStream(txStream)
|
@ -0,0 +1,28 @@
|
||||
import numpy as np
|
||||
|
||||
def generateAMSine(fs, toneFreq, numSamples, amplitude):
|
||||
step = (float(toneFreq) / float(fs)) * 2.0 * np.pi
|
||||
phaseArray = np.array(range(0,numSamples)) * step
|
||||
#e^(j*theta) = cos(theta) + j * sin(theta)
|
||||
wave = np.exp(1.0j * phaseArray) * amplitude
|
||||
|
||||
return wave
|
||||
class OOKModulator:
|
||||
def __init__(self, baseband_samplerate, am_frequency):
|
||||
self.baseband_samplerate = baseband_samplerate
|
||||
self.am_frequency = am_frequency
|
||||
self.samples = generateAMSine(self.baseband_samplerate, 0, 4000, 0)
|
||||
def addPadding(self, uSDuration):
|
||||
sampleCount = int((uSDuration / 1000000.0) * self.baseband_samplerate)
|
||||
self.samples = np.append(self.samples, generateAMSine(self.baseband_samplerate, 0, sampleCount, 0))
|
||||
def addModulation(self, uSDuration):
|
||||
sampleCount = int((uSDuration / 1000000.0) * self.baseband_samplerate)
|
||||
self.samples = np.append(self.samples, generateAMSine(self.baseband_samplerate, self.am_frequency, sampleCount, 1))
|
||||
def getSamples(self, numpyType):
|
||||
self.addPadding(4000)
|
||||
return self.samples.astype(numpyType)
|
||||
def getSamplesAndReset(self, numpyType):
|
||||
self.addPadding(4000)
|
||||
returnSamples = self.samples.astype(numpyType)
|
||||
self.samples = generateAMSine(self.baseband_samplerate, 0, 4000, 0)
|
||||
return returnSamples
|
Binary file not shown.
@ -0,0 +1,48 @@
|
||||
from modulators.OOKModulator import OOKModulator
|
||||
import numpy as np
|
||||
"""
|
||||
Intertek Remote Sockets
|
||||
"""
|
||||
class Intertek_Clone_RemoteSocket:
|
||||
def __init__(self, baseband_samplerate=2e6):
|
||||
self.modulator = OOKModulator(baseband_samplerate=baseband_samplerate, am_frequency=22.471e3)
|
||||
def test(self):
|
||||
print("Intertek Clone Remote Sockets (433MHz)")
|
||||
def generateSamples(self, systemCode=7, deviceCode=1, state=True, numpyType=np.complex64):
|
||||
for i in range(6):
|
||||
# Systemcode
|
||||
SC1 = systemCode & 0x1
|
||||
SC2 = (systemCode >> 1) & 0x1
|
||||
SC3 = (systemCode >> 2) & 0x1
|
||||
SC4 = (systemCode >> 3) & 0x1
|
||||
SC5 = (systemCode >> 4) & 0x1
|
||||
|
||||
SC1 = 1
|
||||
SC2 = 1
|
||||
SC3 = 1
|
||||
SC4 = 0
|
||||
SC5 = 0
|
||||
|
||||
# Devicecode
|
||||
GC1 = 0# if deviceCode == 3 else 0
|
||||
GC2 = 0#0 if deviceCode == 0 else 1
|
||||
GC3 = 0# if deviceCode == 1 else 0
|
||||
GC4 = 1# if deviceCode == 3 else 1
|
||||
# Status
|
||||
STATE = int(state)
|
||||
bits = [
|
||||
1,SC1,1,SC2,1,SC3,1,SC4,1,SC5,
|
||||
1,GC1,1,GC2,1,GC3,1,GC4,
|
||||
1,0,1, STATE,1,1 - STATE,1
|
||||
]
|
||||
print(bits)
|
||||
for j in bits:
|
||||
if int(j) == 1:
|
||||
self.modulator.addModulation(320)
|
||||
self.modulator.addPadding(1060)
|
||||
else:
|
||||
self.modulator.addModulation(1060)
|
||||
self.modulator.addPadding(320)
|
||||
self.modulator.addPadding(10660 -1060) # Packet Sync
|
||||
|
||||
return self.modulator.getSamplesAndReset(numpyType)
|
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import math
|
||||
import signal
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
|
||||
import protocols.Nexus
|
||||
|
||||
nexus = protocols.Nexus.Nexus_TempHumidity()
|
||||
data2 = nexus.generateData(244, 1, 0, 100)
|
||||
|
||||
from modulators.OOKModulator import OOKModulator
|
||||
|
||||
A = 1
|
||||
|
||||
ookTest = OOKModulator(baseband_samplerate=2e6, am_frequency=22.471e3)
|
||||
for i in range(6):
|
||||
# 7x0 Preamble + Code
|
||||
# 1 = 10 10 00 10
|
||||
# 2 = 10 10 10 00
|
||||
# 3 = 10 00 10 10
|
||||
# 4 = 00 10 10 10
|
||||
# Systemcode
|
||||
SC1 = 1
|
||||
SC2 = 1
|
||||
SC3 = 1
|
||||
SC4 = 0
|
||||
SC5 = 0
|
||||
|
||||
GC1 = 1
|
||||
GC2 = 0
|
||||
GC3 = 1
|
||||
GC4 = 1
|
||||
|
||||
STATE = 1
|
||||
bits = [ 1,SC1,1,SC2,1,SC3,1,SC4,1,SC5,1,GC1,1,GC2,1,GC3,1,GC4,1,0,1, STATE,1,1 - STATE,1 ]
|
||||
for j in bits:
|
||||
if int(j) == 0:
|
||||
ookTest.addModulation(1060)
|
||||
ookTest.addPadding(320)
|
||||
else:
|
||||
ookTest.addModulation(320)
|
||||
ookTest.addPadding(1060)
|
||||
ookTest.addPadding(10660 -1060) # Packet Sync
|
||||
|
||||
output = ookTest.getSamples(np.complex64)
|
||||
|
||||
with open('output.complex', 'wb') as f:
|
||||
output.tofile(f)
|
@ -0,0 +1,6 @@
|
||||
from protocols.Intertek_RemoteSocket import Intertek_RemoteSocket
|
||||
intertek = Intertek_RemoteSocket(2e6)
|
||||
output = intertek.generateSamples(7, 3, True)
|
||||
|
||||
with open('output.complex', 'wb') as f:
|
||||
output.tofile(f)
|
@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import math
|
||||
import signal
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
|
||||
import protocols.Nexus
|
||||
|
||||
nexus = protocols.Nexus.Nexus_TempHumidity()
|
||||
data2 = nexus.generateData(244, 1, 0, 100)
|
||||
print(data2)
|
||||
print(len(data2))
|
||||
from modulators.OOKModulator import OOKModulator
|
||||
|
||||
A = 1
|
||||
import struct
|
||||
def binary(num):
|
||||
# Struct can provide us with the float packed into bytes. The '!' ensures that
|
||||
# it's in network byte order (big-endian) and the 'f' says that it should be
|
||||
# packed as a float. Alternatively, for double-precision, you could use 'd'.
|
||||
packed = struct.pack('!f', num)
|
||||
print 'Packed: %s' % repr(packed)
|
||||
|
||||
# For each character in the returned string, we'll turn it into its corresponding
|
||||
# integer code point
|
||||
#
|
||||
# [62, 163, 215, 10] = [ord(c) for c in '>\xa3\xd7\n']
|
||||
integers = [ord(c) for c in packed]
|
||||
print 'Integers: %s' % integers
|
||||
|
||||
# For each integer, we'll convert it to its binary representation.
|
||||
binaries = [bin(i) for i in integers]
|
||||
print 'Binaries: %s' % binaries
|
||||
|
||||
# Now strip off the '0b' from each of these
|
||||
stripped_binaries = [s.replace('0b', '') for s in binaries]
|
||||
print 'Stripped: %s' % stripped_binaries
|
||||
|
||||
# Pad each byte's binary representation's with 0's to make sure it has all 8 bits:
|
||||
#
|
||||
# ['00111110', '10100011', '11010111', '00001010']
|
||||
padded = [s.rjust(8, '0') for s in stripped_binaries]
|
||||
print 'Padded: %s' % padded
|
||||
|
||||
# At this point, we have each of the bytes for the network byte ordered float
|
||||
# in an array as binary strings. Now we just concatenate them to get the total
|
||||
# representation of the float:
|
||||
return ''.join(padded)
|
||||
print(binary(25.1))
|
||||
|
||||
|
||||
ookTest = OOKModulator(baseband_samplerate=2e6, am_frequency=22.471e3)
|
||||
for i in range(4):
|
||||
#bits = [ 0,1,0,0,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,0,0,0,0,1,1,1,0,1,1,0,1,0,1,1,1 ]
|
||||
|
||||
bitsStart = [ #statische 22Bit
|
||||
0,1,0,0,
|
||||
1,0,0,0,
|
||||
1,1,0,0,
|
||||
0,0,1,1,
|
||||
0,0,0,1,
|
||||
0,0,
|
||||
]
|
||||
|
||||
bits_23_7 = [
|
||||
0,0,
|
||||
1,1,1,1,
|
||||
1,1,0,1,
|
||||
0,1,1,1
|
||||
]
|
||||
bits_23_4 = [
|
||||
0,0,
|
||||
1,1,1,1,
|
||||
1,0,1,0,
|
||||
0,1,0,0
|
||||
]
|
||||
bits_25_1 = [
|
||||
0,0,
|
||||
1,1,1,1,
|
||||
1,0,1,1,
|
||||
0,1,1,0
|
||||
]
|
||||
bits_31_6 = [
|
||||
0,1,
|
||||
0,0,1,1,
|
||||
1,1,0,0,
|
||||
1,1,0,0
|
||||
]
|
||||
bits_34_1 = [
|
||||
0,1,
|
||||
0,1,0,1,
|
||||
0,1,0,1,
|
||||
0,1,1,1,
|
||||
]
|
||||
bits_43_4 = [
|
||||
0,1,
|
||||
1,0,1,1,
|
||||
0,0,1,0,
|
||||
1,0,1,0
|
||||
]
|
||||
bits_13_8 = [
|
||||
0,0,
|
||||
1,0,0,0,
|
||||
1,0,1,0,
|
||||
1,1,1,0
|
||||
]
|
||||
bits_11_3 = [
|
||||
0,0,
|
||||
0,1,1,1,
|
||||
0,0,0,1,
|
||||
0,1,0,0
|
||||
]
|
||||
bits_8_8 = [
|
||||
0,0,
|
||||
0,1,0,1,
|
||||
1,0,0,0,
|
||||
1,0,0,1
|
||||
]
|
||||
bits = bitsStart + [
|
||||
0,0,
|
||||
1,0,1,0,
|
||||
1,0,1,0,
|
||||
1,1,1,0
|
||||
]
|
||||
#bits = data2
|
||||
print(bits)
|
||||
print(len(bits))
|
||||
for j in bits:
|
||||
ookTest.addModulation(510)
|
||||
ookTest.addPadding(1010 * (1 + int(j)))
|
||||
ookTest.addModulation(510)
|
||||
ookTest.addPadding(4040) # Sync
|
||||
|
||||
output = ookTest.getSamples(np.complex64)
|
||||
|
||||
with open('output.complex', 'wb') as f:
|
||||
output.tofile(f)
|
Loading…
Reference in New Issue