This commit is contained in:
KF7EEL
2021-03-04 15:26:31 -08:00
parent e6c61dd72a
commit 3946a6735d
6 changed files with 39 additions and 38 deletions
+10 -12
View File
@@ -24,30 +24,27 @@ import time
import argparse
def mailbox_write(call, dmr_id, time, message, recipient):
global mailbox_file
mail_file = ast.literal_eval(os.popen('cat ' + mailbox_file).read())
mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient})
with open("../../gps_data_user_mailbox.txt", 'w') as mailbox_file:
with open(mailbox_file, 'w') as mailbox_file:
mailbox_file.write(str(mail_file[:100]))
mailbox_file.close()
print('User mail saved.')
def aprs_filter(packet):
#if aprslib.parse(packet) in aprslib.parse(packet):
# print(aprslib.parse(packet))
#else:
# pass
user_settings = ast.literal_eval(os.popen('cat ../../user_settings.txt').read())
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
if 'addresse' in aprslib.parse(packet):
#print(aprslib.parse(packet))
recipient = re.sub('-.*','', aprslib.parse(packet)['addresse'])
recipient_ssid = re.sub('.*-','', aprslib.parse(packet)['addresse'])
for i in user_settings.items():
## print('checking user_settings ' + recipient)
if recipient in i[1][0]['call'] and recipient_ssid in i[1][1]['ssid']:
## print(i[1][0])
## print(i[1][1])
## print(aprslib.parse(packet))
ssid = i[1][1]['ssid']
if i[1][1]['ssid'] == '':
ssid = user_aprs_ssid
if recipient in i[1][0]['call'] and recipient_ssid in ssid:
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time.time(), aprslib.parse(packet)['message_text'], recipient)
if 'msgNo' in aprslib.parse(packet):
time.sleep(1)
@@ -71,9 +68,10 @@ if __name__ == '__main__':
aprs_login = parser.get('GPS_DATA', 'APRS_RECEIVE_LOGIN_CALL')
aprs_passcode = parser.get('GPS_DATA', 'APRS_LOGIN_PASSCODE')
mailbox_file = parser.get('GPS_DATA', 'MAILBOX_FILE')
user_settings_file = mailbox_file = parser.get('GPS_DATA', 'USER_SETTINGS_FILE')
AIS = aprslib.IS(aprs_login, passwd=int(aprs_passcode), host=aprs_server, port=int(aprs_port))
user_settings = ast.literal_eval(os.popen('cat ../../user_settings.txt').read())
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
print('APRS message receive script for GPS/Data Application.\nAuthor: Eric, KF7EEL - kf7eel@qsl.net')
AIS.set_filter(parser.get('GPS_DATA', 'APRS_FILTER'))
AIS.connect()