Skip to content

Commit

Permalink
Add command to probe running firmware (#37)
Browse files Browse the repository at this point in the history
* Add command to probe running firmware

* update README
  • Loading branch information
darkxst authored Jun 16, 2023
1 parent 9e07800 commit 303bab2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Options:
Commands:
dump-gbl-metadata
flash
probe
write-ieee
```

Expand Down
17 changes: 17 additions & 0 deletions universal_silabs_flasher/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ async def dump_gbl_metadata(ctx: click.Context, firmware: typing.BinaryIO) -> No

print(json.dumps(metadata_obj))

@main.command()
@click.pass_context
@click_coroutine
async def probe(ctx: click.Context) -> None:
flasher = ctx.obj["flasher"]

try:
await flasher.probe_app_type()
except RuntimeError as e:
raise click.ClickException(str(e)) from e

if flasher.app_type == ApplicationType.EZSP:
_LOGGER.info("Dumping EmberZNet Config")
try:
await flasher.dump_emberznet_config()
except RuntimeError as e:
raise click.ClickException(str(e)) from e

@main.command()
@click.pass_context
Expand Down
11 changes: 11 additions & 0 deletions universal_silabs_flasher/flasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,17 @@ async def flash_firmware(
if run_firmware:
await gecko.run_firmware()

async def dump_emberznet_config(self) -> None:
if self.app_type != ApplicationType.EZSP:
raise RuntimeError(f"Device is not running EmberZNet: {self.app_type}")

async with self._connect_ezsp(self.app_baudrate) as ezsp:
for config in ezsp.types.EzspConfigId:
v = await ezsp.getConfigurationValue(config)
if v[0] == bellows.types.EzspStatus.ERROR_INVALID_ID:
continue
print(f"{config.name}={v[1]}")

async def write_emberznet_eui64(self, new_eui64: bellows.types.EUI64) -> bool:
await self.probe_app_type()

Expand Down

0 comments on commit 303bab2

Please sign in to comment.