-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqttc.py
41 lines (31 loc) · 1.09 KB
/
mqttc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
Powered by Meshtastic™ https://meshtastic.org/
"""
import time
from load_config import ConfigLoader
from tx_message_handler import send_nodeinfo, send_position, send_device_telemetry, send_text_message
from mqtt_handler import get_mqtt_client
from argument_parser import handle_args, get_args
stay_connected = False
def main():
_, args = get_args()
config_file = args.config
config = ConfigLoader.load_config_file(config_file)
client = get_mqtt_client()
if handle_args() == None:
send_nodeinfo(config.node.short_name, config.node.long_name, config.node.hw_model)
time.sleep(3)
# send_position(config.node.lat, config.node.lon, config.node.alt, config.node.precision)
# time.sleep(3)
# send_device_telemetry(battery_level=99, voltage=4.0, chutil=3, airtxutil=1, uptime=420)
# time.sleep(3)
# send_text_message("Happy New Year!")
# time.sleep(3)
if not stay_connected:
client.disconnect()
else:
while True:
time.sleep(1)
if __name__ == "__main__":
main()