Add JS8Call capability

This commit is contained in:
TC² 2024-07-14 18:52:06 -04:00
parent 048772af0f
commit 6363c8dd91
5 changed files with 339 additions and 31 deletions

View file

@ -2,8 +2,8 @@
"""
TC²-BBS Server for Meshtastic by TheCommsChannel (TC²)
Date: 07/09/2024
Version: 0.1.4
Date: 07/14/2024
Version: 0.1.6
Description:
The system allows for mail message handling, bulletin boards, and a channel
@ -13,15 +13,29 @@ other BBS servers listed in the config.ini file.
"""
import logging
import time
from config_init import initialize_config, get_interface, init_cli_parser, merge_config
from db_operations import initialize_database
from js8call_integration import JS8CallClient
from message_processing import on_receive
from pubsub import pub
import time
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# General logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
# JS8Call logging
js8call_logger = logging.getLogger('js8call')
js8call_logger.setLevel(logging.DEBUG)
js8call_handler = logging.StreamHandler()
js8call_handler.setLevel(logging.DEBUG)
js8call_formatter = logging.Formatter('%(asctime)s - JS8Call - %(levelname)s - %(message)s', '%Y-%m-%d %H:%M:%S')
js8call_handler.setFormatter(js8call_formatter)
js8call_logger.addHandler(js8call_handler)
def display_banner():
banner = """
@ -58,6 +72,13 @@ def main():
pub.subscribe(receive_packet, system_config['mqtt_topic'])
# Initialize and start JS8Call Client if configured
js8call_client = JS8CallClient(interface)
js8call_client.logger = js8call_logger
if js8call_client.db_conn:
js8call_client.connect()
try:
while True:
time.sleep(1)
@ -65,6 +86,8 @@ def main():
except KeyboardInterrupt:
logging.info("Shutting down the server...")
interface.close()
if js8call_client.connected:
js8call_client.close()
if __name__ == "__main__":
main()