admin revised this gist . Go to revision
1 file changed, 3 insertions
mesh_ping.py
@@ -19,5 +19,8 @@ while True: | |||
19 | 19 | iface.sendText(f"ping {fmt_time}", wantAck=True, channelIndex=1) | |
20 | 20 | print("sent", fmt_time) | |
21 | 21 | time.sleep(interval) | |
22 | + | except KeyboardInterrupt: | |
23 | + | print("bye") | |
24 | + | exit(1) | |
22 | 25 | except: | |
23 | 26 | print("AAA!") |
admin revised this gist . Go to revision
1 file changed, 23 insertions
mesh_ping.py(file created)
@@ -0,0 +1,23 @@ | |||
1 | + | import sys | |
2 | + | import time | |
3 | + | ||
4 | + | import meshtastic | |
5 | + | import meshtastic.tcp_interface | |
6 | + | ||
7 | + | interval = 10 | |
8 | + | if len(sys.argv) > 1: | |
9 | + | interval = int(sys.argv[1]) | |
10 | + | ||
11 | + | while True: | |
12 | + | try: | |
13 | + | with meshtastic.tcp_interface.TCPInterface("meshtastic.local") as iface: | |
14 | + | if iface != None: | |
15 | + | print("connected to tcp") | |
16 | + | ||
17 | + | for i in range(10): | |
18 | + | fmt_time = time.strftime("%H:%M:%S", time.localtime()) | |
19 | + | iface.sendText(f"ping {fmt_time}", wantAck=True, channelIndex=1) | |
20 | + | print("sent", fmt_time) | |
21 | + | time.sleep(interval) | |
22 | + | except: | |
23 | + | print("AAA!") |