Skip to content

Commit

Permalink
Fix watchdog reset counter (#609)
Browse files Browse the repository at this point in the history
* Fix watchdog reset counter

* change comparison

* update test
  • Loading branch information
dmulcahey authored Feb 4, 2024
1 parent d3ba62e commit 1c43536
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,10 +1018,10 @@ async def _watchdog_feed(self):
LOGGER.warning("Watchdog heartbeat timeout: %s", repr(exc))
self._watchdog_failures += 1
if self._watchdog_failures > MAX_WATCHDOG_FAILURES:
self.state.counters[COUNTERS_CTRL][COUNTER_WATCHDOG].increment()
raise
else:
self._watchdog_failures = 0
self.state.counters[COUNTERS_CTRL][COUNTER_WATCHDOG].increment()

async def _get_free_buffers(self) -> int | None:
status, value = await self._ezsp.getValue(
Expand Down
8 changes: 7 additions & 1 deletion tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,18 @@ async def mock_leave(*args, **kwargs):
app._ezsp.handle_callback("stackStatusHandler", [t.EmberStatus.NETWORK_DOWN])
return [t.EmberStatus.NETWORK_DOWN]

async def nop_mock():
return ([0] * 10,)

app._in_flight_msg = None
ezsp_mock = MagicMock(spec=ezsp.EZSP)
ezsp_mock.types = ezsp_t7
type(ezsp_mock).ezsp_version = PropertyMock(return_value=ezsp_version)
ezsp_mock.initialize = AsyncMock(return_value=ezsp_mock)
ezsp_mock.connect = AsyncMock()
ezsp_mock.nop = AsyncMock(side_effect=nop_mock)
ezsp_mock.readCounters = AsyncMock(side_effect=nop_mock)
ezsp_mock.readAndClearCounters = AsyncMock(side_effect=nop_mock)
ezsp_mock._protocol = AsyncMock()
ezsp_mock.setConcentrator = AsyncMock()
ezsp_mock.getTokenData = AsyncMock(return_value=[t.EmberStatus.ERR_FATAL, b""])
Expand Down Expand Up @@ -1165,7 +1171,7 @@ async def counters_mock():
is None
)
assert (
app.state.counters[application.COUNTERS_CTRL][application.COUNTER_WATCHDOG] == 1
app.state.counters[application.COUNTERS_CTRL][application.COUNTER_WATCHDOG] == 0
)

# Ezsp Value success
Expand Down

0 comments on commit 1c43536

Please sign in to comment.