From 4fd6c8b60012f25a96a5f539064210ef58326d96 Mon Sep 17 00:00:00 2001
From: Cort Buffington <n0mjs@me.com>
Date: Wed, 20 Jun 2018 15:41:37 -0500
Subject: [PATCH] add triggering features of DMRlink version
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

add resets, timeslot specification and not taking actions if they don’t
change anything.
---
 hb_confbridge.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hb_confbridge.py b/hb_confbridge.py
index fc5688f..309a02a 100755
--- a/hb_confbridge.py
+++ b/hb_confbridge.py
@@ -379,12 +379,12 @@ class routerSYSTEM(HBSYSTEM):
                                         self._logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
                                         # Cancel the timer if we've enabled an "OFF" type timeout
                                         if _system['TO_TYPE'] == 'OFF':
-                                            _system['TIMER'] = now
+                                            _system['TIMER'] = pkt_time
                                             self._logger.info('(%s) Bridge: %s set to "OFF" with an on timer rule: timeout timer cancelled', self._system, _bridge)
                                 # Reset the timer for the rule
                                 if _system['ACTIVE'] == True and _system['TO_TYPE'] == 'ON':
-                                    _system['TIMER'] = now + _system['TIMEOUT']
-                                    self._logger.info('(%s) Bridge: %s, timeout timer reset to: %s', self._system, _bridge, _system['TIMER'] - now)
+                                    _system['TIMER'] = pkt_time + _system['TIMEOUT']
+                                    self._logger.info('(%s) Bridge: %s, timeout timer reset to: %s', self._system, _bridge, _system['TIMER'] - pkt_time)
                         
                             # TGID matches an DE-ACTIVATION trigger
                             if (_dst_id in _system['OFF']  or _dst_id in _system['RESET']) and _slot == _system['TS']:
@@ -395,15 +395,15 @@ class routerSYSTEM(HBSYSTEM):
                                         self._logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
                                         # Cancel the timer if we've enabled an "ON" type timeout
                                         if _system['TO_TYPE'] == 'ON':
-                                            _system['TIMER'] = now
+                                            _system['TIMER'] = pkt_time
                                             self._logger.info('(%s) Bridge: %s set to ON with and "OFF" timer rule: timeout timer cancelled', self._system, _bridge)
                                 # Reset the timer for the rule
                                 if _system['ACTIVE'] == False and _system['TO_TYPE'] == 'OFF':
-                                    _system['TIMER'] = now + _system['TIMEOUT']
-                                    self._logger.info('(%s) Bridge: %s, timeout timer reset to: %s', self._system, _bridge, _system['TIMER'] - now)
+                                    _system['TIMER'] = pkt_time + _system['TIMEOUT']
+                                    self._logger.info('(%s) Bridge: %s, timeout timer reset to: %s', self._system, _bridge, _system['TIMER'] - pkt_time)
                                 # Cancel the timer if we've enabled an "ON" type timeout
                                 if _system['ACTIVE'] == True and _system['TO_TYPE'] == 'ON' and _dst_group in _system['OFF']:
-                                    _system['TIMER'] = now
+                                    _system['TIMER'] = pkt_time
                                     self._logger.info('(%s) Bridge: %s set to ON with and "OFF" timer rule: timeout timer cancelled', self._system, _bridge)
 
             #