From 76ad6adea4caee9ee64989bbc0e7a5cd8cbb925c Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 11 Dec 2020 12:47:43 -0800 Subject: [PATCH] add APRS beacon script for gps_data --- config.py | 6 ++++ gps_data-SAMPLE.cfg | 11 ++++++-- gps_data.py | 2 ++ gps_data_igate_beacon.py | 60 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 gps_data_igate_beacon.py diff --git a/config.py b/config.py index 9390b40..f839be8 100755 --- a/config.py +++ b/config.py @@ -152,6 +152,12 @@ def build_config(_config_file): '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' diff --git a/gps_data-SAMPLE.cfg b/gps_data-SAMPLE.cfg index 40527ea..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 diff --git a/gps_data.py b/gps_data.py index 9c38249..0d783a7 100644 --- a/gps_data.py +++ b/gps_data.py @@ -379,6 +379,8 @@ class DATA_SYSTEM(HBSYSTEM): # End APRS-IS upload # Assume this is an SMS message if '$GPRMC' not in final_packet: + if '0005' in hdr_start: + logger('This may be an NMEA coded packet from an MD-380!') # Revisit below later. #### # Motorola type SMS header 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']))