diff --git a/.gitignore b/.gitignore index 7e99e36..040c2bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -*.pyc \ No newline at end of file +*.pyc +*.complex +*.iq \ No newline at end of file diff --git a/main.py b/main.py index 5e39dde..57f6670 100644 --- a/main.py +++ b/main.py @@ -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'} diff --git a/output.complex b/output.complex index 00693e7..8f9c1c7 100644 Binary files a/output.complex and b/output.complex differ diff --git a/protocols/Nexus.py b/protocols/Nexus.py index 78a00b9..4de3e70 100644 --- a/protocols/Nexus.py +++ b/protocols/Nexus.py @@ -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,