14#ifndef NRF_RPC_SERIALIZE_H_
15#define NRF_RPC_SERIALIZE_H_
17#include <zephyr/net_buf.h>
18#include <zephyr/sys/util.h>
19#include <nrf_rpc_cbor.h>
31#define NRF_RPC_SCRATCHPAD_ALIGN(size) WB_UP(size)
39#define NRF_RPC_SCRATCHPAD_DECLARE(_scratchpad, _ctx) \
40 (_scratchpad)->ctx = _ctx; \
41 uint32_t _scratchpad_size = nrf_rpc_decode_uint(_ctx); \
42 uint32_t _scratchpad_data[NRF_RPC_SCRATCHPAD_ALIGN(_scratchpad_size) / sizeof(uint32_t)]; \
43 net_buf_simple_init_with_data(&(_scratchpad)->buf, _scratchpad_data, _scratchpad_size); \
44 net_buf_simple_reset(&(_scratchpad)->buf)
49 struct nrf_rpc_cbor_ctx *
ctx;
52 struct net_buf_simple
buf;
322 struct nrf_rpc_cbor_ctx *ctx);
344 void *result,
size_t result_size);
393 void *result,
size_t result_size);
static void * nrf_rpc_scratchpad_add(struct nrf_rpc_scratchpad *scratchpad, size_t size)
Get the scratchpad item of a given size. The scratchpad item size will be round up to multiple of 4.
Definition nrf_rpc_serialize.h:63
void nrf_rpc_rsp_decode_i16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as a signed 16-bit integer value.
#define NRF_RPC_SCRATCHPAD_ALIGN(size)
Get a scratchpad item size aligned to 4-byte boundary.
Definition nrf_rpc_serialize.h:31
void nrf_rpc_rsp_send_uint(const struct nrf_rpc_group *group, uint32_t response)
Send response to a command as an unsigned integer value.
bool nrf_rpc_decode_bool(struct nrf_rpc_cbor_ctx *ctx)
Decode a boolean value.
void * nrf_rpc_decode_callback_call(struct nrf_rpc_cbor_ctx *ctx)
Decode callback slot.
void nrf_rpc_rsp_decode_int(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *result, size_t result_size)
Decode a command response as a signed integer value.
bool nrf_rpc_decode_is_null(struct nrf_rpc_cbor_ctx *ctx)
Check if value is a null. This function will not consume the value.
const void * nrf_rpc_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t *size)
Decode buffer pointer and length. Moves CBOR buffer pointer past buffer on success.
void nrf_rpc_encode_int(struct nrf_rpc_cbor_ctx *ctx, int32_t value)
Encode an integer value.
void nrf_rpc_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback)
Encode a callback.
void nrf_rpc_rsp_send_void(const struct nrf_rpc_group *group)
Send response to a command as a void.
void nrf_rpc_rsp_decode_u8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as an unsigned 8-bit integer value.
void * nrf_rpc_decode_callbackd(struct nrf_rpc_cbor_ctx *ctx, void *handler)
Decode a callback.
void * nrf_rpc_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffer_size)
Decode a buffer.
int32_t nrf_rpc_decode_int(struct nrf_rpc_cbor_ctx *ctx)
Decode a integer value.
void nrf_rpc_rsp_decode_i32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as a signed 32-bit integer value.
void nrf_rpc_decode_skip(struct nrf_rpc_cbor_ctx *ctx)
Skip one value to decode.
void nrf_rpc_encode_uint64(struct nrf_rpc_cbor_ctx *ctx, uint64_t value)
Encode an 64bits unsigned integer value.
void nrf_rpc_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t size)
Encode a buffer.
void nrf_rpc_encoder_invalid(struct nrf_rpc_cbor_ctx *ctx)
Put encode into an invalid state. All further encoding on this encoder will be ignored....
void nrf_rpc_rsp_decode_u32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as an unsigned 32-bit integer value.
uint64_t nrf_rpc_decode_uint64(struct nrf_rpc_cbor_ctx *ctx)
Decode a 64bits unsigned integer value.
void nrf_rpc_encode_null(struct nrf_rpc_cbor_ctx *ctx)
Encode a null value.
void nrf_rpc_rsp_send_int(const struct nrf_rpc_group *group, int32_t response)
Send response to a command as an integer value.
void nrf_rpc_decoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err)
Put decoder into an invalid state and set error code that caused it. All further decoding on this dec...
void nrf_rpc_encode_undefined(struct nrf_rpc_cbor_ctx *ctx)
Encode an undefined value.
void nrf_rpc_encode_int64(struct nrf_rpc_cbor_ctx *ctx, int64_t value)
Encode an 64bits integer value.
void nrf_rpc_rsp_decode_i8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as a signed 8-bit integer value.
void nrf_rpc_rsp_send_bool(const struct nrf_rpc_group *group, bool response)
Send response to a command as a boolean value.
bool nrf_rpc_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx)
Check if value is an undefined. This function will not consume the value.
char * nrf_rpc_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_size)
Decode a string value.
static void nrf_rpc_encode_callback_call(struct nrf_rpc_cbor_ctx *ctx, uint32_t slot)
Encode a callback slot number.
Definition nrf_rpc_serialize.h:146
void nrf_rpc_rsp_decode_void(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as a void value.
void nrf_rpc_rsp_decode_u16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as an unsigned 16-bit integer value.
int64_t nrf_rpc_decode_int64(struct nrf_rpc_cbor_ctx *ctx)
Decode a 64bits integer value.
uint32_t nrf_rpc_decode_uint(struct nrf_rpc_cbor_ctx *ctx)
Decode an unsigned integer value.
void nrf_rpc_rsp_decode_uint(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *result, size_t result_size)
Decode a command response as an unsigned integer value.
void nrf_rpc_rsp_decode_bool(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data)
Decode a command response as a boolean value.
void nrf_rpc_encode_str(struct nrf_rpc_cbor_ctx *ctx, const char *value, int len)
Encode a string value.
void nrf_rpc_encode_uint(struct nrf_rpc_cbor_ctx *ctx, uint32_t value)
Encode an unsigned integer value.
bool nrf_rpc_decoding_done_and_check(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx)
Signalize that decoding is done. Use this function when you finish decoding of the received serialize...
char * nrf_rpc_decode_str_into_scratchpad(struct nrf_rpc_scratchpad *scratchpad, size_t *len)
bool nrf_rpc_decode_valid(const struct nrf_rpc_cbor_ctx *ctx)
Returns if decoder is in valid state.
void * nrf_rpc_decode_buffer_into_scratchpad(struct nrf_rpc_scratchpad *scratchpad, size_t *len)
Decode buffer into a scratchpad.
void nrf_rpc_encode_bool(struct nrf_rpc_cbor_ctx *ctx, bool value)
Encode a boolean value.
struct net_buf_simple buf
Definition nrf_rpc_serialize.h:52
struct nrf_rpc_cbor_ctx * ctx
Definition nrf_rpc_serialize.h:49
Scratchpad structure.
Definition nrf_rpc_serialize.h:47