Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"click",
"coloredlogs",
"scapy",
"zigpy>=0.48.0",
"zigpy>=0.48.1",
"bellows>=0.31.0",
"zigpy-deconz>=0.18.0",
"zigpy-znp>=0.8.0",
Expand Down
13 changes: 9 additions & 4 deletions zigpy_cli/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import logging
import importlib
import itertools
import collections
import importlib.util

Expand Down Expand Up @@ -47,7 +48,7 @@ async def radio(ctx, radio, port, baudrate=None):

# Start the radio
app_cls = radio_module.ControllerApplication
config = app_cls.SCHEMA({"device": {"path": port}})
config = app_cls.SCHEMA({"device": {"path": port}, "backup_enabled": False})

if baudrate is not None:
config["device"]["baudrate"] = baudrate
Expand Down Expand Up @@ -121,15 +122,16 @@ async def restore(app, frame_counter_increment, input):
@click.pass_obj
@click_coroutine
async def form(app):
await app.startup(auto_form=True)
await app.connect()
await app.form_network()


@radio.command()
@click.pass_obj
@click.option("--nwk", type=HEX_OR_DEC_INT, default=0x0000)
@click.option("-n", "--num-scans", type=int, default=-1)
@click_coroutine
async def energy_scan(app, nwk):
async def energy_scan(app, nwk, num_scans):
await app.startup()
LOGGER.info("Running scan...")

Expand All @@ -143,7 +145,10 @@ async def energy_scan(app, nwk):
# We compute an average over the last 5 scans
channel_energies = collections.defaultdict(lambda: collections.deque([], maxlen=5))

while True:
for scan in itertools.count():
if num_scans != -1 and scan > num_scans:
break

rsp = await app.get_device(nwk=nwk).zdo.Mgmt_NWK_Update_req(
zigpy.zdo.types.NwkUpdate(
ScanChannels=zigpy.types.Channels.ALL_CHANNELS,
Expand Down