-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeshtasticInterface.py
More file actions
62 lines (55 loc) · 1.75 KB
/
meshtasticInterface.py
File metadata and controls
62 lines (55 loc) · 1.75 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
""" text """
import meshtastic
import meshtastic.serial_interface
def serialPort():
""" text """
port = input('Enter serial/COM port for LoRa device: ').upper()
interface = meshtastic.serial_interface.SerialInterface(port)
return(interface)
def sendMessage(interface):
""" text """
message = input('message: ')
interface.sendText(message)
def localConfig(interface):
ourNode = interface.getNode('^local')
print(ourNode.localConfig)
def main():
port = serialPort()
while True:
command = input('''Choose one of the following options:
1 - Send a message to send to the mesh
2 - Change COM port
3 - Change group
4 - Print local config
5 - exit
Enter selection number: ''')
if command == '1':
message = sendMessage(port)
elif command == '2':
port = serialPort()
elif command == '3':
pass
elif command == '4':
print(localConfig(port))
elif command == '5':
exit()
try:
command = int(command)
except ValueError as reason:
print("That is not a valid selection.", reason)
execute = {1: sendMessage,
2: serialPort,
3: '',
4: localConfig,
5: exit}
if command in execute:
try:
option = execute[command]
run = option()
print(run)
except KeyError as reason:
print(reason)
else:
print("That is not a valid selection.")
if __name__ == "__main__":
main()