Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
RPC client APIs

Data Structures

struct  rpc_client_cmd_ctx
 Context associated with a single in-flight command. More...
struct  rpc_client_ctx
 RPC client context. More...
struct  rpc_client_auto_load_params
 State for auto loader control. More...

Typedefs

typedef void(* rpc_client_rsp_fn) (const struct net_buf *buf, void *user_data)
 Callback run when the response arrives.
typedef int(* rpc_client_data_loader) (void *user_data, uint32_t offset, void *data, size_t data_len)
 Callback to load more data for queueing.

Functions

void rpc_client_init (struct rpc_client_ctx *ctx, const struct device *dev, union epacket_interface_address address)
 Initialise RPC client object for use.
static uint32_t rpc_client_last_request_id (const struct rpc_client_ctx *ctx)
 Get the request ID used by the last command.
int rpc_client_update_response_timeout (struct rpc_client_ctx *ctx, uint32_t request_id, k_timeout_t timeout)
 Update the response timeout of an executing command.
int rpc_client_command_queue (struct rpc_client_ctx *ctx, enum rpc_builtin_id cmd, void *req_params, size_t req_params_len, rpc_client_rsp_fn cb, void *user_data, k_timeout_t ctx_timeout, k_timeout_t response_timeout)
 Queue a command for execution on a remote device.
int rpc_client_ack_wait (struct rpc_client_ctx *ctx, uint32_t request_id, k_timeout_t timeout)
 Wait for an INFUSE_RPC_DATA_ACK from the remote device.
int rpc_client_data_queue (struct rpc_client_ctx *ctx, uint32_t request_id, uint32_t offset, const void *data, size_t data_len)
 Queue data associated with a previously queued command.
int rpc_client_data_queue_auto_load (struct rpc_client_ctx *ctx, uint32_t request_id, uint32_t offset, void *buffer, size_t buffer_len, const struct rpc_client_auto_load_params *loader_params)
 Queue data associated with a previously queued command, loaded via callback.
int rpc_client_command_sync (struct rpc_client_ctx *ctx, enum rpc_builtin_id cmd, void *req_params, size_t req_params_len, k_timeout_t ctx_timeout, k_timeout_t response_timeout, struct net_buf **rsp)
 Queue a command for execution on a remote device and wait for the response.
void rpc_client_cleanup (struct rpc_client_ctx *ctx)
 Cleanup a RPC client object.

Detailed Description

Typedef Documentation

◆ rpc_client_data_loader

typedef int(* rpc_client_data_loader) (void *user_data, uint32_t offset, void *data, size_t data_len)

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Callback to load more data for queueing.

Parameters
user_dataArbitrary pointer supplied to rpc_client_data_queue
offsetOffset of data requested
dataPointer to load data into
data_lenLength of data to load
Return values
0on success
-errnoon error

◆ rpc_client_rsp_fn

typedef void(* rpc_client_rsp_fn) (const struct net_buf *buf, void *user_data)

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Callback run when the response arrives.

Note
On response timeout (buf is NULL), the callback is run from the timer ISR. Otherwise it is run from the ePacket receive thread.
Parameters
bufResponse packet if not NULL, NULL on timeout
user_dataUser data provided to rpc_client_command_queue

Function Documentation

◆ rpc_client_ack_wait()

int rpc_client_ack_wait ( struct rpc_client_ctx * ctx,
uint32_t request_id,
k_timeout_t timeout )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Wait for an INFUSE_RPC_DATA_ACK from the remote device.

Note
At a minimum, the client should wait for the first ACK from the remote device before sending data via rpc_client_data_queue. This gives the remote time to configure itself for receiving data.
Parameters
ctxRPC client context
request_idRequest ID from rpc_client_last_request_id
timeout
Return values
0On success
-EINVALIf request ID is no longer valid
-EAGAINIf waiting for ACK timed out

◆ rpc_client_cleanup()

void rpc_client_cleanup ( struct rpc_client_ctx * ctx)

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Cleanup a RPC client object.

