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 src/infuse_iot/rpc_wrappers/data_logger_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def request_struct(self):
return self.request(self.logger, self.start, self.last)

def request_json(self):
return {"logger": self.logger.name, "start_block": self.start, "last_block": self.last}
return {"logger": self.logger.name, "start_block": str(self.start), "last_block": str(self.last)}

def data_recv_cb(self, offset: int, data: bytes) -> None:
if self.expected_offset == 0:
Expand Down
16 changes: 13 additions & 3 deletions src/infuse_iot/tools/rpc_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
import infuse_iot.rpc_wrappers as wrappers
from infuse_iot.api_client import Client
from infuse_iot.api_client.api.rpc import get_rpc_by_id, send_rpc
from infuse_iot.api_client.models import Error, NewRPCMessage, NewRPCReq, RPCParams, RpcRsp
from infuse_iot.api_client.models import Error, NewRPCMessage, NewRPCReq, RPCParams, RPCReqDataHeader, RpcRsp
from infuse_iot.api_client.models.downlink_message_status import DownlinkMessageStatus
from infuse_iot.commands import InfuseCommand, InfuseRpcCommand
from infuse_iot.credentials import get_api_key
from infuse_iot.definitions.rpc import id_type_mapping
from infuse_iot.util.ctypes import UINT32_MAX


class SubCommand(InfuseCommand):
Expand Down Expand Up @@ -77,10 +78,19 @@ def queue(self, client: Client):
params_encoded = base64.b64encode(struct_bytes).decode("utf-8")
rpc_req = NewRPCReq(command_id=command.COMMAND_ID, params_encoded=params_encoded)

if command.RPC_DATA_RECEIVE:
# Generic "unknown" data volume
rpc_req.data_header = RPCReqDataHeader(UINT32_MAX, 0)

rpc_msg = NewRPCMessage(infuse_id, rpc_req, timeout_ms)
rsp = send_rpc.sync(client=client, body=rpc_msg)
if isinstance(rsp, Error) or rsp is None:
sys.exit(f"Failed to queue RPC ({rsp})")
if rsp is None:
sys.exit("Failed to queue RPC (No response)")
elif isinstance(rsp, Error) or rsp is None:
msg = "Failed to queue RPC\n"
msg += f"\t Code: {rsp.code}\n"
msg += f"\t Msg: '{rsp.message}'"
sys.exit(msg)
print("Query RPC state with:")
print(f"\tinfuse rpc_cloud query --id {rsp.id}")

Expand Down