From c3f53b5eb7a27cf11d4a5fd8083db48fb6d0668d Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Thu, 5 Dec 2013 15:20:59 -0600 Subject: [PATCH] Fixed Keep-Alive While Transmitting Issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit repeaters don’t reply to keep alives while they are transmitting. Changed addes so that when voice packets are received, the keep-alive monitor is reset for that peer. --- dmrlink.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dmrlink.py b/dmrlink.py index 6dd53fe..7fb161b 100755 --- a/dmrlink.py +++ b/dmrlink.py @@ -470,6 +470,14 @@ class IPSC(DatagramProtocol): print('{} ({}) Unknown message type encountered\n\tPacket Type: {}\n\tFrom: {}' .format(_network, _packettype, _peerid)) print('\t', h(_data)) + # Reset the outstanding keep-alive counter for _peerid... + # Used when receiving acks OR when we see traffic from a repeater, since they ignore keep-alives when transmitting + # + def reset_keep_alive(self, _peerid): + if _peerid in self._peers.keys(): + self._peers[_peerid]['STATUS']['KEEP_ALIVES_OUTSTANDING'] = 0 + if _peerid == self._master['RADIO_ID']: + self._master_stat['KEEP_ALIVES_OUTSTANDING'] = 0 # Take a packet to be SENT, calculate auth hash and return the whole thing # @@ -642,11 +650,13 @@ class IPSC(DatagramProtocol): # User Voice and Data Call Types: if _packettype == GROUP_VOICE: + self.reset_keep_alive(_peerid) self._notify_event(self._network, 'group_voice', {'peer_id': int(h(_peerid), 16)}) self.group_voice(self._network, _src_sub, _dst_sub, _ts, _end, _peerid, data) return elif _packettype == PVT_VOICE: + self.reset_keep_alive(_peerid) self._notify_event(self._network, 'private_voice', {'peer_id': int(h(_peerid), 16)}) self.private_voice(self._network, _src_sub, _dst_sub, _ts, _end, _peerid, data) return @@ -717,8 +727,7 @@ class IPSC(DatagramProtocol): # Packets we receive... elif _packettype == PEER_ALIVE_REPLY: - if _peerid in self._peers.keys(): - self._peers[_peerid]['STATUS']['KEEP_ALIVES_OUTSTANDING'] = 0 + self.reset_keep_alive(_peerid) return elif _packettype == PEER_REG_REPLY: @@ -737,8 +746,7 @@ class IPSC(DatagramProtocol): return if _packettype == MASTER_ALIVE_REPLY: - # This action is so simple, it doesn't require a callback function, master is responding, we're good. - self._master_stat['KEEP_ALIVES_OUTSTANDING'] = 0 + self.reset_keep_alive(_peerid) return elif _packettype == PEER_LIST_REPLY: