Skip to content

Commit 67a9a0c

Browse files
authored
Enable watchdog based on protocol version. (#77)
1 parent a5eb0d4 commit 67a9a0c

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

tests/test_application.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,23 @@ async def test_form_network(app):
182182
assert app._api.device_state.call_count == 10
183183

184184

185+
@pytest.mark.parametrize(
186+
"protocol_ver, watchdog_cc",
187+
[
188+
(0x0107, False,),
189+
(0x0108, True, ),
190+
(0x010B, True, ),
191+
],
192+
)
185193
@pytest.mark.asyncio
186-
async def test_startup(app, monkeypatch, version=0):
194+
async def test_startup(protocol_ver, watchdog_cc, app, monkeypatch, version=0):
187195

188196
async def _version():
197+
app._api._proto_ver = protocol_ver
189198
return version
190199

200+
app._reset_watchdog = mock.MagicMock(
201+
side_effect=asyncio.coroutine(mock.MagicMock()))
191202
app.form_network = mock.MagicMock(
192203
side_effect=asyncio.coroutine(mock.MagicMock()))
193204
app._api._command = mock.MagicMock(
@@ -203,6 +214,7 @@ async def _version():
203214
monkeypatch.setattr(application.ConBeeDevice, 'new', new_mock)
204215
await app.startup(auto_form=False)
205216
assert app.form_network.call_count == 0
217+
assert app._reset_watchdog.call_count == watchdog_cc
206218
await app.startup(auto_form=True)
207219
assert app.form_network.call_count == 1
208220

zigpy_deconz/api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ def __init__(self):
149149
self._proto_ver = None
150150
self._aps_data_ind_flags = 0x01
151151

152+
@property
153+
def protocol_version(self):
154+
"""Protocol Version."""
155+
return self._proto_ver
156+
152157
def set_application(self, app):
153158
self._app = app
154159

@@ -268,7 +273,8 @@ def _handle_write_parameter(self, data):
268273
async def version(self):
269274
self._proto_ver = await self[NetworkParameter.protocol_version]
270275
version = await self._command(Command.version)
271-
if self._proto_ver >= MIN_PROTO_VERSION and (version[0] & 0x0000FF00) == 0x00000500:
276+
if self.protocol_version >= MIN_PROTO_VERSION and \
277+
(version[0] & 0x0000FF00) == 0x00000500:
272278
self._aps_data_ind_flags = 0x04
273279
return version[0]
274280

zigpy_deconz/zigbee/application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
CHANGE_NETWORK_WAIT = 1
1818
SEND_CONFIRM_TIMEOUT = 60
19+
PROTO_VER_WATCHDOG = 0x0108
1920

2021

2122
class ControllerApplication(zigpy.application.ControllerApplication):
@@ -57,7 +58,7 @@ async def startup(self, auto_form=False):
5758
await self._api[NetworkParameter.nwk_update_id]
5859
self._api[NetworkParameter.aps_designed_coordinator] = 1
5960

60-
if self.version > 0x261f0500:
61+
if self._api.protocol_version >= PROTO_VER_WATCHDOG:
6162
asyncio.ensure_future(self._reset_watchdog())
6263

6364
if auto_form:

0 commit comments

Comments
 (0)