Skip to content

Commit 51ba7eb

Browse files
committed
tools: rpc_cloud: fix handling of responses without values
Fix assertion failures when a queried RPC does not have any response parameters. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent bfde166 commit 51ba7eb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/infuse_iot/tools/rpc_cloud.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
__copyright__ = "Copyright 2024, Embeint Inc"
77

88
import argparse
9+
import base64
910
import importlib
1011
import json
1112
import pkgutil
@@ -83,10 +84,15 @@ def query(self, client: Client):
8384
if rsp.downlink_message.status == DownlinkMessageStatus.COMPLETED:
8485
rpc_rsp = rsp.downlink_message.rpc_rsp
8586
assert isinstance(rpc_rsp, RpcRsp)
86-
assert isinstance(rpc_rsp.params, RPCParams)
87-
8887
print(f" Result: {rpc_rsp.return_code}")
89-
print(json.dumps(rpc_rsp.params.additional_properties, indent=4))
88+
if rpc_rsp.params:
89+
print(json.dumps(rpc_rsp.params.additional_properties, indent=4))
90+
elif rpc_rsp.params_encoded:
91+
raw_rsp = base64.b64decode(rpc_rsp.params_encoded)
92+
print(f" Raw: {raw_rsp.hex()}")
93+
else:
94+
# No response values
95+
pass
9096

9197
def run(self):
9298
with Client(base_url="https://api.infuse-iot.com").with_headers(

0 commit comments

Comments
 (0)