fix bugs, add user settings to config
This commit is contained in:
parent
295dfbda1f
commit
fcff610fd3
@ -46,6 +46,19 @@ SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
# APRS - BY IU7IGU
|
||||
# Enabling "APRS" will configure APRS-Beaconing of Master's connection
|
||||
# like repeater and hotspots.
|
||||
# REPORT_INTERVAL in Minute (ALLOW only > 3 Minutes)
|
||||
# CALLSIGN: Callsign that will pubblish data on aprs server
|
||||
# MESSAGE: This message will print on APRS description together RX and TX Frequency
|
||||
|
||||
[APRS]
|
||||
ENABLED: False
|
||||
REPORT_INTERVAL: 15
|
||||
CALLSIGN:HB1LNK-11
|
||||
SERVER:euro.aprs2.net
|
||||
MESSAGE:Connesso ad HBLINK
|
||||
|
||||
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
|
||||
# Enabling "REPORT" will configure a socket-based reporting
|
||||
@ -135,6 +148,14 @@ IGATE_BEACON_ICON = /I
|
||||
IGATE_LATITUDE = 0000.00N
|
||||
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
|
||||
# about APRS filters.
|
||||
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
|
||||
APRS_FILTER: r/47/-120/500 t/m
|
||||
|
||||
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
|
||||
# to enable the email gateway. Leave as is to disable.
|
||||
EMAIL_SENDER:
|
||||
@ -142,6 +163,51 @@ EMAIL_PASSWORD:
|
||||
SMTP_SERVER: smtp.gmail.com
|
||||
SMTP_PORT: 465
|
||||
|
||||
# The options below are required for operation of the dashboard and will cause errors in gps_data.py
|
||||
# if configured wrong. Leave them as default unless you know what you are doing.
|
||||
# If you do change, you must use absolute paths.
|
||||
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 following options are used for the dashboard. The dashboard is optional.
|
||||
# Title of the Dashboard
|
||||
DASHBOARD_TITLE: HBLink3 D-APRS Dashboard
|
||||
|
||||
# Logo used on dashboard page
|
||||
LOGO: https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png
|
||||
|
||||
# Port to run server
|
||||
DASH_PORT: 8092
|
||||
|
||||
# IP to run server on
|
||||
DASH_HOST: 127.0.0.1
|
||||
|
||||
#Description of dashboard to show on main page
|
||||
DESCRIPTION: Welcome to the dashboard.
|
||||
|
||||
# Gateway contact info displayed on about page.
|
||||
CONTACT_NAME: your name
|
||||
CONTACT_CALL: N0CALL
|
||||
CONTACT_EMAIL: email@example.org
|
||||
CONTACT_WEBSITE: https://hbl.ink
|
||||
|
||||
# Time format for display
|
||||
TIME_FORMAT: %%H:%%M:%%S - %%m/%%d/%%y
|
||||
|
||||
# Center dashboard map over these coordinates
|
||||
MAP_CENTER_LAT: 47.00
|
||||
MAP_CENTER_LON: -120.00
|
||||
ZOOM_LEVEL: 7
|
||||
|
||||
# List and preview of some map themes at http://leaflet-extras.github.io/leaflet-providers/preview/
|
||||
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
|
||||
MAP_THEME: Stamen Toner
|
||||
|
||||
# RSS feed link, shows in the link section of each RSS item.
|
||||
RSS_LINK: http://localhost:8092
|
||||
|
||||
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
|
||||
# OpenBridge is a protocol originall created by DMR+ for connection between an
|
||||
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
|
||||
@ -191,6 +257,9 @@ TGID_ACL: PERMIT:ALL
|
||||
[MASTER-1]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
# The APRS setting below has to do with the beaconing of PEER conections, and not GPS positions
|
||||
# from radios. This setting will not affect gps_data.py
|
||||
APRS: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 10
|
||||
EXPORT_AMBE: False
|
||||
|
@ -44,7 +44,7 @@ from twisted.protocols.basic import NetstringReceiver
|
||||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases, aprs_upload, sendAprs
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
@ -207,7 +207,7 @@ def mailbox_delete(dmr_id):
|
||||
|
||||
|
||||
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:
|
||||
if user_settings[dmr_id][1]['ssid'] == '':
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||
@ -340,7 +340,7 @@ def process_sms(_rf_src, sms):
|
||||
logger.info('Latitude: ' + str(aprs_lat))
|
||||
logger.info('Longitude: ' + str(aprs_lon))
|
||||
# 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:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
@ -383,7 +383,7 @@ def process_sms(_rf_src, sms):
|
||||
aprs_dest = re.sub('@| A-.*','',sms)
|
||||
aprs_msg = re.sub('^@|.* A-|','',sms)
|
||||
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'] != '':
|
||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||
else:
|
||||
@ -1521,7 +1521,7 @@ class routerHBP(HBSYSTEM):
|
||||
#logger.info(aprs_loc_packet)
|
||||
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
||||
# 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:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
@ -1617,7 +1617,7 @@ class routerHBP(HBSYSTEM):
|
||||
# Begin APRS format and upload
|
||||
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
||||
# 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:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
@ -1811,11 +1811,11 @@ if __name__ == '__main__':
|
||||
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
|
||||
|
||||
# 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
|
||||
else:
|
||||
Path('./user_settings.txt').touch()
|
||||
with open("./user_settings.txt", 'w') as user_dict_file:
|
||||
Path(user_settings_file).touch()
|
||||
with open(user_settings_file, 'w') as user_dict_file:
|
||||
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
||||
user_dict_file.close()
|
||||
# Check to see if dashboard files exist
|
||||
@ -1898,7 +1898,7 @@ if __name__ == '__main__':
|
||||
systems[system] = routerHBP(system, CONFIG, report_server)
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
#aprs_upload(CONFIG)
|
||||
aprs_upload(CONFIG)
|
||||
|
||||
def loopingErrHandle(failure):
|
||||
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
|
||||
|
12
config.py
12
config.py
@ -106,6 +106,7 @@ def build_config(_config_file):
|
||||
CONFIG['GLOBAL'] = {}
|
||||
CONFIG['REPORTS'] = {}
|
||||
CONFIG['LOGGER'] = {}
|
||||
CONFIG['APRS'] = {}
|
||||
CONFIG['GPS_DATA'] = {}
|
||||
CONFIG['ALIASES'] = {}
|
||||
CONFIG['SYSTEMS'] = {}
|
||||
@ -165,6 +166,7 @@ def build_config(_config_file):
|
||||
'BULLETIN_BOARD_FILE': config.get(section, 'BULLETIN_BOARD_FILE'),
|
||||
'MAILBOX_FILE': config.get(section, 'MAILBOX_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']:
|
||||
@ -182,6 +184,15 @@ def build_config(_config_file):
|
||||
'STALE_TIME': config.getint(section, 'STALE_DAYS') * 86400,
|
||||
})
|
||||
|
||||
elif section == 'APRS':
|
||||
CONFIG['APRS'].update({
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'CALLSIGN': config.get(section, 'CALLSIGN'),
|
||||
'REPORT_INTERVAL': config.getint(section, 'REPORT_INTERVAL'),
|
||||
'SERVER': config.get(section, 'SERVER'),
|
||||
'MESSAGE': config.get(section, 'MESSAGE')
|
||||
})
|
||||
|
||||
elif config.getboolean(section, 'ENABLED'):
|
||||
if config.get(section, 'MODE') == 'PEER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
@ -278,6 +289,7 @@ def build_config(_config_file):
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'APRS': config.getboolean(section, 'APRS'),
|
||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
|
@ -141,6 +141,9 @@ IGATE_BEACON_ICON = /I
|
||||
IGATE_LATITUDE = 0000.00N
|
||||
IGATE_LONGITUDE = 00000.00W
|
||||
|
||||
# User settings file, MUST configure using absolute path.
|
||||
USER_SETTINGS_FILE: /path/to/user_settings.txt
|
||||
|
||||
# The options below are required for operation of the dashboard. Leave them as default
|
||||
# unless you know what you are doing.
|
||||
LOCATION_FILE: /tmp/gps_data_user_loc.txt
|
||||
|
19
gps_data.py
19
gps_data.py
@ -200,7 +200,7 @@ def mailbox_delete(dmr_id):
|
||||
|
||||
|
||||
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:
|
||||
if user_settings[dmr_id][1]['ssid'] == '':
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||
@ -333,7 +333,7 @@ def process_sms(_rf_src, sms):
|
||||
logger.info('Latitude: ' + str(aprs_lat))
|
||||
logger.info('Longitude: ' + str(aprs_lon))
|
||||
# 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:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
@ -376,7 +376,7 @@ def process_sms(_rf_src, sms):
|
||||
aprs_dest = re.sub('@| A-.*','',sms)
|
||||
aprs_msg = re.sub('^@|.* A-|','',sms)
|
||||
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'] != '':
|
||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||
else:
|
||||
@ -469,7 +469,7 @@ class DATA_SYSTEM(HBSYSTEM):
|
||||
#logger.info(aprs_loc_packet)
|
||||
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
||||
# 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:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
@ -565,7 +565,7 @@ class DATA_SYSTEM(HBSYSTEM):
|
||||
# Begin APRS format and upload
|
||||
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
||||
# 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:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
@ -713,12 +713,15 @@ if __name__ == '__main__':
|
||||
the_mailbox_file = CONFIG['GPS_DATA']['MAILBOX_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.
|
||||
if Path('./user_settings.txt').is_file():
|
||||
if Path(user_settings_file).is_file():
|
||||
pass
|
||||
else:
|
||||
Path('./user_settings.txt').touch()
|
||||
with open("./user_settings.txt", 'w') as user_dict_file:
|
||||
Path(user_settings_file).touch()
|
||||
with open(user_settings_file, 'w') as user_dict_file:
|
||||
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
||||
user_dict_file.close()
|
||||
# Check to see if dashboard files exist
|
||||
|
@ -24,18 +24,16 @@ 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())
|
||||
if 'addresse' in aprslib.parse(packet):
|
||||
#print(aprslib.parse(packet))
|
||||
@ -43,11 +41,10 @@ def aprs_filter(packet):
|
||||
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,6 +68,7 @@ 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())
|
||||
|
Loading…
Reference in New Issue
Block a user