From 33d32c5cc086fc76b8b61ec0f991f7013ca4cd46 Mon Sep 17 00:00:00 2001 From: Jacob Lambert Date: Mon, 23 Mar 2020 11:47:17 -0400 Subject: [PATCH] Add RFMan command (#23) --- bond/app.py | 1 + bond/commands/rfman.py | 37 +++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 bond/commands/rfman.py diff --git a/bond/app.py b/bond/app.py index b869d0a..8a1390b 100644 --- a/bond/app.py +++ b/bond/app.py @@ -14,6 +14,7 @@ "reset", "wifi", "upgrade", + "rfman", ] diff --git a/bond/commands/rfman.py b/bond/commands/rfman.py new file mode 100644 index 0000000..eddfec9 --- /dev/null +++ b/bond/commands/rfman.py @@ -0,0 +1,37 @@ +from .base_command import BaseCommand +from bond.database import BondDatabase +import bond.proto + + +class RFManCommand(BaseCommand): + subcmd = "rfman" + help = "Configure the RF Manager [Bridge Only]" + arguments = { + "--silence-tx": { + "help": "Stop all transmissions from the Bond Bridge (for debugging purposes)", + "action": "store_true", + }, + "--log-signals": { + "help": "Log all signals transmitted by the Bond on BPUP and MQTT transports", + "action": "store_true", + }, + } + + def run(self, args): + bondid = BondDatabase.get_assert_selected_bondid() + rsp = bond.proto.patch( + bondid, + topic="debug/rfman", + body={"log_signals": args.log_signals, "silence_tx": args.silence_tx}, + ) + body = rsp.get("b", {}) + print( + "RF Manager settings: Log Signals (%s) | Silence Transmission (%s)" + % (body.get("log_signals"), body.get("silence_tx")) + ) + if rsp["s"] > 299: + print("HTTP %d %s" % (rsp["s"], rsp["b"]["_error_msg"])) + + +def register(): + RFManCommand() diff --git a/setup.py b/setup.py index 4f7618a..bd2054a 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='bond-cli', - version='0.0.5', + version='0.0.6', author='Olibra', packages=find_packages(), scripts=['bond/bond'],