-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAPRS-Python.py
More file actions
144 lines (120 loc) · 4.16 KB
/
APRS-Python.py
File metadata and controls
144 lines (120 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import sys, time, json
from socket import *
import datetime
# _____ _____ _____ _____ _ _
# /\ | __ \| __ \ / ____| | __ \ | | | |
# / \ | |__) | |__) | (___ | |__) | _| |_| |__ ___ _ __
# / /\ \ | ___/| _ / \___ \ | ___/ | | | __| '_ \ / _ \| '_ \
# / ____ \| | | | \ \ ____) | | | | |_| | |_| | | | (_) | | | |
# /_/ \_\_| |_| \_\_____/ |_| \__, |\__|_| |_|\___/|_| |_|
# __/ |
# https://github.com/EvanVS/APRS-Python |___/ Version: 0.13
# ---------------- INFORMATION ----------------
#
# APRS Python - V0.13
# Evan Vander Stoep - March, 2021
#
# This script is open source. Please leave author credit.
#
# ---------------- INFORMATION ----------------
# --------------- CONFIGURATION ---------------
ServerHost = 'firenet.us'
ServerPort = 10154
Callsign = 'N0CALL'
SSID = '-5'
Password = '12345' # Generate here: https://apps.magicbug.co.uk/passcode/
Latitude = '0000.00N'
Longitude = '00000.00W'
Comment = 'https://github.com/EvanVS/APRS-Python'
Status = 'APRS Python'
Status_Packet = False # False = Do not send status message packet
Primary_Symbol_Key = '/'
Secondary_Symbol_Key = '_' # Default is the House symbol. More info here: https://blog.thelifeofkenneth.com/2017/01/aprs-symbol-look-up-table.html
Delay = 600 # 10 Mins (Value is in seconds)
# --------------- CONFIGURATION ---------------
def check_config():
global ServerHost
global ServerPort
global Callsign
global SSID
global Password
global Latitude
global Longitude
global Comment
global Status
global Delay
if ServerHost == '':
print("CONFIG ERROR: No server host defined! Check configuration and try again!")
exit()
if ServerPort == None:
print("CONFIG ERROR: No server port defined! Check configuration and try again!")
exit()
if Callsign == '' or Callsign == 'N0CALL':
print("CONFIG ERROR: No Callsign defined! Check configuration and try again!")
exit()
elif "-" in Callsign:
print("CONFIG ERROR: SSID Specified in the Callsign field! Please Specify the SSID in the SSID field! Check configuration and try again!")
exit()
if Password == '' or Password == '12345':
print("CONFIG ERROR: No password defined! Check configuration and try again!")
exit()
if Latitude == '':
print("CONFIG ERROR: No Latitude defined! Check configuration and try again!")
exit()
if Longitude == '':
print("CONFIG ERROR: No Longitude defined! Check configuration and try again!")
exit()
if len(Comment) > 43:
print(f"CONFIG ERROR: Comment is over 43 characters ({len(Comment)}/43)! Make it shorter and try again!")
if len(Status) > 43:
print(f"CONFIG ERROR: Status is over 43 characters ({len(Status)}/43)! Make it shorter and try again!")
if Delay == None:
Delay = 600 # Defaults to 10 Mins
else:
print("CONFIGURATION OK")
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timeformat = 'Next Packet: {:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
t -= 1
def send_packet():
global ServerHost
global ServerPort
global Callsign
global SSID
global Password
global Latitude
global Longitude
global Comment
global Status
global Delay
# create socket & connect to server
sSock = socket(AF_INET, SOCK_STREAM)
sSock.connect((ServerHost, ServerPort))
# logon
RAWpacket = f'user {Callsign} pass {Password} vers "KJ7BRE APRS Python" \n'
sSock.send(bytes(RAWpacket, 'utf-8'))
# send BEACON packet
BEACONpacket = f'{Callsign}{SSID}>APE,TCPIP*:={Latitude}{Primary_Symbol_Key}{Longitude}{Secondary_Symbol_Key}{Comment}\n'
sSock.send(bytes(BEACONpacket, 'utf-8'))
print(BEACONpacket)
print("[BEACON packet sent]")
if Status_Packet == True and Status != '':
countdown(5)
# send STATUS packet
STATUSpacket = f'{Callsign}{SSID}>APE,TCPIP*:>{Status}\n'
sSock.send(bytes(STATUSpacket, 'utf-8'))
print(STATUSpacket)
print("[STATUS packet sent]")
else:
pass
# close socket -- must be closed to avoid buffer overflow
sSock.shutdown(0)
sSock.close()
print("\n----------")
check_config()
while True:
send_packet()
countdown(Delay)