mirror of https://github.com/kf7eel/hbnet
SMS format translation and web service configuration export, initial commit and untested
This commit is contained in:
parent
678c5fff60
commit
1e311d86c6
|
|
@ -1913,6 +1913,9 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
|||
process_sms(_rf_src, msg_found, _call_type, UNIT_MAP[_rf_src][0])
|
||||
if int_id(_dst_id) not in data_id:
|
||||
dashboard_sms_write(str(get_alias(int_id(_rf_src), subscriber_ids)), str(get_alias(int_id(_dst_id), subscriber_ids)), int_id(_dst_id), int_id(_rf_src), msg_found, time(), UNIT_MAP[_rf_src][0])
|
||||
if '$' in msg_found[0:1]:
|
||||
send_sms(False, int_id(_dst_id), int_id(_rf_src), int_id(_rf_src), 'unit', msg_found)
|
||||
|
||||
pass
|
||||
|
||||
# Reset assembly
|
||||
|
|
|
|||
135
web/app.py
135
web/app.py
|
|
@ -2589,6 +2589,138 @@ FLOOD_TIMEOUT = ''' + str(s.unit_time)
|
|||
response = Response(rules, mimetype="text/plain")
|
||||
return response
|
||||
|
||||
@app.route('/export_config/<server>.cfg')
|
||||
@roles_required('Admin')
|
||||
@login_required
|
||||
def config_export(server):
|
||||
## response = generate_rules(server)
|
||||
s = ServerList.query.filter_by(name=server).first()
|
||||
|
||||
config=server_get(server)
|
||||
peers=get_peer_configs(server)
|
||||
masters=masters_get(server)
|
||||
|
||||
final_config = '# Exported config generated by HBNet - ' + server + '''
|
||||
|
||||
[LOGGER]
|
||||
LOG_FILE: /tmp/''' + server + '''.log
|
||||
LOG_HANDLERS: console-timed
|
||||
LOG_LEVEL: DEBUG
|
||||
LOG_NAME: ''' + server + '''
|
||||
'''
|
||||
##
|
||||
## for i in config.keys():
|
||||
## final_config[i] = {}
|
||||
##
|
||||
## for i in config.items():
|
||||
## print(i[1])
|
||||
## print(config)
|
||||
|
||||
|
||||
|
||||
if 'DATA_GATEWAY' in config['OTHER']['OTHER_OPTIONS']:
|
||||
final_config = final_config + '\n[DATA_CONFIG]\n'
|
||||
gateway_options = config['OTHER']['OTHER_OPTIONS'][13:].split(':')
|
||||
## print(gateway_options)
|
||||
for o in gateway_options:
|
||||
## final_config = final_config + o
|
||||
final_options = o.split('=')
|
||||
## print(final_options)
|
||||
if final_options[0] == 'aprs_login_call':
|
||||
final_config = final_config + 'APRS_LOGIN_CALL: ' + final_options[1].upper() +'\n'
|
||||
if final_options[0] == 'aprs_login_passcode':
|
||||
final_config = final_config + 'APRS_LOGIN_PASSCODE: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'aprs_server':
|
||||
final_config = final_config + 'APRS_SERVER: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'aprs_filter':
|
||||
final_config = final_config + 'APRS_FILTER: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'aprs_port':
|
||||
final_config = final_config + 'APRS_PORT: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'default_ssid':
|
||||
final_config = final_config + 'USER_APRS_SSID: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'default_comment':
|
||||
final_config = final_config + 'USER_APRS_COMMENT: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'data_id':
|
||||
final_config = final_config + 'DATA_DMR_ID: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'call_type':
|
||||
final_config = final_config + 'CALL_TYPE: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'user_settings':
|
||||
final_config = final_config + 'USER_SETTINGS_FILE: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'igate_time':
|
||||
final_config = final_config + 'IGATE_BEACON_TIME: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'igate_icon':
|
||||
final_config = final_config + 'IGATE_BEACON_ICON: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'igate_comment':
|
||||
final_config = final_config + 'IGATE_BEACON_COMMENT: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'igate_lat':
|
||||
final_config = final_config + 'IGATE_BEACON_LATITUDE: ' + final_options[1][:8] + '\n'
|
||||
if final_options[0] == 'igate_lon':
|
||||
final_config = final_config + 'IGATE_BEACON_LONGITUDE: ' + final_options[1][:9] + '\n'
|
||||
|
||||
|
||||
if 'MQTT' in config['OTHER']['OTHER_OPTIONS']:
|
||||
mqtt_options = config['OTHER']['OTHER_OPTIONS'][5:].split(':')
|
||||
for o in mqtt_options:
|
||||
final_options = o.split('=')
|
||||
if final_options[0] == 'gateway_callsign':
|
||||
final_config = final_config + 'GATEWAY_CALLSIGN: ' + final_options[1].upper() +'\n'
|
||||
if final_options[0] == 'url':
|
||||
final_config = final_config + 'URL: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'description':
|
||||
final_config = final_config + 'DESCRIPTION: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'server':
|
||||
final_config = final_config + 'MQTT_SERVER: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'port':
|
||||
final_config = final_config + 'MQTT_PORT: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'username':
|
||||
final_config = final_config + 'MQTT_USERNAME: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'password':
|
||||
final_config = final_config + 'MQTT_PASSWORD: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'server2':
|
||||
final_config = final_config + 'MQTT_SERVER2: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'port2':
|
||||
final_config = final_config + 'MQTT_PORT2: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'username2':
|
||||
final_config = final_config + 'MQTT_USERNAME2: ' + final_options[1] + '\n'
|
||||
if final_options[0] == 'password2':
|
||||
final_config = final_config + 'MQTT_PASSWORD2: ' + final_options[1] + '\n'
|
||||
|
||||
for i in config.items():
|
||||
if i[0] == 'OTHER':
|
||||
pass
|
||||
else:
|
||||
final_config = final_config + '\n[' + i[0] + ']\n'
|
||||
for l in i[1].items():
|
||||
final_config = final_config + l[0] + ': ' + str(l[1]) + '\n'
|
||||
|
||||
for i in masters.items():
|
||||
final_config = final_config + '\n[' + i[0] + ']\n'
|
||||
for l in i[1].items():
|
||||
if l[0] == 'PEERS':
|
||||
pass
|
||||
elif l[0] == 'TARGET_SOCK':
|
||||
pass
|
||||
else:
|
||||
final_config = final_config + l[0] + ': ' + str(l[1]) + '\n'
|
||||
|
||||
for i in peers.items():
|
||||
final_config = final_config + '\n[' + i[0] + ']\n'
|
||||
for l in i[1].items():
|
||||
if l[0] == 'SOCK_ADDR':
|
||||
pass
|
||||
elif l[0] == 'MASTER_SOCKADDR':
|
||||
pass
|
||||
else:
|
||||
final_config = final_config + l[0] + ': ' + str(l[1]) + '\n'
|
||||
|
||||
|
||||
## print()
|
||||
## print(final_config)
|
||||
## print(config)
|
||||
|
||||
response = Response(final_config, mimetype="text/plain")
|
||||
return response
|
||||
|
||||
@app.route('/hbnet_tg_anytone.csv')
|
||||
## @login_required
|
||||
def anytone_tg_csv():
|
||||
|
|
@ -4675,6 +4807,9 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
|||
|
||||
<p style="text-align: center;"><strong><a href="/export_rules/''' + str(s.name) + '''.py">Export Rules</a></strong></p>
|
||||
|
||||
<p style="text-align: center;"><strong><a href="/export_config/''' + str(s.name) + '''.cfg">Export Configuration</a></strong></p>
|
||||
|
||||
|
||||
<p style="text-align: center;"><strong><a href="/data_wizard/''' + str(s.name) + '''">Add options for Data Gateway</a></strong></p>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue