Repeat and DMRD... working on it.
This commit is contained in:
parent
be71cd63d3
commit
739fc10a94
@ -76,6 +76,7 @@ def build_config(_config_file):
|
|||||||
# HomeBrew Master Configuration
|
# HomeBrew Master Configuration
|
||||||
CONFIG['MASTERS'].update({section: {
|
CONFIG['MASTERS'].update({section: {
|
||||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||||
|
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||||
'IP': gethostbyname(config.get(section, 'IP')),
|
'IP': gethostbyname(config.get(section, 'IP')),
|
||||||
'PORT': config.getint(section, 'PORT'),
|
'PORT': config.getint(section, 'PORT'),
|
||||||
'PASSPHRASE': config.get(section, 'PASSPHRASE')
|
'PASSPHRASE': config.get(section, 'PASSPHRASE')
|
||||||
|
@ -24,9 +24,11 @@ LOG_NAME: HBlink
|
|||||||
# IP may be left blank if there's one interface on your system.
|
# IP may be left blank if there's one interface on your system.
|
||||||
# Port should be the port you want this master to listen on. It must be unique
|
# Port should be the port you want this master to listen on. It must be unique
|
||||||
# and unused by anything else.
|
# and unused by anything else.
|
||||||
|
# Repeat - if True, the master repeats traffic to clients, False, it does nothing.
|
||||||
[MASTER-1]
|
[MASTER-1]
|
||||||
MODE: MASTER
|
MODE: MASTER
|
||||||
ENABLED: True
|
ENABLED: True
|
||||||
|
REPEAT: True
|
||||||
IP:
|
IP:
|
||||||
PORT: 54000
|
PORT: 54000
|
||||||
PASSPHRASE: s3cr37w0rd
|
PASSPHRASE: s3cr37w0rd
|
||||||
|
32
hblink.py
32
hblink.py
@ -139,22 +139,24 @@ class HBMASTER(DatagramProtocol):
|
|||||||
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
||||||
#logger.debug('(%s) TX Packet to %s on port %s: %s', self._client, self._config['MASTER_IP'], self._config['MASTER_PORT'], h(_packet))
|
#logger.debug('(%s) TX Packet to %s on port %s: %s', self._client, self._config['MASTER_IP'], self._config['MASTER_PORT'], h(_packet))
|
||||||
|
|
||||||
def dmrd_received(self, _radio_id, _data):
|
def dmrd_received(self, _data):
|
||||||
pass
|
pass
|
||||||
|
'''
|
||||||
|
if self._config['REPEAT'] == True:
|
||||||
|
for _client in self._clients:
|
||||||
|
if _client != _radio_id:
|
||||||
|
self.send_packet(_client, _data)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
'''
|
||||||
|
|
||||||
def datagramReceived(self, _data, (_host, _port)):
|
def datagramReceived(self, _data, (_host, _port)):
|
||||||
# Extract the command, which is various length, all but one 4 significant characters -- RPTCL
|
# Extract the command, which is various length, all but one 4 significant characters -- RPTCL
|
||||||
_command = _data[:4]
|
_command = _data[:4]
|
||||||
|
|
||||||
if _command == 'DMRD': # DMRData -- encapsulated DMR data frame
|
if _command == 'DMRD': # DMRData -- encapsulated DMR data frame
|
||||||
_radio_id = _data[4:8]
|
|
||||||
if _radio_id in self._clients \
|
|
||||||
and self._clients[_radio_id]['IP'] == _host \
|
|
||||||
and self._clients[_radio_id]['PORT'] == _port:
|
|
||||||
logger.debug('(%s) DMRD Received', self._master)
|
logger.debug('(%s) DMRD Received', self._master)
|
||||||
self.dmrd_received(_radio_id, _data)
|
self.dmrd_received(_data)
|
||||||
else:
|
|
||||||
logger.warning('(%s) DMRD packet recieved from an invalid client')
|
|
||||||
|
|
||||||
elif _command == 'RPTL': # RPTLogin -- a repeater wants to login
|
elif _command == 'RPTL': # RPTLogin -- a repeater wants to login
|
||||||
_radio_id = _data[4:8]
|
_radio_id = _data[4:8]
|
||||||
@ -262,7 +264,7 @@ class HBMASTER(DatagramProtocol):
|
|||||||
and self._clients[_radio_id]['PORT'] == _port:
|
and self._clients[_radio_id]['PORT'] == _port:
|
||||||
self._clients['LAST_PING'] = time()
|
self._clients['LAST_PING'] = time()
|
||||||
self.send_packet(_radio_id, 'MSTPONG'+_radio_id)
|
self.send_packet(_radio_id, 'MSTPONG'+_radio_id)
|
||||||
logger.info('(%s) Received and answered RPTPING from client %s', self._master, h(_radio_id))
|
logger.debug('(%s) Received and answered RPTPING from client %s', self._master, h(_radio_id))
|
||||||
else:
|
else:
|
||||||
self.transport.write('MSTNAK'+_radio_id, (_host, _port))
|
self.transport.write('MSTNAK'+_radio_id, (_host, _port))
|
||||||
logger.warning('(%s) Client info from Radio ID that has not logged in: %s', self._master, h(_radio_id))
|
logger.warning('(%s) Client info from Radio ID that has not logged in: %s', self._master, h(_radio_id))
|
||||||
@ -303,14 +305,14 @@ class HBCLIENT(DatagramProtocol):
|
|||||||
if self._stats['CONNECTION'] == 'YES':
|
if self._stats['CONNECTION'] == 'YES':
|
||||||
self.send_packet('RPTPING'+self._config['RADIO_ID'])
|
self.send_packet('RPTPING'+self._config['RADIO_ID'])
|
||||||
self._stats['PINGS_SENT'] += 1
|
self._stats['PINGS_SENT'] += 1
|
||||||
logger.info('(%s) RPTPING Sent to Master. Pings Since Connected: %s', self._client, self._stats['PINGS_SENT'])
|
logger.debug('(%s) RPTPING Sent to Master. Pings Since Connected: %s', self._client, self._stats['PINGS_SENT'])
|
||||||
|
|
||||||
def send_packet(self, _packet):
|
def send_packet(self, _packet):
|
||||||
self.transport.write(_packet, (self._config['MASTER_IP'], self._config['MASTER_PORT']))
|
self.transport.write(_packet, (self._config['MASTER_IP'], self._config['MASTER_PORT']))
|
||||||
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
||||||
#logger.debug('(%s) TX Packet to %s on port %s: %s', self._client, self._config['MASTER_IP'], self._config['MASTER_PORT'], h(_packet))
|
#logger.debug('(%s) TX Packet to %s on port %s: %s', self._client, self._config['MASTER_IP'], self._config['MASTER_PORT'], h(_packet))
|
||||||
|
|
||||||
def dmrd_received(self, _radio_id, _data):
|
def dmrd_received(self, _data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def datagramReceived(self, _data, (_host, _port)):
|
def datagramReceived(self, _data, (_host, _port)):
|
||||||
@ -319,15 +321,13 @@ class HBCLIENT(DatagramProtocol):
|
|||||||
# Extract the command, which is various length, but only 4 significant characters
|
# Extract the command, which is various length, but only 4 significant characters
|
||||||
_command = _data[:4]
|
_command = _data[:4]
|
||||||
if _command == 'DMRD': # DMRData -- encapsulated DMR data frame
|
if _command == 'DMRD': # DMRData -- encapsulated DMR data frame
|
||||||
_radio_id = _data[4:8]
|
|
||||||
if self._config['RADIO_ID'] == _radio_id: # Check to ensure this packet is meant for us
|
|
||||||
logger.debug('(%s) DMRD Received', self._client)
|
logger.debug('(%s) DMRD Received', self._client)
|
||||||
self.dmrd_received(_radio_id, _data)
|
self.dmrd_received(_data)
|
||||||
|
|
||||||
elif _command == 'MSTN': # Actually MSTNAK -- a NACK from the master
|
elif _command == 'MSTN': # Actually MSTNAK -- a NACK from the master
|
||||||
_radio_id = _data[4:8]
|
_radio_id = _data[4:8]
|
||||||
if self._config['RADIO_ID'] == _radio_id: # Check to ensure this packet is meant for us
|
if self._config['RADIO_ID'] == _radio_id: # Check to ensure this packet is meant for us
|
||||||
logger.info('(%s) MSTNAK Received', self._client)
|
logger.warning('(%s) MSTNAK Received', self._client)
|
||||||
self._stats['CONNECTION'] = 'NO' # Disconnect ourselves and re-register
|
self._stats['CONNECTION'] = 'NO' # Disconnect ourselves and re-register
|
||||||
|
|
||||||
elif _command == 'RPTA': # Actually RPTACK -- an ACK from the master
|
elif _command == 'RPTA': # Actually RPTACK -- an ACK from the master
|
||||||
@ -378,7 +378,7 @@ class HBCLIENT(DatagramProtocol):
|
|||||||
elif _command == 'MSTP': # Actually MSTPONG -- a reply to RPTPING (send by client)
|
elif _command == 'MSTP': # Actually MSTPONG -- a reply to RPTPING (send by client)
|
||||||
if _data [7:11] == self._config['RADIO_ID']:
|
if _data [7:11] == self._config['RADIO_ID']:
|
||||||
self._stats['PINGS_ACKD'] += 1
|
self._stats['PINGS_ACKD'] += 1
|
||||||
logger.info('(%s) MSTPONG Received. Pongs Since Connected: %s', self._client, self._stats['PINGS_ACKD'])
|
logger.debug('(%s) MSTPONG Received. Pongs Since Connected: %s', self._client, self._stats['PINGS_ACKD'])
|
||||||
|
|
||||||
elif _command == 'MSTC': # Actually MSTCL -- notify us the master is closing down
|
elif _command == 'MSTC': # Actually MSTCL -- notify us the master is closing down
|
||||||
if _data[5:9] == self._config['RADIO_ID']:
|
if _data[5:9] == self._config['RADIO_ID']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user