fix bugs
This commit is contained in:
parent
e6c61dd72a
commit
3946a6735d
|
@ -148,6 +148,9 @@ IGATE_BEACON_ICON = /I
|
||||||
IGATE_LATITUDE = 0000.00N
|
IGATE_LATITUDE = 0000.00N
|
||||||
IGATE_LONGITUDE = 00000.00W
|
IGATE_LONGITUDE = 00000.00W
|
||||||
|
|
||||||
|
# User settings file, MUST configure using absolute path.
|
||||||
|
USER_SETTINGS_FILE: /path/to/user_settings.txt
|
||||||
|
|
||||||
# The APRS filter below is used for the message received script. See http://www.aprs-is.net/javAPRSFilter.aspx for details
|
# The APRS filter below is used for the message received script. See http://www.aprs-is.net/javAPRSFilter.aspx for details
|
||||||
# about APRS filters.
|
# about APRS filters.
|
||||||
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
|
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
|
||||||
|
|
|
@ -207,7 +207,7 @@ def mailbox_delete(dmr_id):
|
||||||
|
|
||||||
|
|
||||||
def sos_write(dmr_id, time, message):
|
def sos_write(dmr_id, time, message):
|
||||||
user_settings = ast.literal_eval(os.popen('cat ./user_settings.txt').read())
|
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||||
try:
|
try:
|
||||||
if user_settings[dmr_id][1]['ssid'] == '':
|
if user_settings[dmr_id][1]['ssid'] == '':
|
||||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||||
|
@ -245,7 +245,7 @@ def decdeg2dms(dd):
|
||||||
def user_setting_write(dmr_id, setting, value):
|
def user_setting_write(dmr_id, setting, value):
|
||||||
## try:
|
## try:
|
||||||
# Open file and load as dict for modification
|
# Open file and load as dict for modification
|
||||||
with open("./user_settings.txt", 'r') as f:
|
with open(user_settings_file, 'r') as f:
|
||||||
## if f.read() == '{}':
|
## if f.read() == '{}':
|
||||||
## user_dict = {}
|
## user_dict = {}
|
||||||
user_dict = ast.literal_eval(f.read())
|
user_dict = ast.literal_eval(f.read())
|
||||||
|
@ -264,7 +264,7 @@ def user_setting_write(dmr_id, setting, value):
|
||||||
f.close()
|
f.close()
|
||||||
logger.info('Loaded user settings. Preparing to write...')
|
logger.info('Loaded user settings. Preparing to write...')
|
||||||
# Write modified dict to file
|
# Write modified dict to file
|
||||||
with open("./user_settings.txt", 'w') as user_dict_file:
|
with open(user_settings_file, 'w') as user_dict_file:
|
||||||
user_dict_file.write(str(user_dict))
|
user_dict_file.write(str(user_dict))
|
||||||
user_dict_file.close()
|
user_dict_file.close()
|
||||||
logger.info('User setting saved')
|
logger.info('User setting saved')
|
||||||
|
@ -340,7 +340,7 @@ def process_sms(_rf_src, sms):
|
||||||
logger.info('Latitude: ' + str(aprs_lat))
|
logger.info('Latitude: ' + str(aprs_lat))
|
||||||
logger.info('Longitude: ' + str(aprs_lon))
|
logger.info('Longitude: ' + str(aprs_lon))
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
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 int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
|
@ -383,7 +383,7 @@ def process_sms(_rf_src, sms):
|
||||||
aprs_dest = re.sub('@| A-.*','',sms)
|
aprs_dest = re.sub('@| A-.*','',sms)
|
||||||
aprs_msg = re.sub('^@|.* A-|','',sms)
|
aprs_msg = re.sub('^@|.* A-|','',sms)
|
||||||
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
||||||
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 int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
if int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||||
else:
|
else:
|
||||||
|
@ -1521,7 +1521,7 @@ class routerHBP(HBSYSTEM):
|
||||||
#logger.info(aprs_loc_packet)
|
#logger.info(aprs_loc_packet)
|
||||||
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
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 int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
|
@ -1617,7 +1617,7 @@ class routerHBP(HBSYSTEM):
|
||||||
# Begin APRS format and upload
|
# Begin APRS format and upload
|
||||||
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
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 int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
|
@ -1811,11 +1811,11 @@ if __name__ == '__main__':
|
||||||
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
|
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
|
||||||
|
|
||||||
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
||||||
if Path('./user_settings.txt').is_file():
|
if Path(user_settings_file).is_file():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
Path('./user_settings.txt').touch()
|
Path(user_settings_file).touch()
|
||||||
with open("./user_settings.txt", 'w') as user_dict_file:
|
with open(user_settings_file, 'w') as user_dict_file:
|
||||||
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
||||||
user_dict_file.close()
|
user_dict_file.close()
|
||||||
# Check to see if dashboard files exist
|
# Check to see if dashboard files exist
|
||||||
|
|
|
@ -166,6 +166,7 @@ def build_config(_config_file):
|
||||||
'BULLETIN_BOARD_FILE': config.get(section, 'BULLETIN_BOARD_FILE'),
|
'BULLETIN_BOARD_FILE': config.get(section, 'BULLETIN_BOARD_FILE'),
|
||||||
'MAILBOX_FILE': config.get(section, 'MAILBOX_FILE'),
|
'MAILBOX_FILE': config.get(section, 'MAILBOX_FILE'),
|
||||||
'EMERGENCY_SOS_FILE': config.get(section, 'EMERGENCY_SOS_FILE'),
|
'EMERGENCY_SOS_FILE': config.get(section, 'EMERGENCY_SOS_FILE'),
|
||||||
|
'USER_SETTINGS_FILE': config.get(section, 'USER_SETTINGS_FILE'),
|
||||||
|
|
||||||
})
|
})
|
||||||
if not CONFIG['LOGGER']['LOG_FILE']:
|
if not CONFIG['LOGGER']['LOG_FILE']:
|
||||||
|
|
|
@ -141,12 +141,8 @@ IGATE_BEACON_ICON = /I
|
||||||
IGATE_LATITUDE = 0000.00N
|
IGATE_LATITUDE = 0000.00N
|
||||||
IGATE_LONGITUDE = 00000.00W
|
IGATE_LONGITUDE = 00000.00W
|
||||||
|
|
||||||
# The options below are required for operation of the dashboard. Leave them as default
|
# User settings file, MUST configure using absolute path.
|
||||||
# unless you know what you are doing.
|
USER_SETTINGS_FILE: /path/to/user_settings.txt
|
||||||
LOCATION_FILE: /tmp/gps_data_user_loc.txt
|
|
||||||
BULLETIN_BOARD_FILE: /tmp/gps_data_user_bb.txt
|
|
||||||
MAILBOX_FILE: /tmp/gps_data_user_mailbox.txt
|
|
||||||
EMERGENCY_SOS_FILE: /tmp/gps_data_user_sos.txt
|
|
||||||
|
|
||||||
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
|
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
|
||||||
http://www.aprs-is.net/javAPRSFilter.aspx# to enable the email gateway. Leave as is to disable.
|
http://www.aprs-is.net/javAPRSFilter.aspx# to enable the email gateway. Leave as is to disable.
|
||||||
|
|
23
gps_data.py
23
gps_data.py
|
@ -200,7 +200,7 @@ def mailbox_delete(dmr_id):
|
||||||
|
|
||||||
|
|
||||||
def sos_write(dmr_id, time, message):
|
def sos_write(dmr_id, time, message):
|
||||||
user_settings = ast.literal_eval(os.popen('cat ./user_settings.txt').read())
|
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||||
try:
|
try:
|
||||||
if user_settings[dmr_id][1]['ssid'] == '':
|
if user_settings[dmr_id][1]['ssid'] == '':
|
||||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||||
|
@ -238,7 +238,7 @@ def decdeg2dms(dd):
|
||||||
def user_setting_write(dmr_id, setting, value):
|
def user_setting_write(dmr_id, setting, value):
|
||||||
## try:
|
## try:
|
||||||
# Open file and load as dict for modification
|
# Open file and load as dict for modification
|
||||||
with open("./user_settings.txt", 'r') as f:
|
with open(user_settings_file, 'r') as f:
|
||||||
## if f.read() == '{}':
|
## if f.read() == '{}':
|
||||||
## user_dict = {}
|
## user_dict = {}
|
||||||
user_dict = ast.literal_eval(f.read())
|
user_dict = ast.literal_eval(f.read())
|
||||||
|
@ -257,7 +257,7 @@ def user_setting_write(dmr_id, setting, value):
|
||||||
f.close()
|
f.close()
|
||||||
logger.info('Loaded user settings. Preparing to write...')
|
logger.info('Loaded user settings. Preparing to write...')
|
||||||
# Write modified dict to file
|
# Write modified dict to file
|
||||||
with open("./user_settings.txt", 'w') as user_dict_file:
|
with open(user_settings_file, 'w') as user_dict_file:
|
||||||
user_dict_file.write(str(user_dict))
|
user_dict_file.write(str(user_dict))
|
||||||
user_dict_file.close()
|
user_dict_file.close()
|
||||||
logger.info('User setting saved')
|
logger.info('User setting saved')
|
||||||
|
@ -333,7 +333,7 @@ def process_sms(_rf_src, sms):
|
||||||
logger.info('Latitude: ' + str(aprs_lat))
|
logger.info('Latitude: ' + str(aprs_lat))
|
||||||
logger.info('Longitude: ' + str(aprs_lon))
|
logger.info('Longitude: ' + str(aprs_lon))
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
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 int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
|
@ -376,7 +376,7 @@ def process_sms(_rf_src, sms):
|
||||||
aprs_dest = re.sub('@| A-.*','',sms)
|
aprs_dest = re.sub('@| A-.*','',sms)
|
||||||
aprs_msg = re.sub('^@|.* A-|','',sms)
|
aprs_msg = re.sub('^@|.* A-|','',sms)
|
||||||
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
||||||
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 int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
if int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||||
else:
|
else:
|
||||||
|
@ -469,7 +469,7 @@ class DATA_SYSTEM(HBSYSTEM):
|
||||||
#logger.info(aprs_loc_packet)
|
#logger.info(aprs_loc_packet)
|
||||||
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
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 int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
|
@ -565,7 +565,7 @@ class DATA_SYSTEM(HBSYSTEM):
|
||||||
# Begin APRS format and upload
|
# Begin APRS format and upload
|
||||||
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
||||||
# 14FRS2013 simplified and moved settings retrieval
|
# 14FRS2013 simplified and moved settings retrieval
|
||||||
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 int_id(_rf_src) not in user_settings:
|
if int_id(_rf_src) not in user_settings:
|
||||||
ssid = str(user_ssid)
|
ssid = str(user_ssid)
|
||||||
icon_table = '/'
|
icon_table = '/'
|
||||||
|
@ -713,12 +713,15 @@ if __name__ == '__main__':
|
||||||
the_mailbox_file = CONFIG['GPS_DATA']['MAILBOX_FILE']
|
the_mailbox_file = CONFIG['GPS_DATA']['MAILBOX_FILE']
|
||||||
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
|
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
|
||||||
|
|
||||||
|
# User APRS settings
|
||||||
|
user_settings_file = CONFIG['GPS_DATA']['USER_SETTINGS_FILE']
|
||||||
|
|
||||||
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
||||||
if Path('./user_settings.txt').is_file():
|
if Path(user_settings_file).is_file():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
Path('./user_settings.txt').touch()
|
Path(user_settings_file).touch()
|
||||||
with open("./user_settings.txt", 'w') as user_dict_file:
|
with open(user_settings_file, 'w') as user_dict_file:
|
||||||
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
||||||
user_dict_file.close()
|
user_dict_file.close()
|
||||||
# Check to see if dashboard files exist
|
# Check to see if dashboard files exist
|
||||||
|
|
|
@ -24,30 +24,27 @@ import time
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
def mailbox_write(call, dmr_id, time, message, recipient):
|
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 = 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})
|
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.write(str(mail_file[:100]))
|
||||||
mailbox_file.close()
|
mailbox_file.close()
|
||||||
print('User mail saved.')
|
print('User mail saved.')
|
||||||
|
|
||||||
def aprs_filter(packet):
|
def aprs_filter(packet):
|
||||||
#if aprslib.parse(packet) in aprslib.parse(packet):
|
|
||||||
# print(aprslib.parse(packet))
|
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||||
#else:
|
|
||||||
# pass
|
|
||||||
user_settings = ast.literal_eval(os.popen('cat ../../user_settings.txt').read())
|
|
||||||
if 'addresse' in aprslib.parse(packet):
|
if 'addresse' in aprslib.parse(packet):
|
||||||
#print(aprslib.parse(packet))
|
#print(aprslib.parse(packet))
|
||||||
recipient = re.sub('-.*','', aprslib.parse(packet)['addresse'])
|
recipient = re.sub('-.*','', aprslib.parse(packet)['addresse'])
|
||||||
recipient_ssid = re.sub('.*-','', aprslib.parse(packet)['addresse'])
|
recipient_ssid = re.sub('.*-','', aprslib.parse(packet)['addresse'])
|
||||||
|
|
||||||
for i in user_settings.items():
|
for i in user_settings.items():
|
||||||
## print('checking user_settings ' + recipient)
|
ssid = i[1][1]['ssid']
|
||||||
if recipient in i[1][0]['call'] and recipient_ssid in i[1][1]['ssid']:
|
if i[1][1]['ssid'] == '':
|
||||||
## print(i[1][0])
|
ssid = user_aprs_ssid
|
||||||
## print(i[1][1])
|
if recipient in i[1][0]['call'] and recipient_ssid in ssid:
|
||||||
## print(aprslib.parse(packet))
|
|
||||||
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time.time(), aprslib.parse(packet)['message_text'], recipient)
|
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):
|
if 'msgNo' in aprslib.parse(packet):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -71,9 +68,10 @@ if __name__ == '__main__':
|
||||||
aprs_login = parser.get('GPS_DATA', 'APRS_RECEIVE_LOGIN_CALL')
|
aprs_login = parser.get('GPS_DATA', 'APRS_RECEIVE_LOGIN_CALL')
|
||||||
aprs_passcode = parser.get('GPS_DATA', 'APRS_LOGIN_PASSCODE')
|
aprs_passcode = parser.get('GPS_DATA', 'APRS_LOGIN_PASSCODE')
|
||||||
mailbox_file = parser.get('GPS_DATA', 'MAILBOX_FILE')
|
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))
|
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')
|
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.set_filter(parser.get('GPS_DATA', 'APRS_FILTER'))
|
||||||
AIS.connect()
|
AIS.connect()
|
||||||
|
|
Loading…
Reference in New Issue