add APRS beacon script for gps_data

This commit is contained in:
KF7EEL 2020-12-11 12:52:25 -08:00
parent ec783b210b
commit a2c782cef5
4 changed files with 90 additions and 32 deletions

View File

@ -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']))

View File

@ -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:

View File

@ -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:

60
gps_data_igate_beacon.py Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env python
#
###############################################################################
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
#
# 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']))