Added serial support

Added support for serial connections and updated config.ini to be more detail
This commit is contained in:
TC² 2025-01-22 07:54:40 -05:00
parent 917797789c
commit 751c92cd7e
3 changed files with 75 additions and 10 deletions

View File

@ -103,7 +103,11 @@ def send_bulletin(bulletin_id, bulletin_text):
info=frame_info
)
ki = aprs.TCPKISS(host=config.KISS_HOST, port=config.KISS_PORT)
if config.KISS_INTERFACE == "SERIAL":
ki = aprs.SerialKISS(port=config.SERIAL_PORT, speed=config.SERIAL_BAUDRATE)
else:
ki = aprs.TCPKISS(host=config.KISS_HOST, port=config.KISS_PORT)
ki.start()
ki.write(frame)
print(f"Urgent bulletin transmitted: {bulletin_text}")
@ -114,7 +118,13 @@ def send_bulletin(bulletin_id, bulletin_text):
def start():
ki = aprs.TCPKISS(host=config.KISS_HOST, port=config.KISS_PORT)
if config.KISS_INTERFACE == "SERIAL":
ki = aprs.SerialKISS(port=config.SERIAL_PORT, speed=config.SERIAL_BAUDRATE)
print(f"Starting APRS in SERIAL mode on {config.SERIAL_PORT} at {config.SERIAL_BAUDRATE} baud...")
else:
ki = aprs.TCPKISS(host=config.KISS_HOST, port=config.KISS_PORT)
print("Starting APRS in TCP mode...")
ki.start()
device_data = fetch_device_data()
@ -235,7 +245,12 @@ def send_direct_message(recipient, message):
path=config.APRS_PATH,
info=frame_info
)
ki = aprs.TCPKISS(host=config.KISS_HOST, port=config.KISS_PORT)
if config.KISS_INTERFACE == "SERIAL":
ki = aprs.SerialKISS(port=config.SERIAL_PORT, speed=config.SERIAL_BAUDRATE)
else:
ki = aprs.TCPKISS(host=config.KISS_HOST, port=config.KISS_PORT)
ki.start()
ki.write(frame)
print(f"Direct message sent to {recipient}: {formatted_message}")

View File

@ -15,6 +15,9 @@ KISS_HOST = 127.0.0.1
KISS_PORT = 8001
BULLETIN_EXPIRATION_DAYS = 7
APRS_PATH = WIDE1-1,WIDE2-1
KISS_INTERFACE = TCP
SERIAL_PORT = /dev/rfcomm0
SERIAL_BAUDRATE = 9600
""")
config.read(config_file)
@ -26,3 +29,6 @@ KISS_PORT = config.getint("DEFAULT", "KISS_PORT", fallback=8001)
BULLETIN_EXPIRATION_DAYS = config.getint("DEFAULT", "BULLETIN_EXPIRATION_DAYS", fallback=7)
APRS_PATH = config.get("DEFAULT", "APRS_PATH", fallback="WIDE1-1").split(",")
RAW_PACKET_DISPLAY = config.getboolean("DEFAULT", "RAW_PACKET_DISPLAY", fallback=False)
KISS_INTERFACE = config.get("DEFAULT", "KISS_INTERFACE", fallback="TCP").upper()
SERIAL_PORT = config.get("DEFAULT", "SERIAL_PORT", fallback="/dev/rfcomm0")
SERIAL_BAUDRATE = config.getint("DEFAULT", "SERIAL_BAUDRATE", fallback=9600)

View File

@ -1,7 +1,16 @@
# This is the config file for the TC² APRS-BBS.
# Edit the values below to customize the behavior of the system.
############################################################
# #
# TC² APRS-BBS Configuration File #
# #
# Edit the values below to customize the behavior of the #
# system. Ensure all settings match your environment. #
# #
############################################################
[DEFAULT]
# ================================[ CALLSIGNS ]=============================== #
# TACTICAL_CALL: The callsign of the BBS. This is the identifier used to communicate
# with the APRS network. This can be a Tactical Callsign (like BBS) or your ham radio
# license callsign (WITH SSID). If using a tactical callsign, be sure to enter in your ham radio
@ -13,14 +22,49 @@ TACTICAL_CALL = BBS
# If using your ham radio license call in the Tactical Call field, leave this as TC2BBS.
STANDARD_CALL = TC2BBS
# KISS_HOST: The hostname or IP address of the KISS TNC (Terminal Node Controller)
# used for APRS communications. Typically, this is a local device or a remote server.
# ===============================[ CONNECTIONS ]============================== #
##############
# --SERIAL-- #
##############
# KISS_INTERFACE: Defines the type of connection to the KISS TNC (Terminal Node Controller).
# Options:
# - 'SERIAL': Connect via a physical serial port (e.g., USB-to-Serial adapter, Bluetooth serial).
# - 'TCP': Connect over a network using TCP/IP (for software TNCs like Direwolf).
KISS_INTERFACE = SERIAL
# SERIAL_PORT: Specifies the serial port device used for the serial connection.
# Example values:
# - Linux: /dev/ttyUSB0 (for USB serial devices) or /dev/rfcomm0 (for Bluetooth serial)
# - Windows: COM3, COM4 (depending on the connected device)
SERIAL_PORT = /dev/rfcomm0
# SERIAL_BAUDRATE: Sets the baud rate (communication speed) for the serial connection.
# Common baud rates:
# - 9600 (VGC VR-N76, BTECH UV-PRO, Kenwood TH-D75, Kenwood TH-D74)
SERIAL_BAUDRATE = 9600
###############
# --NETWORK-- #
###############
# KISS_HOST: The IP address or hostname of the KISS TNC server.
# Use '127.0.0.1' for localhost if the TNC software (e.g., Direwolf) is running on the same machine.
# For remote TNCs, provide the external IP address.
# This setting is **only used when KISS_INTERFACE is set to 'TCP'**.
KISS_HOST = 127.0.0.1
# KISS_PORT: The port number used to connect to the KISS TNC.
# Ensure the port matches the configuration of your TNC.
# KISS_PORT: The TCP port number used to connect to the KISS TNC server.
# Default port for Direwolf is typically 8001, but this must match the configuration of your TNC.
# This setting is **only used when KISS_INTERFACE is set to 'TCP'**.
KISS_PORT = 8001
# =================================[ GENERAL ]================================ #
# BULLETIN_EXPIRATION_DAYS: The number of days after which bulletins will
# automatically expire and be deleted from the database. Set to 0 to disable expiration.
BULLETIN_EXPIRATION_DAYS = 7
@ -29,4 +73,4 @@ BULLETIN_EXPIRATION_DAYS = 7
APRS_PATH = WIDE1-1,WIDE2-1
# Enable or disable raw packet display (True or False)
RAW_PACKET_DISPLAY = True
RAW_PACKET_DISPLAY = True