Removed timers, add disconnect/reconnect to make the conntion more reliable

This commit is contained in:
Andy Taylor 2019-06-19 15:03:29 +00:00
parent bce4e01775
commit 02c605dab7

View File

@ -33,7 +33,7 @@ from binascii import a2b_hex as bhex
from random import randint from random import randint
from hashlib import sha256, sha1 from hashlib import sha256, sha1
from hmac import new as hmac_new, compare_digest from hmac import new as hmac_new, compare_digest
from time import time, sleep from time import time
from collections import deque from collections import deque
# Twisted is pretty important, so I keep it separate # Twisted is pretty important, so I keep it separate
@ -296,7 +296,6 @@ class HBSYSTEM(DatagramProtocol):
xlx3 = xlx.to_bytes(3, 'big') xlx3 = xlx.to_bytes(3, 'big')
streamid = randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big') streamid = randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')
# Wait for .5 secs for the XLX to log us in # Wait for .5 secs for the XLX to log us in
sleep(.500)
for packetnr in range(5): for packetnr in range(5):
if packetnr < 3: if packetnr < 3:
# First 3 packets, voice start, stream type e1 # First 3 packets, voice start, stream type e1
@ -309,7 +308,6 @@ class HBSYSTEM(DatagramProtocol):
packetnr1 = packetnr.to_bytes(1, 'big') packetnr1 = packetnr.to_bytes(1, 'big')
strmtype1 = strmtype.to_bytes(1, 'big') strmtype1 = strmtype.to_bytes(1, 'big')
_packet = b''.join([DMRD, packetnr1, radio3, xlx3, radio4, strmtype1, streamid, payload]) _packet = b''.join([DMRD, packetnr1, radio3, xlx3, radio4, strmtype1, streamid, payload])
sleep(.100)
self.transport.write(_packet, mastersock) self.transport.write(_packet, mastersock)
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!! # KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
#logger.debug('(%s) XLX Module Change Packet: %s', self._system, ahex(_packet)) #logger.debug('(%s) XLX Module Change Packet: %s', self._system, ahex(_packet))
@ -665,6 +663,7 @@ class HBSYSTEM(DatagramProtocol):
logger.info('(%s) Connection to Master Completed', self._system) logger.info('(%s) Connection to Master Completed', self._system)
# If we are an XLX, send the XLX module request here. # If we are an XLX, send the XLX module request here.
if self._config['MODE'] == 'XLXPEER': if self._config['MODE'] == 'XLXPEER':
self.send_xlxmaster(self._config['RADIO_ID'], int(4000), self._config['MASTER_SOCKADDR'])
self.send_xlxmaster(self._config['RADIO_ID'], self._config['XLXMODULE'], self._config['MASTER_SOCKADDR']) self.send_xlxmaster(self._config['RADIO_ID'], self._config['XLXMODULE'], self._config['MASTER_SOCKADDR'])
logger.info('(%s) Sending XLX Module request', self._system) logger.info('(%s) Sending XLX Module request', self._system)
else: else: