improve APRS per master config
This commit is contained in:
parent
cae4ad03d8
commit
88a791ee7b
@ -42,7 +42,7 @@ from twisted.protocols.basic import NetstringReceiver
|
|||||||
from twisted.internet import reactor, task
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
# Things we import from the main hblink module
|
# Things we import from the main hblink module
|
||||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
|
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases, aprs_upload
|
||||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||||
from dmr_utils3 import decode, bptc, const
|
from dmr_utils3 import decode, bptc, const
|
||||||
import config
|
import config
|
||||||
@ -1183,6 +1183,8 @@ if __name__ == '__main__':
|
|||||||
logger.info('(REPORT) TCP Socket reporting not configured')
|
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||||
|
|
||||||
# HBlink instance creation
|
# HBlink instance creation
|
||||||
|
# Run aprs_upload loop
|
||||||
|
aprs_upload()
|
||||||
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
|
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
|
||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
|
@ -46,7 +46,7 @@ from twisted.protocols.basic import NetstringReceiver
|
|||||||
from twisted.internet import reactor, task
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
# Things we import from the main hblink module
|
# Things we import from the main hblink module
|
||||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases, acl_check
|
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases, acl_check, aprs_upload
|
||||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||||
from dmr_utils3 import decode, bptc, const
|
from dmr_utils3 import decode, bptc, const
|
||||||
import config
|
import config
|
||||||
@ -281,6 +281,8 @@ if __name__ == '__main__':
|
|||||||
report_server = config_reports(CONFIG, reportFactory)
|
report_server = config_reports(CONFIG, reportFactory)
|
||||||
|
|
||||||
# HBlink instance creation
|
# HBlink instance creation
|
||||||
|
# Run aprs_upload loop
|
||||||
|
aprs_upload()
|
||||||
logger.info('HBlink \'bridge_all.py\' -- SYSTEM STARTING...')
|
logger.info('HBlink \'bridge_all.py\' -- SYSTEM STARTING...')
|
||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
|
@ -280,7 +280,7 @@ def build_config(_config_file):
|
|||||||
CONFIG['SYSTEMS'].update({section: {
|
CONFIG['SYSTEMS'].update({section: {
|
||||||
'MODE': config.get(section, 'MODE'),
|
'MODE': config.get(section, 'MODE'),
|
||||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||||
'APRS_ENABLED': config.getboolean(section, 'APRS_ENABLED'),
|
'APRS': config.getboolean(section, 'APRS'),
|
||||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||||
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
||||||
'IP': gethostbyname(config.get(section, 'IP')),
|
'IP': gethostbyname(config.get(section, 'IP')),
|
||||||
|
@ -167,7 +167,7 @@ TGID_ACL: PERMIT:ALL
|
|||||||
[MASTER-1]
|
[MASTER-1]
|
||||||
MODE: MASTER
|
MODE: MASTER
|
||||||
ENABLED: True
|
ENABLED: True
|
||||||
APRS_ENABLED: False
|
APRS: False
|
||||||
REPEAT: True
|
REPEAT: True
|
||||||
MAX_PEERS: 10
|
MAX_PEERS: 10
|
||||||
EXPORT_AMBE: False
|
EXPORT_AMBE: False
|
||||||
|
28
hblink.py
28
hblink.py
@ -74,10 +74,12 @@ systems = {}
|
|||||||
|
|
||||||
open("nom_aprs","w").close
|
open("nom_aprs","w").close
|
||||||
|
|
||||||
file_config=config.build_config('hblink.cfg')
|
#file_config=config.build_config('hblink.cfg')
|
||||||
|
|
||||||
|
CONFIG = ''
|
||||||
|
|
||||||
def sendAprs():
|
def sendAprs():
|
||||||
AIS = aprslib.IS(str(file_config['APRS']['CALLSIGN']), passwd=aprslib.passcode(str(file_config['APRS']['CALLSIGN'])), host=str(file_config['APRS']['SERVER']), port=14580)
|
AIS = aprslib.IS(str(CONFIG['APRS']['CALLSIGN']), passwd=aprslib.passcode(str(CONFIG['APRS']['CALLSIGN'])), host=str(CONFIG['APRS']['SERVER']), port=14580)
|
||||||
AIS.connect()
|
AIS.connect()
|
||||||
f = open('nom_aprs', 'r')
|
f = open('nom_aprs', 'r')
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
@ -141,16 +143,14 @@ def sendAprs():
|
|||||||
rx_utile = dati[2][0:3]+'.'+dati[2][3:]
|
rx_utile = dati[2][0:3]+'.'+dati[2][3:]
|
||||||
tx_utile = dati[3][0:3]+'.'+dati[3][3:]
|
tx_utile = dati[3][0:3]+'.'+dati[3][3:]
|
||||||
|
|
||||||
if self._config['APRS']['ENABLED']:
|
AIS.sendall(str(dati[0])+">APRS,TCPIP*,qAC,"+str(CONFIG['APRS']['CALLSIGN'])+":!"+str(lat_utile)[:-2]+lat_verso+"/"+str(lon_utile)[:-1]+lon_verso+"r"+str(CONFIG['APRS']['MESSAGE'])+' RX: '+str(rx_utile)+' TX: '+str(tx_utile))
|
||||||
AIS.sendall(str(dati[0])+">APRS,TCPIP*,qAC,"+str(file_config['APRS']['CALLSIGN'])+":!"+str(lat_utile)[:-2]+lat_verso+"/"+str(lon_utile)[:-1]+lon_verso+"r"+str(file_config['APRS']['MESSAGE'])+' RX: '+str(rx_utile)+' TX: '+str(tx_utile))
|
logging.info('APRS INVIATO/APRS Sent')
|
||||||
logging.info('APRS INVIATO/APRS Sent')
|
|
||||||
else:
|
def aprs_upload():
|
||||||
pass
|
if CONFIG['APRS']['ENABLED']:
|
||||||
|
if int(CONFIG['APRS']['REPORT_INTERVAL']) >= 10:
|
||||||
if file_config['APRS']['ENABLED']:
|
|
||||||
if int(file_config['APRS']['REPORT_INTERVAL']) >= 10:
|
|
||||||
l=task.LoopingCall(sendAprs)
|
l=task.LoopingCall(sendAprs)
|
||||||
l.start(int(file_config['APRS']['REPORT_INTERVAL'])*60)
|
l.start(int(CONFIG['APRS']['REPORT_INTERVAL'])*60)
|
||||||
else:
|
else:
|
||||||
l=task.LoopingCall(sendAprs)
|
l=task.LoopingCall(sendAprs)
|
||||||
l.start(15*60)
|
l.start(15*60)
|
||||||
@ -568,7 +568,7 @@ class HBSYSTEM(DatagramProtocol):
|
|||||||
and self._peers[_peer_id]['SOCKADDR'] == _sockaddr:
|
and self._peers[_peer_id]['SOCKADDR'] == _sockaddr:
|
||||||
logger.info('(%s) Peer is closing down: %s (%s)', self._system, self._peers[_peer_id]['CALLSIGN'], int_id(_peer_id))
|
logger.info('(%s) Peer is closing down: %s (%s)', self._system, self._peers[_peer_id]['CALLSIGN'], int_id(_peer_id))
|
||||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||||
if self._CONFIG['APRS']['ENABLED']:
|
if self._CONFIG['SYSTEMS'][self._system]['APRS']:
|
||||||
#if self._config['APRS_ENABLED'] == True:
|
#if self._config['APRS_ENABLED'] == True:
|
||||||
fn = 'nom_aprs'
|
fn = 'nom_aprs'
|
||||||
f = open(fn)
|
f = open(fn)
|
||||||
@ -612,7 +612,7 @@ class HBSYSTEM(DatagramProtocol):
|
|||||||
lista_blocco=['ysf', 'xlx', 'nxdn', 'dstar', 'echolink','p25', 'svx', 'l1nk']
|
lista_blocco=['ysf', 'xlx', 'nxdn', 'dstar', 'echolink','p25', 'svx', 'l1nk']
|
||||||
#if self._CONFIG['SYSTEMS']['APRS_ENABLED']['ENABLED'] and self._CONFIG['APRS']['ENABLED'] and not str(_this_peer['CALLSIGN'].decode('UTF-8')).replace(' ', '').isalpha() :
|
#if self._CONFIG['SYSTEMS']['APRS_ENABLED']['ENABLED'] and self._CONFIG['APRS']['ENABLED'] and not str(_this_peer['CALLSIGN'].decode('UTF-8')).replace(' ', '').isalpha() :
|
||||||
# Check if master has APRS enabled instead of global.
|
# Check if master has APRS enabled instead of global.
|
||||||
if self._CONFIG['APRS']['ENABLED'] and not str(_this_peer['CALLSIGN'].decode('UTF-8')).replace(' ', '').isalpha() :
|
if self._CONFIG['SYSTEMS'][self._system]['APRS'] and not str(_this_peer['CALLSIGN'].decode('UTF-8')).replace(' ', '').isalpha() :
|
||||||
file = open("nom_aprs","r")
|
file = open("nom_aprs","r")
|
||||||
linee = file.readlines()
|
linee = file.readlines()
|
||||||
file.close()
|
file.close()
|
||||||
@ -962,6 +962,8 @@ if __name__ == '__main__':
|
|||||||
logger.info('(REPORT) TCP Socket reporting not configured')
|
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||||
|
|
||||||
# HBlink instance creation
|
# HBlink instance creation
|
||||||
|
# Run aprs_upload loop
|
||||||
|
aprs_upload()
|
||||||
logger.info('(GLOBAL) HBlink \'HBlink.py\' -- SYSTEM STARTING...')
|
logger.info('(GLOBAL) HBlink \'HBlink.py\' -- SYSTEM STARTING...')
|
||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
|
Loading…
Reference in New Issue
Block a user