Skip to content

Commit

Permalink
Print network parameters during startup (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminiuga committed Aug 29, 2020
1 parent 521d501 commit ed11e0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,20 @@ async def startup(self, auto_form=False):
raise Exception("Could not initialize network")
await self.form_network()

v = await ezsp.getNetworkParameters()
assert v[0] == t.EmberStatus.SUCCESS # TODO: Better check
if v[1] != t.EmberNodeType.COORDINATOR:
status, node_type, nwk_params = await ezsp.getNetworkParameters()
assert status == t.EmberStatus.SUCCESS # TODO: Better check
if node_type != t.EmberNodeType.COORDINATOR:
if not auto_form:
raise Exception("Network not configured as coordinator")

LOGGER.info("Forming network")
await self._ezsp.leaveNetwork()
await asyncio.sleep(1) # TODO
await self.form_network()
status, node_type, nwk_params = await ezsp.getNetworkParameters()
assert status == t.EmberStatus.SUCCESS

LOGGER.info("Node type: %s, Network parameters: %s", node_type, nwk_params)

await ezsp.update_policies(self.config)
nwk = await ezsp.getNodeId()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def mock_coro(*args, **kwargs):

def _test_startup(app, nwk_type, ieee, auto_form=False, init=0, ezsp_version=4):
async def mockezsp(*args, **kwargs):
return [0, nwk_type]
return [0, nwk_type, mock.sentinel.nework_parameters]

async def mockinit(*args, **kwargs):
return [init]
Expand Down

0 comments on commit ed11e0e

Please sign in to comment.