From 52bd918a238d94ead2b730d08c0281efbc8c4dcb Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Mon, 21 Feb 2022 19:21:14 -0800 Subject: [PATCH] clean data_gateway-SAMPLE, comment out sstuff before deletion --- data_gateway-SAMPLE.cfg | 88 ++++------------------------- data_gateway.py | 121 +++++++++++++++++++++------------------- data_gateway_config.py | 2 +- 3 files changed, 76 insertions(+), 135 deletions(-) diff --git a/data_gateway-SAMPLE.cfg b/data_gateway-SAMPLE.cfg index aac12f6..1bd123b 100644 --- a/data_gateway-SAMPLE.cfg +++ b/data_gateway-SAMPLE.cfg @@ -84,10 +84,10 @@ REPORT_CLIENTS: 127.0.0.1 # used. # [LOGGER] -LOG_FILE: /tmp/hblink.log +LOG_FILE: /tmp/hbnet_data_gateway.log LOG_HANDLERS: console-timed LOG_LEVEL: DEBUG -LOG_NAME: HBlink +LOG_NAME: HBNet Data Gateway # DOWNLOAD AND IMPORT SUBSCRIBER, PEER and TGID ALIASES # Ok, not the TGID, there's no master list I know of to download @@ -109,29 +109,18 @@ STALE_DAYS: 7 # This is where to configure the details for use with a user managment script [WEB_SERVICE] THIS_SERVER_NAME: DATA_GATEWAY +# This must be set to True in order to use the web service an any mode. REMOTE_CONFIG_ENABLED: False # URL of the user managment server URL: http://localhost:8080/svr -# Integer appended to DMR ID during the generation of a passphrase -##APPEND_INT: 1 -##EXTRA_INT_1: 5 -##EXTRA_INT_2: 8 -##EXTRA_1: TeSt -##EXTRA_2: DmR4 -### Secret used to authenticate with user managment server, before checking if user login is approved +### Secret used to authenticate with web service SHARED_SECRET: test -# Shorten passphrases -SHORTEN_PASSPHRASE: True -SHORTEN_SAMPLE: 4 -SHORTEN_LENGTH: 4 -BURN_FILE: ./burn_ids.txt -BURN_INT: 5 [DATA_CONFIG] USE_DASHBOARD: True DATA_DMR_ID: 9099 CALL_TYPE: both -UNIT_SMS_TS: 2 +##UNIT_SMS_TS: 2 USER_APRS_SSID: 5 USER_APRS_COMMENT: HBNet APRS Gateway @@ -141,6 +130,10 @@ APRS_LOGIN_CALL: N0CALL APRS_LOGIN_PASSCODE: 12345 APRS_FILTER: r/47/-120/500 t/m + +# User settings file, MUST configure using absolute path. +USER_SETTINGS_FILE: /tmp/user_settings.txt + # The following settings are only applicable if you are using the gps_data_beacon_igate script. # They do not affect the operation gps_data itself. # Time in minutes. @@ -150,73 +143,14 @@ IGATE_BEACON_ICON = /I IGATE_LATITUDE = 4730. N IGATE_LONGITUDE = 11930. W +############################ NOT IMPLEMENTED YET ############################## # The following settings are for the static positions only, for hotspots or repeaters connected to MASTER stanzas. # Implementation by IU7IGU # REPORT_INTERVAL in Minute (ALLOW only > 3 Minutes) # MESSAGE: This message will print on APRS description together RX and TX Frequency APRS_STATIC_REPORT_INTERVAL: 15 APRS_STATIC_MESSAGE:Connected to HBLink - -# 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 -SMS_FILE: /tmp/gps_data_user_sms.txt - -# User settings file, MUST configure using absolute path. -USER_SETTINGS_FILE: /tmp/user_settings.txt - -# API settings -# Authorized Apps file - data used for the dashboard API -USE_API: True -AUTHORIZED_APPS_FILE: /tmp/authorized_apps.txt -AUTHORIZED_TOKENS_FILE: /tmp/hblink_auth_tokens.txt -AUTHORIZED_USERS_FILE: /home/eric/Sync/hblink3_sms_dev/authorized_users.txt -ACCESS_SYSTEMS_FILE: /home/eric/Sync/hblink3_sms_dev/access_systems.txt -MY_SERVER_SHORTCUT: XYZ -SERVER_NAME: Test HBLink Network -USE_PUBLIC_APPS: True -PUBLIC_APPS_LIST: https://raw.githubusercontent.com/kf7eel/hblink_sms_external_apps/main/public_systems.txt -RULES_PATH: /home/eric/Sync/hblink3_sms_dev/rules.py - -# The following options are used for the dashboard. The dashboard is optional. -# Title of the Dashboard -DASHBOARD_TITLE: HBNet D-APRS Dashboard -# Used for API, RSS feed link, etc -DASHBOARD_URL: http://localhost:8092 - -# 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 +############################################################################### # OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS diff --git a/data_gateway.py b/data_gateway.py index ed5ab36..f9655d5 100644 --- a/data_gateway.py +++ b/data_gateway.py @@ -532,70 +532,77 @@ def aprs_send(packet): logger.info('Packet sent to APRS-IS.') def dashboard_loc_write(call, lat, lon, time, comment, dmr_id): - if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: - if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: - send_dash_loc(CONFIG, call, lat, lon, time, comment, dmr_id) - else: - dash_entries = ast.literal_eval(os.popen('cat ' + loc_file).read()) - dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time, 'comment':comment}) - # Clear old entries - list_index = 0 - call_count = 0 - new_dash_entries = [] - for i in dash_entries: - if i['call'] == call: - if call_count >= 25: - pass - else: - new_dash_entries.append(i) - call_count = call_count + 1 - - if call != i['call']: - new_dash_entries.append(i) - pass - list_index = list_index + 1 - with open(loc_file, 'w') as user_loc_file: - user_loc_file.write(str(new_dash_entries[:500])) - user_loc_file.close() - logger.info('User location saved for dashboard') - #logger.info(dash_entries) +## if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: + if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: + send_dash_loc(CONFIG, call, lat, lon, time, comment, dmr_id) + logger.info('Sent to web service/dashboard') else: - pass + logger.info('Web service/dashboard not enabled.') + +## dash_entries = ast.literal_eval(os.popen('cat ' + loc_file).read()) +## dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time, 'comment':comment}) +## # Clear old entries +## list_index = 0 +## call_count = 0 +## new_dash_entries = [] +## for i in dash_entries: +## if i['call'] == call: +## if call_count >= 25: +## pass +## else: +## new_dash_entries.append(i) +## call_count = call_count + 1 +## +## if call != i['call']: +## new_dash_entries.append(i) +## pass +## list_index = list_index + 1 +## with open(loc_file, 'w') as user_loc_file: +## user_loc_file.write(str(new_dash_entries[:500])) +## user_loc_file.close() +## logger.info('User location saved for dashboard') + #logger.info(dash_entries) +## else: +## pass def dashboard_bb_write(call, dmr_id, time, bulletin, system_name): - if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: - if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: - send_bb(CONFIG, call, dmr_id, bulletin, system_name) - else: - #try: - dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read()) - # except: - # dash_entries = [] - dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulletin':bulletin}) - with open(bb_file, 'w') as user_bb_file: - user_bb_file.write(str(dash_bb[:20])) - user_bb_file.close() - logger.info('User bulletin entry saved.') - #logger.info(dash_bb) +## if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: + if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: + send_bb(CONFIG, call, dmr_id, bulletin, system_name) else: - pass + logger.info('Web service/dashboard not enabled.') +## #try: +## dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read()) +## # except: +## # dash_entries = [] +## dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulletin':bulletin}) +## with open(bb_file, 'w') as user_bb_file: +## user_bb_file.write(str(dash_bb[:20])) +## user_bb_file.close() +## logger.info('User bulletin entry saved.') +## #logger.info(dash_bb) +## else: +## pass def dashboard_sms_write(snd_call, rcv_call, rcv_dmr_id, snd_dmr_id, sms, time, system_name): - if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: - if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: - send_sms_log(CONFIG, snd_call, rcv_call, sms, rcv_dmr_id, snd_dmr_id, system_name) - else: - #try: - dash_sms = ast.literal_eval(os.popen('cat ' + sms_file).read()) - # except: - # dash_entries = [] - dash_sms.insert(0, {'snd_call': snd_call, 'rcv_call':rcv_call, 'snd_dmr_id': snd_dmr_id, 'rcv_dmr_id':rcv_dmr_id, 'time': time, 'sms':sms}) - with open(sms_file, 'w') as user_sms_file: - user_sms_file.write(str(dash_sms[:25])) - user_sms_file.close() - logger.info('User SMS entry saved.') +## if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: + if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: + send_sms_log(CONFIG, snd_call, rcv_call, sms, rcv_dmr_id, snd_dmr_id, system_name) + logger.info('Web service/dashboard not enabled.') else: - pass + logger.info('Web service/dashboard not enabled.') + +## #try: +## dash_sms = ast.literal_eval(os.popen('cat ' + sms_file).read()) +## # except: +## # dash_entries = [] +## dash_sms.insert(0, {'snd_call': snd_call, 'rcv_call':rcv_call, 'snd_dmr_id': snd_dmr_id, 'rcv_dmr_id':rcv_dmr_id, 'time': time, 'sms':sms}) +## with open(sms_file, 'w') as user_sms_file: +## user_sms_file.write(str(dash_sms[:25])) +## user_sms_file.close() +## logger.info('User SMS entry saved.') +## else: +## pass def mailbox_write(call, dmr_id, time, message, recipient): diff --git a/data_gateway_config.py b/data_gateway_config.py index 4ab2bfd..6e908c9 100644 --- a/data_gateway_config.py +++ b/data_gateway_config.py @@ -167,7 +167,7 @@ def build_config(_config_file): elif section == 'DATA_CONFIG': CONFIG['DATA_CONFIG'].update({ - 'USE_DASHBOARD': config.getboolean(section, 'USE_DASHBOARD'), +## 'USE_DASHBOARD': config.getboolean(section, 'USE_DASHBOARD'), 'DATA_DMR_ID': config.get(section, 'DATA_DMR_ID'), 'USER_APRS_SSID': config.get(section, 'USER_APRS_SSID'), 'CALL_TYPE': config.get(section, 'CALL_TYPE'),