Skip to content

Commit 18448dc

Browse files
committed
Explicitly configure some NVIDs instead of relying on defaults
1 parent 8ddf758 commit 18448dc

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

tests/test_application.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ def application(znp_server):
178178
],
179179
)
180180

181+
# Reply to the initialization NVID writes
182+
for nvid in [
183+
NwkNvIds.CONCENTRATOR_ENABLE,
184+
NwkNvIds.CONCENTRATOR_DISCOVERY,
185+
NwkNvIds.CONCENTRATOR_RC,
186+
NwkNvIds.SRC_RTG_EXPIRY_TIME,
187+
NwkNvIds.NWK_CHILD_AGE_ENABLE,
188+
]:
189+
znp_server.reply_to(
190+
request=c.SysCommands.OSALNVWrite.Req(Id=nvid, Offset=0, partial=True),
191+
responses=[c.SysCommands.OSALNVWrite.Rsp(Status=t.Status.Success)],
192+
)
193+
181194
return app, znp_server
182195

183196

@@ -206,7 +219,7 @@ def register_endpoint(request):
206219
assert len(endpoints) == 5
207220

208221

209-
@pytest_mark_asyncio_timeout(seconds=2)
222+
@pytest_mark_asyncio_timeout(seconds=3)
210223
async def test_permit_join(application):
211224
app, znp_server = application
212225

@@ -241,7 +254,7 @@ async def test_permit_join(application):
241254
await asyncio.gather(data_req_sent, permit_join_sent)
242255

243256

244-
@pytest_mark_asyncio_timeout(seconds=2)
257+
@pytest_mark_asyncio_timeout(seconds=3)
245258
async def test_permit_join_failure(application):
246259
app, znp_server = application
247260

@@ -278,7 +291,7 @@ async def test_permit_join_failure(application):
278291
await asyncio.gather(data_req_sent, permit_join_sent)
279292

280293

281-
@pytest_mark_asyncio_timeout()
294+
@pytest_mark_asyncio_timeout(seconds=3)
282295
async def test_on_zdo_relays_message_callback(application, mocker):
283296
app, znp_server = application
284297
await app.startup(auto_form=False)
@@ -292,7 +305,7 @@ async def test_on_zdo_relays_message_callback(application, mocker):
292305
assert device.relays == [0x5678, 0xABCD]
293306

294307

295-
@pytest_mark_asyncio_timeout()
308+
@pytest_mark_asyncio_timeout(seconds=3)
296309
async def test_on_zdo_device_announce(application, mocker):
297310
app, znp_server = application
298311
await app.startup(auto_form=False)
@@ -310,7 +323,7 @@ async def test_on_zdo_device_announce(application, mocker):
310323
app.handle_join.assert_called_once_with(nwk=nwk, ieee=ieee, parent_nwk=0)
311324

312325

313-
@pytest_mark_asyncio_timeout()
326+
@pytest_mark_asyncio_timeout(seconds=3)
314327
async def test_on_zdo_device_join(application, mocker):
315328
app, znp_server = application
316329
await app.startup(auto_form=False)
@@ -326,7 +339,7 @@ async def test_on_zdo_device_join(application, mocker):
326339
app.handle_join.assert_called_once_with(nwk=nwk, ieee=ieee, parent_nwk=0x0001)
327340

328341

329-
@pytest_mark_asyncio_timeout()
342+
@pytest_mark_asyncio_timeout(seconds=3)
330343
async def test_on_zdo_device_leave_callback(application, mocker):
331344
app, znp_server = application
332345
await app.startup(auto_form=False)
@@ -344,7 +357,7 @@ async def test_on_zdo_device_leave_callback(application, mocker):
344357
app.handle_leave.assert_called_once_with(nwk=nwk, ieee=ieee)
345358

346359

347-
@pytest_mark_asyncio_timeout()
360+
@pytest_mark_asyncio_timeout(seconds=3)
348361
async def test_on_af_message_callback(application, mocker):
349362
app, znp_server = application
350363
await app.startup(auto_form=False)
@@ -390,7 +403,7 @@ async def test_on_af_message_callback(application, mocker):
390403
assert app.handle_message.call_count == 0
391404

392405

393-
@pytest_mark_asyncio_timeout()
406+
@pytest_mark_asyncio_timeout(seconds=3)
394407
async def test_probe(pingable_serial_port): # noqa: F811
395408
assert not (
396409
await ControllerApplication.probe(
@@ -467,7 +480,7 @@ async def fixed_uart_connect(config, api):
467480
assert app._config[conf.CONF_DEVICE][conf.CONF_DEVICE_PATH] == AUTO_DETECTED_PORT
468481

469482

470-
@pytest_mark_asyncio_timeout()
483+
@pytest_mark_asyncio_timeout(seconds=3)
471484
async def test_close(mocker, application):
472485
app, znp_server = application
473486
app.connection_lost = mocker.MagicMock(wraps=app.connection_lost)
@@ -478,7 +491,7 @@ async def test_close(mocker, application):
478491
app.connection_lost.assert_called_once_with(None)
479492

480493

481-
@pytest_mark_asyncio_timeout()
494+
@pytest_mark_asyncio_timeout(seconds=3)
482495
async def test_shutdown(mocker, application):
483496
app, znp_server = application
484497

@@ -493,7 +506,7 @@ async def test_shutdown(mocker, application):
493506
app._znp.close.assert_called_once_with()
494507

495508

496-
@pytest_mark_asyncio_timeout(seconds=2)
509+
@pytest_mark_asyncio_timeout(seconds=3)
497510
async def test_zdo_request_interception(application, mocker):
498511
app, znp_server = application
499512
await app.startup(auto_form=False)
@@ -587,7 +600,7 @@ async def test_zigpy_request(application, mocker):
587600
await data_req
588601

589602

590-
@pytest_mark_asyncio_timeout(seconds=2)
603+
@pytest_mark_asyncio_timeout(seconds=3)
591604
@pytest.mark.parametrize(
592605
"use_ieee,dev_addr",
593606
[
@@ -616,7 +629,7 @@ async def test_request_use_ieee(application, mocker, use_ieee, dev_addr):
616629
assert send_req.mock_calls[0][2]["dst_addr"] == dev_addr
617630

618631

619-
@pytest_mark_asyncio_timeout()
632+
@pytest_mark_asyncio_timeout(seconds=3)
620633
async def test_update_network_noop(mocker, application):
621634
app, znp_server = application
622635

zigpy_znp/zigbee/application.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ async def startup(self, auto_form=False):
249249
conf.CONF_DEVICE_PATH
250250
] = self._znp._uart.transport.serial.name
251251

252+
# It's better to configure these explicitly than rely on the NVRAM defaults
253+
await self._znp.nvram_write(NwkNvIds.CONCENTRATOR_ENABLE, t.Bool(True))
254+
await self._znp.nvram_write(NwkNvIds.CONCENTRATOR_DISCOVERY, t.uint8_t(120))
255+
await self._znp.nvram_write(NwkNvIds.CONCENTRATOR_RC, t.Bool(True))
256+
await self._znp.nvram_write(NwkNvIds.SRC_RTG_EXPIRY_TIME, t.uint8_t(255))
257+
await self._znp.nvram_write(NwkNvIds.NWK_CHILD_AGE_ENABLE, t.Bool(False))
258+
252259
await self._reset()
253260

254261
if auto_form and False:

0 commit comments

Comments
 (0)