WIP
This commit is contained in:
commit
4ac9d4e6a2
4 changed files with 55 additions and 0 deletions
1
.gitingnore
Normal file
1
.gitingnore
Normal file
|
|
@ -0,0 +1 @@
|
|||
venv/
|
||||
9
config.yaml
Normal file
9
config.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
serial_device_path: "/dev/ttyACM0"
|
||||
radio_settings:
|
||||
radio_freq: 869.618
|
||||
radio_bw: 62.5
|
||||
radio_sf: 8
|
||||
radio_cr: 8
|
||||
repeaters:
|
||||
- public_key: "4a629a62e51f0ec770afc47bb22010df0ac1c47475499b6b5e47b3487a4f71e6" # stay_hydrated_01
|
||||
path: ""
|
||||
38
main.py
Executable file
38
main.py
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import json
|
||||
import yaml
|
||||
import time
|
||||
from meshcore import MeshCore, EventType
|
||||
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
|
||||
|
||||
async def main():
|
||||
with open("config.yaml", "r") as file:
|
||||
config = yaml.safe_load(file)
|
||||
|
||||
meshcore = await MeshCore.create_serial(config["serial_device_path"])
|
||||
await meshcore.commands.set_time(int(time.time()))
|
||||
|
||||
#await meshcore.commands.change_contact_path("4a629a62e51f0ec770afc47bb22010df0ac1c47475499b6b5e47b3487a4f71e6", [])
|
||||
|
||||
#await meshcore.ensure_contacts()
|
||||
#contact = meshcore.get_contact_by_key_prefix("4a629a62e51f0ec770afc47bb22010df0ac1c47475499b6b5e47b3487a4f71e6")
|
||||
#print(contact)
|
||||
for repeater in config["repeaters"]:
|
||||
result = await meshcore.commands.send_telemetry_req(repeater["public_key"])
|
||||
if result.type == EventType.ERROR:
|
||||
pass
|
||||
|
||||
result = await meshcore.wait_for_event(EventType.TELEMETRY_RESPONSE, timeout=10.0)
|
||||
if result is None:
|
||||
print(json.dumps({"error" : "Timeout waiting for telemetry"}))
|
||||
else:
|
||||
print(json.dumps(result.payload, indent=4))
|
||||
|
||||
registry = CollectorRegistry()
|
||||
test = Gauge("voltage", "Battery Voltage", registry=registry)
|
||||
test.set(result.payload["lpp"][0]["value"])
|
||||
push_to_gateway("localhost:9091", job="batchA", registry=registry)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
7
requirements.txt
Normal file
7
requirements.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
bleak==1.1.1
|
||||
dbus-fast==2.44.5
|
||||
meshcore==2.1.12
|
||||
prometheus_client==0.23.1
|
||||
pycayennelpp==2.4.0
|
||||
pyserial==3.5
|
||||
pyserial-asyncio==0.6
|
||||
Loading…
Add table
Add a link
Reference in a new issue