最後活躍 3 weeks ago

dominic 已修改 2 months ago. 還原成這個修訂版本

1 file changed, 24 insertions, 12 deletions

aprs_sendstatus.py

@@ -1,12 +1,14 @@
1 - #!/usr/bin/env python3
1 + #!/home/dominic/python/aprs/bin/python3
2 2
3 3 """ sending aprs status packets for my weather station
4 + and the -10 Packet Station
4 5
5 6 Author: Dominic Reich (OE7DRT) <quick.hat4396@qtztsjosmprqmgtunjyf.com>
7 + Lastmod: 2026-02-15T11:52:22+0000
6 8 """
7 9
8 10 import aprslib
9 -
11 + import datetime
10 12
11 13 intervals = (
12 14 ('weeks', 604800), # 60 * 60 * 24 * 7
@@ -44,17 +46,27 @@ def test():
44 46
45 47 def main():
46 48 """main func"""
47 - AIS = aprslib.IS("OE7DRT-13", passwd="*****", port=14580)
49 + timestamp = datetime.datetime.now(tz=datetime.timezone.utc).strftime("%d%H%M")
48 50
49 - #AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Running for " + get_uptime(2) + " on https://wx.oe7drt.com\r\n")
50 - try:
51 - AIS.connect()
52 - except TimeoutError:
53 - print("Could not send packets - Timeout.")
54 - except:
55 - print("An unexpected Error occured:")
56 -
57 - AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Weatherpage: https://wx.oe7drt.com\r\n")
51 + #
52 + # Login as Weatherstation OE7DRT-13
53 + #
54 + AIS = aprslib.IS("OE7DRT-13", passwd="*****", port=14580)
55 + AIS.connect()
56 +
57 + # AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Running for " + get_uptime(2) + " on https://wx.oe7drt.com - happy new year!\r\n")
58 + AIS.sendall("OE7DRT-13>APZ,TCPIP*:>" + timestamp + "zhttps://wx.oe7drt.com")
59 +
60 + #
61 + # Log in as iGate OE7DRT-10
62 + #
63 + # Log in multiple times in order to get qAC
64 + # otherwise station x would provide infos for station y and that ends up in qAS
65 + # which is deprecated: https://www.aprs-is.net/q.aspx
66 + AIS = aprslib.IS("OE7DRT-10", passwd="*****", port=14580)
67 + AIS.connect()
68 + # AIS.sendall("OE7DRT-10>APZ,TCPIP:>" + timestamp + "zhttps://oe7drt.com/equipment/radio-stuff/packet-radio-node/")
69 + AIS.sendall("OE7DRT-10>APZ,TCPIP*:>" + timestamp + "zhttps://oe7drt.com/")
58 70
59 71 if __name__ == "__main__":
60 72 main()

dominic 已修改 2 years ago. 還原成這個修訂版本

1 file changed, 60 insertions

aprs_sendstatus.py(檔案已創建)

@@ -0,0 +1,60 @@
1 + #!/usr/bin/env python3
2 +
3 + """ sending aprs status packets for my weather station
4 +
5 + Author: Dominic Reich (OE7DRT) <quick.hat4396@qtztsjosmprqmgtunjyf.com>
6 + """
7 +
8 + import aprslib
9 +
10 +
11 + intervals = (
12 + ('weeks', 604800), # 60 * 60 * 24 * 7
13 + ('days', 86400), # 60 * 60 * 24
14 + ('hours', 3600), # 60 * 60
15 + ('minutes', 60),
16 + ('seconds', 1),
17 + )
18 +
19 +
20 + def get_uptime(granularity=2):
21 + with open('/proc/uptime', 'r') as u:
22 + uptime_seconds = int(float(u.readline().split()[0]))
23 +
24 + return(display_time(uptime_seconds, granularity))
25 +
26 +
27 + def display_time(seconds, granularity=2):
28 + result = []
29 +
30 + for name, count in intervals:
31 + value = seconds // count
32 + if value:
33 + seconds -= value * count
34 + if value == 1:
35 + name = name.rstrip('s')
36 + result.append("{} {}".format(value, name))
37 + return ', '.join(result[:granularity])
38 +
39 +
40 + def test():
41 + """test function"""
42 + print('Uptime: ' + get_uptime())
43 +
44 +
45 + def main():
46 + """main func"""
47 + AIS = aprslib.IS("OE7DRT-13", passwd="*****", port=14580)
48 +
49 + #AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Running for " + get_uptime(2) + " on https://wx.oe7drt.com\r\n")
50 + try:
51 + AIS.connect()
52 + except TimeoutError:
53 + print("Could not send packets - Timeout.")
54 + except:
55 + print("An unexpected Error occured:")
56 +
57 + AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Weatherpage: https://wx.oe7drt.com\r\n")
58 +
59 + if __name__ == "__main__":
60 + main()
上一頁 下一頁