diff --git a/data_gateway.py b/data_gateway.py index a67de9e..1fd2d11 100644 --- a/data_gateway.py +++ b/data_gateway.py @@ -457,7 +457,6 @@ def download_config(CONFIG_FILE, cli_file): try: req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'}) resp = json.loads(req.text) - print(resp) iterate_config = resp['peers'].copy() corrected_config = resp['config'].copy() corrected_config['SYSTEMS'] = {} @@ -885,18 +884,18 @@ def process_sms(_rf_src, sms, call_type, system_name): elif '#' == parse_sms[0][0:1]: ## print(mqtt_services.keys()) - if parse_sms[0][1:] in mqtt_services.keys(): - mqtt_send_msg(str(parse_sms[0])[1:], parse_sms[1], int_id(_rf_src), ' '.join(parse_sms[2:])) - else: - # Add error message - pass +## if parse_sms[0][1:] in mqtt_services.keys(): + mqtt_send_msg(str(parse_sms[0])[1:], parse_sms[1], int_id(_rf_src), ' '.join(parse_sms[2:])) +## else: +## # Add error message +## pass elif '!' == parse_sms[0][0:1]: ## print(mqtt_services.keys()) - if parse_sms[0][1:] in mqtt_services.keys(): - mqtt_send_app(str(parse_sms[0])[1:], str(int_id(_rf_src)), ' '.join(parse_sms[1:])) - else: - # Add error message - pass +## if parse_sms[0][1:] in mqtt_services.keys(): + mqtt_send_app(str(parse_sms[0])[1:], str(int_id(_rf_src)), ' '.join(parse_sms[1:])) +## else: +## # Add error message +## pass elif '@' in parse_sms[0][0:1] and ' ' in sms: #'M-' not in parse_sms[1][0:2] or '@' not in parse_sms[0][1:]: #Example SMS text: @ARMDS This is a test. @@ -1761,7 +1760,9 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr for i in ars_snd: print(ahex(bptc_decode(i))) +## systems[UNIT_MAP[_rf_src][0]].send_system(i) systems[UNIT_MAP[_rf_src][0]].send_system(i) + @@ -2073,6 +2074,8 @@ if __name__ == '__main__': user_ssid = CONFIG['DATA_CONFIG']['USER_APRS_SSID'] aprs_comment = CONFIG['DATA_CONFIG']['USER_APRS_COMMENT'] aprs_filter = CONFIG['DATA_CONFIG']['APRS_FILTER'] + + ## # User APRS settings @@ -2146,10 +2149,12 @@ if __name__ == '__main__': rule_timer.addErrback(loopingErrHandle) # Experimental MQTT for external applications, etc. - print(CONFIG['DATA_CONFIG']['MQTT_SERVER']) - mqtt_thread = threading.Thread(target=mqtt_main, args=(CONFIG['DATA_CONFIG']['MQTT_SERVER'],int(CONFIG['DATA_CONFIG']['MQTT_PORT']),)) - mqtt_thread.daemon = True - mqtt_thread.start() + if CONFIG['DATA_CONFIG']['GATEWAY_CALLSIGN'] == 'n0call'.upper(): + logger.info('MQTT disabled. External applications and networks will not be available.') + else: + mqtt_thread = threading.Thread(target=mqtt_main, args=(CONFIG['DATA_CONFIG']['MQTT_SERVER'],int(CONFIG['DATA_CONFIG']['MQTT_PORT']),)) + mqtt_thread.daemon = True + mqtt_thread.start() # Used for misc timing events ten_loop_task = task.LoopingCall(ten_loop_func) diff --git a/data_gateway_config.py b/data_gateway_config.py index cec53e6..9f693f7 100644 --- a/data_gateway_config.py +++ b/data_gateway_config.py @@ -201,9 +201,10 @@ def build_config(_config_file): ## 'DASHBOARD_URL': config.get(section, 'DASHBOARD_URL'), ## 'SERVER_NAME': config.get(section, 'SERVER_NAME'), ## 'RULES_PATH': config.get(section, 'RULES_PATH'), + 'GATEWAY_CALLSIGN': config.get(section, 'GATEWAY_CALLSIGN'), - 'URL': config.get(section, 'URL'), - 'DESCRIPTION': config.get(section, 'DESCRIPTION'), +## 'URL': config.get(section, 'URL'), +## 'DESCRIPTION': config.get(section, 'DESCRIPTION'), 'MQTT_SERVER': config.get(section, 'MQTT_SERVER'), 'MQTT_PORT': config.get(section, 'MQTT_PORT'), diff --git a/web/app.py b/web/app.py index 9177c78..c134a14 100644 --- a/web/app.py +++ b/web/app.py @@ -54,7 +54,7 @@ import os, ast from cryptography.fernet import Fernet peer_locations = {} -hbnet_version = 'HWS 0.0.1-pre_pre_alpha' +hbnet_version = 'HWS 0.0.1-pre_pre_alpha/MQTT' # Query radioid.net for list of IDs def get_ids(callsign): @@ -4654,7 +4654,7 @@ Name: ''' + p.name + '''  -  Port: ''' + str( ## s = ServerList.query.filter_by(name=request.args.get('add_data_options')).first() print(request.form) print(request.form.get('user_settings')) - add_data_options(request.args.get('add_data_options'), 'DATA_GATEWAY:data_id=' + request.form.get('data_id') + ':call_type=' + request.form.get('call_type') + ':aprs_login_call=' + request.form.get('aprs_login_call') + ':aprs_login_passcode=' + request.form.get('aprs_login_passcode') + ':aprs_server=' + request.form.get('aprs_server') + ':aprs_port=' + request.form.get('aprs_port') + ':default_ssid=' + request.form.get('default_ssid') + ':default_comment=' + request.form.get('default_comment') + ':aprs_filter=' + request.form.get('aprs_filter') + ':user_settings=' + request.form.get('user_settings') + ':igate_time=' + request.form.get('igate_time') + ':igate_icon=' + request.form.get('igate_icon') + ':igate_comment=' + request.form.get('igate_comment') + ':igate_lat=' + request.form.get('igate_lat') + ':igate_lon=' + request.form.get('igate_lon') + '') + add_data_options(request.args.get('add_data_options'), 'DATA_GATEWAY:data_id=' + request.form.get('data_id') + ':call_type=' + request.form.get('call_type') + ':aprs_login_call=' + request.form.get('aprs_login_call') + ':aprs_login_passcode=' + request.form.get('aprs_login_passcode') + ':aprs_server=' + request.form.get('aprs_server') + ':aprs_port=' + request.form.get('aprs_port') + ':default_ssid=' + request.form.get('default_ssid') + ':default_comment=' + request.form.get('default_comment') + ':aprs_filter=' + request.form.get('aprs_filter') + ':user_settings=' + request.form.get('user_settings') + ':igate_time=' + request.form.get('igate_time') + ':igate_icon=' + request.form.get('igate_icon') + ':igate_comment=' + request.form.get('igate_comment') + ':igate_lat=' + request.form.get('igate_lat') + ':igate_lon=' + request.form.get('igate_lon') + ';MQTT:gateway_callsign=' + request.form.get('gateway_call') + ':server=' + request.form.get('mqtt_server') + ':port=' + request.form.get('mqtt_port') + ':username=' + request.form.get('mqtt_user') + ':password=' + request.form.get('mqtt_password') + ':url=' + request.form.get('url') + ':description=' + request.form.get('description')) content = '''

