Skip to content

Commit cbff95f

Browse files
committed
rpc_wrappers: initial rpc_cloud support
Add initial support for queuing some commands through `rpc_cloud`. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 78a6874 commit cbff95f

File tree

9 files changed

+29
-11
lines changed

9 files changed

+29
-11
lines changed

src/infuse_iot/rpc_wrappers/application_info.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __init__(self, _args):
1717
def request_struct(self):
1818
return self.request()
1919

20+
def request_json(self):
21+
return {}
22+
2023
def handle_response(self, return_code, response):
2124
if return_code != 0:
2225
print(f"Failed to query current time ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/data_logger_state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def __init__(self, args):
2424
def request_struct(self):
2525
return self.request(self.logger)
2626

27+
def request_json(self):
28+
return {"logger": str(self.logger.value)}
29+
2730
def handle_response(self, return_code, response):
2831
if return_code != 0:
2932
print(f"Failed to query current time ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/kv_read.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def request_struct(self):
5858
keys = (ctypes.c_uint16 * len(self.keys))(*self.keys)
5959
return bytes(self.request(len(self.keys))) + bytes(keys)
6060

61+
def request_json(self):
62+
return {"num": str(len(self.keys)), "keys": [str(k) for k in self.keys]}
63+
6164
def handle_response(self, return_code, response):
6265
if return_code != 0:
6366
print(f"Invalid data buffer ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/last_reboot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __init__(self, args):
1717
def request_struct(self):
1818
return self.request()
1919

20+
def request_json(self):
21+
return {}
22+
2023
def handle_response(self, return_code, response):
2124
if return_code != 0:
2225
print(f"Failed to query reboot info ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/lte_at_cmd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def __init__(self, args):
2525
def request_struct(self):
2626
return self.args.cmd.encode("utf-8") + b"\x00"
2727

28+
def request_json(self):
29+
return {"cmd": self.args.cmd}
30+
2831
def handle_response(self, return_code, response):
2932
if return_code != 0:
3033
print(f"Failed to run command ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/lte_modem_info.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#!/usr/bin/env python3
22

3-
import ctypes
3+
# import ctypes
4+
import argparse
45
import os
56

6-
import infuse_iot.generated.rpc_definitions as defs
7-
from infuse_iot.commands import InfuseRpcCommand
8-
97
from . import kv_read, lte_pdp_ctx
108

119

12-
class lte_modem_info(InfuseRpcCommand, defs.kv_read):
10+
class lte_modem_info(kv_read.kv_read):
1311
HELP = "Get LTE modem information"
1412
DESCRIPTION = "Get LTE modem information"
1513

@@ -23,12 +21,8 @@ class response(kv_read.kv_read.response):
2321
def add_parser(cls, parser):
2422
return
2523

26-
def __init__(self, args):
27-
self.keys = [40, 41, 42, 43, 44, 45]
28-
29-
def request_struct(self):
30-
keys = (ctypes.c_uint16 * len(self.keys))(*self.keys)
31-
return bytes(self.request(len(self.keys))) + bytes(keys)
24+
def __init__(self, _args):
25+
super().__init__(argparse.Namespace(keys=[40, 41, 42, 43, 44, 45]))
3226

3327
def handle_response(self, return_code, response):
3428
if return_code != 0:

src/infuse_iot/rpc_wrappers/lte_state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def __init__(self, args):
8080
def request_struct(self):
8181
return self.request()
8282

83+
def request_json(self):
84+
return {}
85+
8386
def handle_response(self, return_code, response):
8487
if return_code != 0:
8588
print(f"Failed to query current time ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/time_get.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __init__(self, args):
1717
def request_struct(self):
1818
return self.request()
1919

20+
def request_json(self):
21+
return {}
22+
2023
def handle_response(self, return_code, response):
2124
if return_code != 0:
2225
print(f"Failed to query current time ({os.strerror(-return_code)})")

src/infuse_iot/rpc_wrappers/zbus_channel_state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def __init__(self, args):
6363
def request_struct(self):
6464
return self.request(self._channel.id)
6565

66+
def request_json(self):
67+
return {"channel_id": str(self._channel.id)}
68+
6669
def handle_response(self, return_code, response):
6770
if return_code != 0:
6871
print(f"Failed to query channel ({os.strerror(-return_code)})")

0 commit comments

Comments
 (0)