Parameters
ctxRPC client context

◆ rpc_client_command_queue()

int rpc_client_command_queue ( struct rpc_client_ctx * ctx,
enum rpc_builtin_id cmd,
void * req_params,
size_t req_params_len,
rpc_client_rsp_fn cb,
void * user_data,
k_timeout_t ctx_timeout,
k_timeout_t response_timeout )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Queue a command for execution on a remote device.

Note
The header information in req_params is populated by this function.
When used with rpc_client_data_queue, receiving INFUSE_RPC_DATA_ACK messages will reset response_timeout.
Parameters
ctxRPC client context
cmdCommand ID
req_paramsCommand request parameters
req_params_lenLength of command request
cbCallback to run when associated response is received
user_dataArbitrary user data to supply to callback
ctx_timeoutMaximum duration to wait for a command context to become available
response_timeoutMaximum duration to wait for a response to be received from remote device
Return values
0If command pushed to remote device
-EAGAINIf command context claim timed out
-EINVALIf request params, callback or response timeout are invalid values
-EMSGSIZEIf the command does not fit in the current interface payload

◆ rpc_client_command_sync()

int rpc_client_command_sync ( struct rpc_client_ctx * ctx,
enum rpc_builtin_id cmd,
void * req_params,
size_t req_params_len,
k_timeout_t ctx_timeout,
k_timeout_t response_timeout,
struct net_buf ** rsp )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Queue a command for execution on a remote device and wait for the response.

Parameters
ctxRPC client context
cmdCommand ID
req_paramsCommand request parameters
req_params_lenLength of command request
ctx_timeoutMaximum duration to wait for a command context to become available
response_timeoutMaximum duration to wait for a response to be received from remote device
rspOutput store for response buffer
Return values
0On success
-ETIMEDOUTOn response timeout
-errnoError code from rpc_client_command_queue on error

◆ rpc_client_data_queue()

int rpc_client_data_queue ( struct rpc_client_ctx * ctx,
uint32_t request_id,
uint32_t offset,
const void * data,
size_t data_len )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Queue data associated with a previously queued command.

Parameters
ctxRPC client context
request_idRequest ID from rpc_client_last_request_id
offsetByte offset of data
dataCommand data pointer
data_lenCommand data length
Return values
0If data pushed to remote device
-EINVALIf request ID is no longer valid

◆ rpc_client_data_queue_auto_load()

int rpc_client_data_queue_auto_load ( struct rpc_client_ctx * ctx,
uint32_t request_id,
uint32_t offset,
void * buffer,
size_t buffer_len,
const struct rpc_client_auto_load_params * loader_params )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Queue data associated with a previously queued command, loaded via callback.

Parameters
ctxRPC client context
request_idRequest ID from rpc_client_last_request_id
offsetByte offset of data
bufferBuffer for loading data
buffer_lenBuffer data length
loader_paramsContext for loading data
Return values
0If data pushed to remote device
-EINVALIf request ID is no longer valid

◆ rpc_client_init()

void rpc_client_init ( struct rpc_client_ctx * ctx,
const struct device * dev,
union epacket_interface_address address )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Initialise RPC client object for use.

Parameters
ctxRPC client context
devePacket interface to send commands on
addressInterface address to communicate with

◆ rpc_client_last_request_id()

uint32_t rpc_client_last_request_id ( const struct rpc_client_ctx * ctx)
inlinestatic

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Get the request ID used by the last command.

Note
Used in conjunction with rpc_client_data_queue.
Parameters
ctxRPC client context
Returns
uint32_t request ID

◆ rpc_client_update_response_timeout()

int rpc_client_update_response_timeout ( struct rpc_client_ctx * ctx,
uint32_t request_id,
k_timeout_t timeout )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/rpc/client.h>

Update the response timeout of an executing command.

Note
This restarts the response timeout with the new value.
Parameters
ctxRPC client context
request_idRequest ID from rpc_client_last_request_id
timeoutNew response timeout
Return values
0On success
-EINVALIf request ID is no longer valid