Added data gateway options.

Redirecting in 3 seconds.

@@ -7081,7 +7081,7 @@ Name: ''' + p.name + '''  -  Port: ''' + str( ''' web_output = ''' -

External Services for: ''' + i.name + '''

+

External Services for discovered: ''' + i.name + '''

diff --git a/web/templates/data_gateway_help.html b/web/templates/data_gateway_help.html index fce4698..82ce155 100644 --- a/web/templates/data_gateway_help.html +++ b/web/templates/data_gateway_help.html @@ -60,6 +60,34 @@

 

+ + +

External Applications

+

If configured, this gateway can send and receive SMS messages from other networks and applications. An external application may be a type of gateway, such as an email gateway, or some other information service. See the External Services page to see what is available.

+

Social Status Commands

+ + + + + + + + + + + + + + + + + + + + +
CommandDescriptionExample
![SHORTCUT] [MESSAGE]Send a message to an external application.!TST test
#[SHORTCUT] [DMR ID] [MESSAGE]Send an SMS to another user on a different network.#DMRNET 1234567 Are you there?
+

 

+

Tiny Pages

Tiny Pages are statically retrievable pieces of information. A tiny page can be created and changed by a user in the web service. A tiny page can be retrieved via SMS with a simple command. Potential uses include help messages, net schedule messages, or whatever you can think of.

@@ -121,7 +149,7 @@ *SS -Post a message to social status.. +Post a message to social status. *SS testing 123 diff --git a/web/templates/data_gateway_wizard.html b/web/templates/data_gateway_wizard.html index a302425..c40b876 100644 --- a/web/templates/data_gateway_wizard.html +++ b/web/templates/data_gateway_wizard.html @@ -5,10 +5,13 @@
-Note: Setting the APRS Login Call to N0CALL will disable APRS features. You will still be able to see station positions on the map though. +Note: Setting the APRS Login Call to N0CALL will disable APRS and MQTT (external application/network) features. You will still be able to see station positions on the map though. Note: Setting iGate Time to 0 will disable beaconing of iGate packets. +Note: Leave MQTT Username and Password to use with servers that don't require authentication. + +

@@ -106,6 +109,44 @@ +
+ +
+ +
+ MQTT Callsign + +
+ +
+ URL + +
+ +
+ Description + +
+ +
+ MQTT Server + +
+ +
+ MQTT Port + +
+ +
+ MQTT Username + +
+ +
+ MQTT Password + +