nrfxlib API 2.7.99
Loading...
Searching...
No Matches
nrf_rpc.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <nrf_rpc_errno.h>
#include <nrf_rpc_common.h>
#include <nrf_rpc_tr.h>
#include <nrf_rpc_os.h>

Go to the source code of this file.

Data Structures

struct  nrf_rpc_group_data
 Group data structure. It contains no constant group data. More...
 
struct  nrf_rpc_group
 Defines a group of commands and events. More...
 
struct  nrf_rpc_err_report
 Error report. More...
 

Macros

#define NRF_RPC_PROTOCOL_VERSION   0
 nRF RPC protocol version.
 
#define NRF_RPC_ID_UNKNOWN   0xFF
 Special value to indicate that ID is unknown or irrelevant.
 
#define NRF_RPC_FLAGS_WAIT_ON_INIT   0x01
 Flag indicating that the group does not block on initialization.
 
#define NRF_RPC_FLAGS_INITIATOR   0x02
 Flag indicating that the peer must initiate group binding.
 
#define NRF_RPC_FLAG_COND(_cond, _flag)   ((_cond) ? (_flag) : 0UL)
 Helper macro for conditional flag initialization.
 
#define NRF_RPC_GROUP_DEFINE_INTERNAL__(_name, _strid, _transport, _ack_handler, _ack_data, _err_handler, _bound_handler, _wait_on_init, _initiator)
 Internal macro for parametrizing nrf_rpc groups.
 
#define NRF_RPC_GROUP_DEFINE(_name, _strid, _transport, _ack_handler, _ack_data, _err_handler)
 Define a group of commands and events.
 
#define NRF_RPC_GROUP_DEFINE_NOWAIT(_name, _strid, _transport, _ack_handler, _ack_data, _err_handler, _bound_handler, _initiator)
 Define a non-blocking group of commands and events.
 
#define NRF_RPC_GROUP_DECLARE(_name)    extern const struct nrf_rpc_group _name
 Extern declaration of a group.
 
#define NRF_RPC_CMD_DECODER(_group, _name, _cmd, _handler, _data)
 Register a command decoder.
 
#define NRF_RPC_EVT_DECODER(_group, _name, _evt, _handler, _data)
 Register an event decoder.
 
#define NRF_RPC_GROUP_STATUS(_group)    (_group.data->transport_initialized && (_group.data->dst_group_id != NRF_RPC_ID_UNKNOWN))
 Check group status.
 

Typedefs

typedef void(* nrf_rpc_handler_t) (const struct nrf_rpc_group *group, const uint8_t *packet, size_t len, void *handler_data)
 Callback that handles decoding of commands, events and responses.
 
typedef void(* nrf_rpc_ack_handler_t) (uint8_t id, void *handler_data)
 Callback called when ACK was received.
 
typedef void(* nrf_rpc_err_handler_t) (const struct nrf_rpc_err_report *report)
 Callback to report error that cannot be returned by the API call.
 
typedef void(* nrf_rpc_group_bound_handler_t) (const struct nrf_rpc_group *group)
 Callback called when the command group is bound.
 

Enumerations

enum  nrf_rpc_packet_type {
  NRF_RPC_PACKET_TYPE_EVT = 0x00 , NRF_RPC_PACKET_TYPE_RSP = 0x01 , NRF_RPC_PACKET_TYPE_ACK = 0x02 , NRF_RPC_PACKET_TYPE_ERR = 0x03 ,
  NRF_RPC_PACKET_TYPE_INIT = 0x04 , NRF_RPC_PACKET_TYPE_CMD = 0x80
}
 Type of packet. More...
 
enum  nrf_rpc_err_src { NRF_RPC_ERR_SRC_RECV , NRF_RPC_ERR_SRC_SEND , NRF_RPC_ERR_SRC_REMOTE }
 Error source. More...
 

Functions

int nrf_rpc_init (nrf_rpc_err_handler_t err_handler)
 Initialize the nRF RPC.
 
static int nrf_rpc_cmd (const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet, size_t len, nrf_rpc_handler_t handler, void *handler_data)
 Send a command and provide callback to handle response.
 
static int nrf_rpc_cmd_rsp (const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet, size_t len, const uint8_t **rsp_packet, size_t *rsp_len)
 Send a command and get response as an output parameter.
 
static void nrf_rpc_cmd_no_err (const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet, size_t len, nrf_rpc_handler_t handler, void *handler_data)
 Send a command, provide callback to handle response and pass any error to an error handler.
 
static void nrf_rpc_cmd_rsp_no_err (const struct nrf_rpc_group *group, uint8_t cmd, uint8_t *packet, size_t len, const uint8_t **rsp_packet, size_t *rsp_len)
 Send a command, get response as an output parameter and pass any error to an error handler.
 
int nrf_rpc_evt (const struct nrf_rpc_group *group, uint8_t evt, uint8_t *packet, size_t len)
 Send an event.
 
void nrf_rpc_evt_no_err (const struct nrf_rpc_group *group, uint8_t evt, uint8_t *packet, size_t len)
 Send an event and pass any error to an error handler.
 
int nrf_rpc_rsp (const struct nrf_rpc_group *group, uint8_t *packet, size_t len)
 Send a response.
 
void nrf_rpc_rsp_no_err (const struct nrf_rpc_group *group, uint8_t *packet, size_t len)
 Send a response and pass any error to an error handler.
 
void nrf_rpc_decoding_done (const struct nrf_rpc_group *group, const uint8_t *packet)
 Indicate that decoding of the input packet is done.
 
void nrf_rpc_err (int code, enum nrf_rpc_err_src src, const struct nrf_rpc_group *group, uint8_t id, uint8_t packet_type)
 Report an error to nRF RPC error handler.
 
void nrf_rpc_alloc_tx_buf (const struct nrf_rpc_group *group, uint8_t **buf, size_t len)
 Allocates buffer for a packet.
 
void nrf_rpc_free_tx_buf (const struct nrf_rpc_group *group, uint8_t *buf)
 Deallocates Tx buffer.