-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmbbs.py
55 lines (45 loc) · 1.69 KB
/
mbbs.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
42
43
44
45
46
47
48
49
50
51
52
53
54
import meshtastic
import meshtastic.tcp_interface
import time
from pubsub import pub
from utils.log import logger as logger
from utils.config import config
from interfaces.comm_interface_tcp import CommInterfaceTCP
from interfaces.comm_interface_meshtastic_tcp import CommInterfaceMeshtasticTCP
from interfaces.comm_interface_meshtastic_serial import CommInterfaceMeshtasticSerial
'''
This is the main application. Edit the config file at config.toml to configure the program, then launch this.
'''
if __name__ == '__main__':
interface = None
serial_interface = None
# Meshtastic radio TCP interface
try:
radio_ip = config["interface_mesh_tcp"]["radio_ip"]
radio_channel = config["main"]["radio_channel_index"]
except:
logger.error("Unable to read radio's TCP config options from config.toml. Continuing without it.")
else:
interface = CommInterfaceMeshtasticTCP(radio_ip, radio_channel)
# Meshtastic radio serial interface
try:
radio_device = config["interface_mesh_serial"]["serial_device"]
radio_channel = config["main"]["radio_channel_index"]
except:
logger.error("Unable to read serial device path from config.toml. Continuing without it.")
else:
serial_interface = CommInterfaceMeshtasticSerial(radio_device, radio_channel)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
logger.info("Shutting down the server...")
if interface:
interface.close()
if serial_interface:
serial_interface.close()
try:
if js8call_client.connected:
js8call_client.close()
except:
pass