2024-06-25 08:50:52 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
"""
|
|
|
|
TC²-BBS Server for Meshtastic by TheCommsChannel (TC²)
|
|
|
|
Date: 06/25/2024
|
|
|
|
Version: 0.1.0
|
|
|
|
|
|
|
|
Description:
|
|
|
|
The system allows for mail message handling, bulletin boards, and a channel
|
|
|
|
directory. It uses a configuration file for setup details and an SQLite3
|
|
|
|
database for data storage. Mail messages and bulletins are synced with
|
|
|
|
other BBS servers listed in the config.ini file.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2024-06-28 16:35:45 -04:00
|
|
|
from config_init import initialize_config, get_interface, init_cli_parser, merge_config
|
2024-06-25 08:50:52 -04:00
|
|
|
from db_operations import initialize_database
|
|
|
|
from message_processing import on_receive
|
|
|
|
from pubsub import pub
|
|
|
|
|
|
|
|
# Configure logging
|
|
|
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
|
|
|
|
|
def display_banner():
|
|
|
|
banner = """
|
|
|
|
████████╗ ██████╗██████╗ ██████╗ ██████╗ ███████╗
|
|
|
|
╚══██╔══╝██╔════╝╚════██╗ ██╔══██╗██╔══██╗██╔════╝
|
|
|
|
██║ ██║ █████╔╝█████╗██████╔╝██████╔╝███████╗
|
|
|
|
██║ ██║ ██╔═══╝ ╚════╝██╔══██╗██╔══██╗╚════██║
|
|
|
|
██║ ╚██████╗███████╗ ██████╔╝██████╔╝███████║
|
|
|
|
╚═╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝
|
|
|
|
Meshtastic Version
|
|
|
|
"""
|
|
|
|
print(banner)
|
|
|
|
|
2024-06-28 16:35:45 -04:00
|
|
|
|
|
|
|
|
2024-06-25 08:50:52 -04:00
|
|
|
def main():
|
|
|
|
display_banner()
|
2024-06-28 16:35:45 -04:00
|
|
|
# config, interface_type, hostname, port, bbs_nodes = initialize_config()
|
|
|
|
args = init_cli_parser()
|
|
|
|
config_file = None
|
|
|
|
if args.config is not None:
|
|
|
|
config_file = args.config
|
|
|
|
system_config = initialize_config(config_file)
|
|
|
|
|
|
|
|
merge_config(system_config, args)
|
|
|
|
|
|
|
|
print(f"{system_config=}")
|
|
|
|
|
|
|
|
interface = get_interface(system_config)
|
|
|
|
interface.bbs_nodes = system_config['bbs_nodes']
|
2024-06-25 08:50:52 -04:00
|
|
|
|
2024-06-28 16:35:45 -04:00
|
|
|
logging.info(f"TC²-BBS is running on {system_config['interface_type']} interface...")
|
2024-06-25 08:50:52 -04:00
|
|
|
|
|
|
|
initialize_database()
|
|
|
|
|
|
|
|
def receive_packet(packet):
|
2024-06-28 16:35:45 -04:00
|
|
|
on_receive(packet, interface, system_config)
|
2024-06-25 08:50:52 -04:00
|
|
|
|
2024-06-28 16:35:45 -04:00
|
|
|
pub.subscribe(receive_packet, system_config['mqtt_topic'])
|
2024-06-25 08:50:52 -04:00
|
|
|
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
pass
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
logging.info("Shutting down the server...")
|
|
|
|
interface.close()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|