From a2c782cef55271ef49c725de411e5be217682c97 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 11 Dec 2020 12:52:25 -0800 Subject: [PATCH] add APRS beacon script for gps_data --- config.py | 49 ++++++++++++++------------------ gps_data-SAMPLE.cfg | 12 ++++++-- gps_data.py | 1 - gps_data_igate_beacon.py | 60 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 32 deletions(-) create mode 100644 gps_data_igate_beacon.py diff --git a/config.py b/config.py index c1cba86..f839be8 100644 --- a/config.py +++ b/config.py @@ -26,9 +26,6 @@ updated if the items in the main configuraiton file (usually hblink.cfg) change. ''' -# Added config option for APRS in the master config section -# Modified by KF7EEL - 10-15-2020 - import configparser import sys import const @@ -107,10 +104,9 @@ def build_config(_config_file): CONFIG = {} CONFIG['GLOBAL'] = {} - CONFIG['APRS'] = {} - CONFIG['GPS_DATA'] = {} CONFIG['REPORTS'] = {} CONFIG['LOGGER'] = {} + CONFIG['GPS_DATA'] = {} CONFIG['ALIASES'] = {} CONFIG['SYSTEMS'] = {} @@ -127,27 +123,6 @@ def build_config(_config_file): 'TG1_ACL': config.get(section, 'TGID_TS1_ACL'), 'TG2_ACL': config.get(section, 'TGID_TS2_ACL') }) - - 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 section == 'GPS_DATA': - CONFIG['GPS_DATA'].update({ - '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'), - 'USER_APRS_COMMENT': config.get(section, 'USER_APRS_COMMENT'), - 'APRS_LOGIN_CALL': config.get(section, 'APRS_LOGIN_CALL'), - 'APRS_LOGIN_PASSCODE': config.get(section, 'APRS_LOGIN_PASSCODE'), - 'APRS_SERVER': config.get(section, 'APRS_SERVER'), - 'APRS_PORT': config.get(section, 'APRS_PORT'), - }) elif section == 'REPORTS': CONFIG['REPORTS'].update({ @@ -167,6 +142,26 @@ def build_config(_config_file): if not CONFIG['LOGGER']['LOG_FILE']: CONFIG['LOGGER']['LOG_FILE'] = '/dev/null' + elif section == 'GPS_DATA': + CONFIG['GPS_DATA'].update({ + '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'), + 'USER_APRS_COMMENT': config.get(section, 'USER_APRS_COMMENT'), + 'APRS_LOGIN_CALL': config.get(section, 'APRS_LOGIN_CALL'), + 'APRS_LOGIN_PASSCODE': config.get(section, 'APRS_LOGIN_PASSCODE'), + 'APRS_SERVER': config.get(section, 'APRS_SERVER'), + 'APRS_PORT': config.get(section, 'APRS_PORT'), + 'IGATE_BEACON_TIME': config.get(section, 'IGATE_BEACON_TIME'), + 'IGATE_BEACON_ICON': config.get(section, 'IGATE_BEACON_ICON'), + 'IGATE_BEACON_COMMENT': config.get(section, 'IGATE_BEACON_COMMENT'), + 'IGATE_LATITUDE': config.get(section, 'IGATE_LATITUDE'), + 'IGATE_LONGITUDE': config.get(section, 'IGATE_LONGITUDE'), + + }) + if not CONFIG['LOGGER']['LOG_FILE']: + CONFIG['LOGGER']['LOG_FILE'] = '/dev/null' + elif section == 'ALIASES': CONFIG['ALIASES'].update({ 'TRY_DOWNLOAD': config.getboolean(section, 'TRY_DOWNLOAD'), @@ -275,7 +270,6 @@ def build_config(_config_file): CONFIG['SYSTEMS'].update({section: { 'MODE': config.get(section, 'MODE'), 'ENABLED': config.getboolean(section, 'ENABLED'), - 'APRS_ENABLED': config.getboolean(section, 'APRS_ENABLED'), 'REPEAT': config.getboolean(section, 'REPEAT'), 'MAX_PEERS': config.getint(section, 'MAX_PEERS'), 'IP': gethostbyname(config.get(section, 'IP')), @@ -349,4 +343,3 @@ if __name__ == '__main__': return not _acl[0] print(acl_check(b'\x00\x01\x37', CONFIG['GLOBAL']['TG1_ACL'])) - diff --git a/gps_data-SAMPLE.cfg b/gps_data-SAMPLE.cfg index 46eb93b..337558a 100644 --- a/gps_data-SAMPLE.cfg +++ b/gps_data-SAMPLE.cfg @@ -118,12 +118,19 @@ STALE_DAYS: 1 DATA_DMR_ID: 9099 CALL_TYPE: unit USER_APRS_SSID: 15 -USER_APRS_COMMENT: HBLink3 GPS Decode - +USER_APRS_COMMENT: HBLink3 D-APRS - APRS_LOGIN_CALL: N0CALL APRS_LOGIN_PASSCODE: 12345 APRS_SERVER: rotate.aprs2.net APRS_PORT: 14580 - +# 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. +IGATE_BEACON_TIME = 45 +IGATE_BEACON_COMMENT = HBLink3 D-APRS Gateway +IGATE_BEACON_ICON = /I +IGATE_LATITUDE = 0000.00N +IGATE_LONGITUDE = 00000.00W # OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS # OpenBridge is a protocol originall created by DMR+ for connection between an @@ -176,7 +183,6 @@ APRS_PORT: 14580 MODE: MASTER ENABLED: False REPEAT: True -APRS_ENABLED: True MAX_PEERS: 10 EXPORT_AMBE: False IP: diff --git a/gps_data.py b/gps_data.py index 20c8cdc..1360115 100644 --- a/gps_data.py +++ b/gps_data.py @@ -382,7 +382,6 @@ class DATA_SYSTEM(HBSYSTEM): if '$GPRMC' not in final_packet: if '0005' in hdr_start: logger('This may be an NMEA coded packet from an MD-380 type radio!') - # Revisit below later. #### # Motorola type SMS header ## if '824a' in hdr_start or '024a' in hdr_start: diff --git a/gps_data_igate_beacon.py b/gps_data_igate_beacon.py new file mode 100644 index 0000000..234f474 --- /dev/null +++ b/gps_data_igate_beacon.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +############################################################################### +# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS +# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL +# +# 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 +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +############################################################################### + +''' +This script uploads a beacon to APRS-IS for the GPS/Data Application itself, cuasing it to appear as an igate +an aprs.fi. +''' + +import aprslib +import argparse +import os +import config +import time + +parser = argparse.ArgumentParser() +parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)') +cli_args = parser.parse_args() + +if not cli_args.CONFIG_FILE: + cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/gps_data.cfg' +CONFIG = config.build_config(cli_args.CONFIG_FILE) + +print(''' +GPS/Data Application Beacon Script by Eric, KF7EEL. https://github.com/kf7eel/hblink3 \n +This script will upload an APRS position for the GPS/Data Application. This usually causes most APRS-IS clients to see the GPS/Data Application +as an i-gate. \n +Using the following setting to upload beacon.\n +Callsign: ''' + CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + ''' - Position comment: ''' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT'] + ''' +Beacon time: ''' + CONFIG['GPS_DATA']['IGATE_BEACON_TIME'] + ''' +''') + +beacon_packet = CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + '>APHBL3,TCPIP*:!' + CONFIG['GPS_DATA']['IGATE_LATITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][0]) + CONFIG['GPS_DATA']['IGATE_LONGITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][1]) + '/' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT'] +#print(beacon_packet) +AIS = aprslib.IS(CONFIG['GPS_DATA']['APRS_LOGIN_CALL'], passwd=CONFIG['GPS_DATA']['APRS_LOGIN_PASSCODE'],host=CONFIG['GPS_DATA']['APRS_SERVER'], port=CONFIG['GPS_DATA']['APRS_PORT']) + +while int(CONFIG['GPS_DATA']['IGATE_BEACON_TIME']) > 15: + + AIS.connect() + AIS.sendall(beacon_packet) + print(beacon_packet) + AIS.close() + time.sleep(int(CONFIG['GPS_DATA']['IGATE_BEACON_TIME']))