From 341f1a26abf919612c615e05bde489beae4aea33 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Sat, 10 Aug 2024 10:07:23 +0200 Subject: [PATCH] Expose flow_control paramater from zigpy Certain boards (such as the Sonoff Zigbee 3.0 USB Dongle Plus P) have a hardware switch that allows for turning on hardware flow control (given the correct firmware is flashed). This requires of course that zigpy-cli also allows for setting this flag to be able to communicate with the dongle. Zigpy and zigpy-znp already support hardware flow control fully. No wit is time that zigpy-cli also offers this option. Signed-off-by: Olliver Schinagl --- README.md | 2 ++ zigpy_cli/radio.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 61e4cc1..8d84b1e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ radio requires exclusive access to the hardware: if both are running at once, ne Network commands require the radio type to be specified. See `zigpy radio --help` for the list of supported types. If your radio requires a different baudrate than the radio library default (mainly EZSP), you must specify it as a command line option. For example, `zigpy radio --baudrate 115200 ezsp backup -`. +Similarly if a different flow control is required ("hardware" or "software"), this also must be specified, otherwise the driver default will be used (usually software flow control). For example, `zigpy radio --flow-control hardware znp backup -`. + ## Network backup ```console diff --git a/zigpy_cli/radio.py b/zigpy_cli/radio.py index 7926480..a173f5a 100644 --- a/zigpy_cli/radio.py +++ b/zigpy_cli/radio.py @@ -25,9 +25,10 @@ @click.argument("radio", type=click.Choice(list(RADIO_TO_PACKAGE.keys()))) @click.argument("port", type=str) @click.option("--baudrate", type=int, default=None) +@click.option("--flow-control", type=click.Choice(["software", "hardware", "none"]), default=None) @click.option("--database", type=str, default=None) @click_coroutine -async def radio(ctx, radio, port, baudrate=None, database=None): +async def radio(ctx, radio, port, baudrate=None, flow_control=None, database=None): # Setup logging for the radio verbose = ctx.parent.params["verbose"] logging_configs = RADIO_LOGGING_CONFIGS[radio] @@ -60,6 +61,9 @@ async def radio(ctx, radio, port, baudrate=None, database=None): if baudrate is not None: config["device"]["baudrate"] = baudrate + if flow_control == "hardware" or flow_control == "software": + config["device"]["flow_control"] = flow_control + app = radio_module.ControllerApplication(config) ctx.obj = app