master
cheetah 5 years ago
parent cfb5021a1b
commit 1388bf9ef2

4
.gitignore vendored

@ -1 +1,3 @@
*.pyc
*.pyc
*.complex
*.iq

@ -8,11 +8,11 @@ import protocols.Nexus
nexus = protocols.Nexus.Nexus_TempHumidity()
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()
samples = nexus.generateSamples(baseband_samplerate=2e6, id=244, channel=1, temp=30, humidity=100)
with open('nexus.iq', 'wb') as f:
samples.tofile(f)
## Transmit Part
SDR_ARGS = {'driver': 'lime'}

Binary file not shown.

@ -1,9 +1,11 @@
from modulators.OOKModulator import OOKModulator
import numpy as np
"""
Nexus Temperature & Humidity Protocol
"""
class Nexus_TempHumidity:
def __init__(self):
self.test()
def test(self):
print("Nexus Temperature & Humidity Sensor")
pass
def generateData(self, id=244, channel=1, temp=30, humidity=100):
nibbles = self.generatePacket(id, channel, temp, humidity)
data = []
@ -16,6 +18,16 @@ class Nexus_TempHumidity:
data.append(0)
mask >>= 1
return data
def generateSamples(self, baseband_samplerate=2e6, id=244, channel=1, temp=30, humidity=100, numpyType=np.complex64):
modulator = OOKModulator(baseband_samplerate=baseband_samplerate, am_frequency=22.471e3)
bits = self.generateData(id, channel, temp, humidity)
for j in bits:
modulator.addModulation(500)
modulator.addPadding(1000 * (1 + int(j)))
modulator.addModulation(500)
modulator.addPadding(4000)
return modulator.getSamplesAndReset(numpyType)
def generatePacket(self, id=244, channel=1, temp=30, humidity=100):
packet = [
(id >> 4) & 0x0f,

Loading…
Cancel
Save