|
|
|
@ -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,
|
|
|
|
|