arcs

Amateur Radio Chat Server with a modern interface
git clone git://squid-tech.com/arcs.git
Log | Files | Refs | README

commit 335bcfa48f98255e46abc844355408c9e34122c1
parent a38b996ac63ad17b4783bcbcb5d14a8b017abc60
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Wed, 18 Dec 2019 23:32:48 -0500

Add automatic beacon daemon to server

Diffstat:
Marcs.py | 44+++++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/arcs.py b/arcs.py @@ -3,11 +3,13 @@ Amateur Radio Chat Server """ import sys import serial +import threading +import time -# replace with your callsign +# change this to your callsign MYCALL = 'KD2SIX' -### server config +### server config ### # server callsign HOST = 'KD2SIX-1' @@ -22,6 +24,11 @@ SERV_LONG = '07608.61W' # message for position beacon BEACON_MSG = 'Amateur Radio Chat Server - WIP' +# how long to delay between beacon transmissions (in seconds) +BEACON_DELAY = 1800 + +##################### + KISS_FEND = 0xC0 KISS_FESC = 0xDB @@ -29,6 +36,10 @@ KISS_TFEND = 0xDC KISS_TFESC = 0xDD +# whether we are the server or a client +_SERVER = False + + """ Send command and data to the KISS TNC. data should be a byte array. @@ -77,15 +88,13 @@ def decodecall(call): # decode callsign for i in range(0, len(call) - 1): c = int.from_bytes(call[i], "little") >> 1 - if c != ' ': + if chr(c) != ' ': decodedcall += chr(c) # decode SSID ssid = (int.from_bytes(call[-1], "little") >> 1) & 0x0F if ssid != 0: - decodedcall += "-" + str(ssid) + (" " if ssid < 10 else "") - else: - decodedcall += " " + decodedcall += "-" + str(ssid) return decodedcall @@ -159,11 +168,25 @@ def AX25parse(packet): Transmit the server's beacon message, position, and symbol. """ def beacon(port): + print("BEACON") out = "=" + SERV_LAT + SYMBOL[0] + SERV_LONG + SYMBOL[1] + BEACON_MSG AX25send(port, HOST, "APRS", ["WIDE2-2"], out) +""" +Automatically beacon on a set interval. +""" +def beacond(port): + while True: + beacon(port) + time.sleep(BEACON_DELAY) + def main(): + global _SERVER + + if "-server" in sys.argv: + _SERVER = True + # initialize serial port ser = serial.Serial( port=sys.argv[1], @@ -173,9 +196,12 @@ def main(): # initialize the KISS TNC KISSinit(ser) - #beacon(ser) - while True: - print(AX25parse(AX25read(ser))) + if _SERVER: + # start beacon daemon + threading.Thread(target=beacond, args=[ser]).start() + + while True: + print(AX25parse(AX25read(ser))) if __name__ == '__main__': main()