diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cc67606 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..48bcac2 --- /dev/null +++ b/main.py @@ -0,0 +1,4 @@ +import protocols.Nexus + +nexus = protocols.Nexus.Nexus_TempHumidity() +print(nexus.generate(244, 1, 55, 100)) diff --git a/protocols/Nexus.py b/protocols/Nexus.py new file mode 100644 index 0000000..85ee19e --- /dev/null +++ b/protocols/Nexus.py @@ -0,0 +1,19 @@ + +class Nexus_TempHumidity: + def __init__(self): + self.test() + def test(self): + print("Nexus Temperature & Humidity Sensor") + def generate(self, id=244, channel=1, temp=30, humidity=100): + packet = [ + (id >> 4) & 0x0f, + id & 0x0f, + 7 + channel, + (temp >> 8) & 0x0f, + (temp >> 4) & 0x0f, + temp & 0x0f, + 0x0f, + (humidity >> 4) & 0x0f, + humidity & 0x0f + ] + return packet diff --git a/protocols/__init__.py b/protocols/__init__.py new file mode 100644 index 0000000..e69de29