#!/home/dominic/python/aprs/bin/python3 """ sending aprs status packets for my weather station and the -10 Packet Station Author: Dominic Reich (OE7DRT) Lastmod: 2026-02-15T11:52:22+0000 """ import aprslib import datetime intervals = ( ('weeks', 604800), # 60 * 60 * 24 * 7 ('days', 86400), # 60 * 60 * 24 ('hours', 3600), # 60 * 60 ('minutes', 60), ('seconds', 1), ) def get_uptime(granularity=2): with open('/proc/uptime', 'r') as u: uptime_seconds = int(float(u.readline().split()[0])) return(display_time(uptime_seconds, granularity)) def display_time(seconds, granularity=2): result = [] for name, count in intervals: value = seconds // count if value: seconds -= value * count if value == 1: name = name.rstrip('s') result.append("{} {}".format(value, name)) return ', '.join(result[:granularity]) def test(): """test function""" print('Uptime: ' + get_uptime()) def main(): """main func""" timestamp = datetime.datetime.now(tz=datetime.timezone.utc).strftime("%d%H%M") # # Login as Weatherstation OE7DRT-13 # AIS = aprslib.IS("OE7DRT-13", passwd="*****", port=14580) AIS.connect() # AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Running for " + get_uptime(2) + " on https://wx.oe7drt.com - happy new year!\r\n") AIS.sendall("OE7DRT-13>APZ,TCPIP*:>" + timestamp + "zhttps://wx.oe7drt.com") # # Log in as iGate OE7DRT-10 # # Log in multiple times in order to get qAC # otherwise station x would provide infos for station y and that ends up in qAS # which is deprecated: https://www.aprs-is.net/q.aspx AIS = aprslib.IS("OE7DRT-10", passwd="*****", port=14580) AIS.connect() # AIS.sendall("OE7DRT-10>APZ,TCPIP:>" + timestamp + "zhttps://oe7drt.com/equipment/radio-stuff/packet-radio-node/") AIS.sendall("OE7DRT-10>APZ,TCPIP*:>" + timestamp + "zhttps://oe7drt.com/") if __name__ == "__main__": main()