diff --git a/access_systems.txt b/access_systems.txt index ad40854..b3e5e0b 100644 --- a/access_systems.txt +++ b/access_systems.txt @@ -1,11 +1,20 @@ { 'XYZ':{ 'mode':'msg_xfer', + 'network_name':'My HBlink Server', + 'url':'http://example.net/api', 'user':'test_name', 'password':'passw0rd' }, 'APP':{ 'mode':'app', + 'app_name':'Test app', + 'url':'http://localhost:8080/post', + }, + 'ABC':{ + 'mode':'msg_xfer', + 'network_name':'Regional HBlink Network 1', + 'url':'http://localhost:8092/api', 'user':'test_name', 'password':'passw0rd' } diff --git a/authorized_users.txt b/authorized_users.txt index 0cf8f02..5e300b7 100644 --- a/authorized_users.txt +++ b/authorized_users.txt @@ -1,5 +1,5 @@ { - 'ABC':{ + 'XYZ':{ 'mode':'msg_xfer', 'user':'test_name', 'password':'passw0rd' diff --git a/dev/json_templates.py b/dev/json_templates.py index 8fc838b..2c23cb3 100644 --- a/dev/json_templates.py +++ b/dev/json_templates.py @@ -34,8 +34,10 @@ msg_xfer = { } json_object = json.dumps(msg_xfer, indent = 4) -print('App') +print('-----------------------------------------') +print('msg_xfer') print(json_object) +print('-----------------------------------------') app_request = { 'mode':'app', @@ -44,7 +46,6 @@ app_request = { 'auth_token':'1234567899', 'data':{ 'source_id':1234, - 'destination_id':3153591, 'slot':2, 'msg_type':'unit', 'msg_format':'motorola', @@ -52,22 +53,25 @@ app_request = { } } -json_object = json.dumps(app_request, indent = 4) +json_object = json.dumps(app_request, indent = 4) +print('-----------------------------------------') +print('app, request, sent to the APP server') print(json_object) +print('-----------------------------------------') app_response = { 'mode':'app', 'system_name':'APP', - 'auth_token':'1234567899', + 'auth_token':'736a9ced7e7688c951490a7f8e1ebdd4', 'data':{ - 1:{'source_id':1234, + 1:{'source_app':'app_name', 'destination_id':3153591, 'slot':2, 'msg_type':'unit', 'msg_format':'motorola', 'message':'text of the message' }, - 2:{'source_id':1234, + 2:{'source_id':'app_name', 'destination_id':3153591, 'slot':2, 'msg_type':'unit', @@ -77,10 +81,12 @@ app_response = { } } -json_object = json.dumps(app_response, indent = 4) +json_object = json.dumps(app_response, indent = 4) +print('-----------------------------------------') +print('app, response, sent to your dashboard') print(json_object) - -msg_xfer = { +print('-----------------------------------------') +raw_msg_xfer = { 'mode':'raw', 'system_name':'ABC', 'response_url':'http://localhost:8093/api/', diff --git a/full_bridge.py b/full_bridge.py index 6f0fbaf..f09e471 100644 --- a/full_bridge.py +++ b/full_bridge.py @@ -2,8 +2,9 @@ # ############################################################################### # Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS -# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL +# GPS/Data - Copyright (C) 2021 Eric Craw, KF7EEL # Annotated modifications Copyright (C) 2021 Xavier FRS2013 +# Static position by IU7IGU # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -242,7 +243,7 @@ def sos_write(dmr_id, time, message): sos_file.close() logger.info('Saved SOS.') def send_app_request(url, message, source_id): - url = url + '/app' + #url = url + '/app' #Load current AUTH token list auth_file = ast.literal_eval(os.popen('cat ' + auth_token_file).read()) the_token = str(hashlib.md5(str(time()).encode('utf-8')).hexdigest()) @@ -255,7 +256,7 @@ def send_app_request(url, message, source_id): app_request = { 'mode':'app', 'system_name':CONFIG['GPS_DATA']['MY_API_NAME'], - 'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'], + 'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'] + '/api', 'auth_token':the_token, 'data':{ 'source_id':source_id, diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index 663e5ab..e01f8fd 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -726,7 +726,7 @@ def mail_rss(): def api(api_mode=None): if request.method == 'GET': api_content = '

API Enabled: ' + str(use_api) + '

' - return render_template('generic.html', title = dashboard_title, content = Markup(api_content)) + return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(api_content)) if use_api == 'True' or use_api == "true": access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read()) authorized_users = ast.literal_eval(os.popen('cat ' + authorized_users_file).read()) @@ -776,6 +776,7 @@ def api(api_mode=None): return make_response(message, 400) if api_data['mode'] == 'app': auth_file = ast.literal_eval(os.popen('cat ' + auth_token_file).read()) + print(auth_file) for token in auth_file: print() print(token) @@ -792,7 +793,7 @@ def api(api_mode=None): send_slot = 0 if sms_data['slot'] == 2: send_slot = 1 - send_sms(False, sms_data['destination_id'], sms_data['source_id'], 0000, 'unit', send_slot, sms_data['message']) + send_sms(False, sms_data['destination_id'], 0000, 0000, 'unit', send_slot, sms_data['message']) new_auth_file = auth_file with open(auth_token_file, 'w') as auth_token: auth_token.write(str(auth_file)) @@ -803,9 +804,9 @@ def api(api_mode=None): mode=api_data['mode'], status='Token accepted, SMS generated', ) - if token != api_data['auth_token']: - message = jsonify(message='Auth token not found') - return make_response(message, 401) +## if token != api_data['auth_token']: +## message = jsonify(message='Auth token not found') +## return make_response(message, 401) else: message = jsonify(message='Mode not found')