diff --git a/doc/nrf/libraries/bluetooth_services/rpc.rst b/doc/nrf/libraries/bluetooth_services/rpc.rst index 5f8e83b0fe60..0c5dd2334479 100644 --- a/doc/nrf/libraries/bluetooth_services/rpc.rst +++ b/doc/nrf/libraries/bluetooth_services/rpc.rst @@ -81,7 +81,7 @@ Set the following options in the same way for the :ref:`ble_rpc_host` or :ref:`i * :kconfig:option:`CONFIG_BT_PER_ADV_SYNC_MAX` * :kconfig:option:`CONFIG_BT_DEVICE_APPEARANCE` * :kconfig:option:`CONFIG_BT_DEVICE_NAME` - * :kconfig:option:`CONFIG_CBKPROXY_OUT_SLOTS` on one core must be equal to :kconfig:option:`CONFIG_CBKPROXY_IN_SLOTS` on the other. + * :kconfig:option:`CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS` on one core must be equal to :kconfig:option:`CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS` on the other. To keep all the above configuration options in sync, create an overlay file that is shared between the application and network core. Then, you can invoke build command like this: @@ -111,8 +111,8 @@ Additionally, you can use the following options: * :kconfig:option:`CONFIG_BT_RPC_GATT_SRV_MAX` * :kconfig:option:`CONFIG_BT_RPC_GATT_BUFFER_SIZE` * :kconfig:option:`CONFIG_BT_RPC_INTERNAL_FUNCTIONS` - * :kconfig:option:`CONFIG_CBKPROXY_OUT_SLOTS` - * :kconfig:option:`CONFIG_CBKPROXY_IN_SLOTS` + * :kconfig:option:`CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS` + * :kconfig:option:`CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS` For more details, see the Kconfig option description. diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 2f88e3c7988d..bd83289ee4f5 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -478,7 +478,7 @@ Libraries for NFC nRF RPC libraries ----------------- -|no_changes_yet_note| +* Updated the internal Bluetooth serialization API and Bluetooth callback proxy API to become part of the public NRF RPC API. Other libraries --------------- diff --git a/subsys/bluetooth/rpc/common/cbkproxy.h b/include/nrf_rpc/nrf_rpc_cbkproxy.h similarity index 66% rename from subsys/bluetooth/rpc/common/cbkproxy.h rename to include/nrf_rpc/nrf_rpc_cbkproxy.h index 47c5a7a8834a..95d3c8c8262d 100644 --- a/subsys/bluetooth/rpc/common/cbkproxy.h +++ b/include/nrf_rpc/nrf_rpc_cbkproxy.h @@ -6,49 +6,56 @@ /** * @file - * @defgroup bt_rpc_cbkproxy Bluetooth RPC callback proxy API + * @defgroup nrf_rpc_cbkproxy NRF RPC callback proxy API * @{ - * @brief API for the Bluetooth RPC callback proxy. + * @brief API for the NRF RPC callback proxy. */ -#ifndef CBKPROXY_H -#define CBKPROXY_H +#ifndef NRF_RPC_CBKPROXY_H +#define NRF_RPC_CBKPROXY_H #include +#ifdef __cplusplus +extern "C" { +#endif + /** @brief Creates a handler for output callback proxy. * * It is a variadic macro that takes following parameters: * - * ''CBKPROXY_HANDLER(handler_name, callback_name, [return_type,] + * ''NRF_RPC_CBKPROXY_HANDLER(handler_name, callback_name, [return_type,] * [handler_parameters, callback_arguments])'' * - * @param handler_name name of the handler function that can ne passed to @ref - * cbkproxy_out_get() function. - * @param callback_name Callback that will be called by this handler. Best - * approach is to declare it as 'static inline' to make - * sure that handler and callback will be combined into - * one function during the optimization. This callback - * has the same parameters as the original one (provided - * in ''handler_parameters'') with following parameter - * appended to the end: ''uint32_t callback_slot''. - * @param return_type Optional return type of the callback. It must be - * convertable to ''uint32_t'' without lost of information. - * If it is ''void'' this macro parameter must be skipped. - * @param handler_parameters - * List of parameters with its types enclosed in - * parentheses, e.g. ''(uint8_t *buf, size_t len)''. - * This macro parameter is optional and must be skipped - * if callback does not take any parameres. - * @param callback_arguments - * List of arguments with the same names as in - * ''handler_parameters'' enclosed in parentheses, - * e.g. ''(buf, len)''. This macro parameter is optional - * and must be skipped if callback does not take any - * parameres. + * @param ... - variadic number of parameters: + * + * handler_name - name of the handler function that can be passed to the + * @ref nrf_rpc_cbkproxy_out_get() function. + * + * callback_name - callback that will be called by this handler. Best + * approach is to declare it as 'static inline' to make + * sure that handler and callback will be combined into + * one function during the optimization. This callback + * has the same parameters as the original one (provided + * in ''handler_parameters'') with the following parameter + * appended to the end: ''uint32_t callback_slot''. + * + * return_type - optional return type of the callback. It must be + * convertible to ''uint32_t'' without a loss of information. + * If it is ''void'' this macro parameter must be skipped. + * + * handler_parameters - list of parameters with its types enclosed in + * parentheses, for example, ''(uint8_t *buf, size_t len)''. + * This macro parameter is optional and must be skipped + * if the callback does not take any parameters. + * + * callback_arguments - list of arguments with the same names as in + * ''handler_parameters'' enclosed in parentheses, + * for example, ''(buf, len)''. This macro parameter is optional + * and must be skipped if the callback does not take any parameters. */ -#define CBKPROXY_HANDLER(...) \ +#define NRF_RPC_CBKPROXY_HANDLER(...) \ _CBKPROXY_HANDLER_CAT(_CBKPROXY_HANDLER_, _CBKPROXY_HANDLER_CNT(__VA_ARGS__)) (__VA_ARGS__) #define _CBKPROXY_HANDLER_CNT2(a, b, c, d, e, f, ...) f #define _CBKPROXY_HANDLER_CNT(...) \ @@ -94,9 +101,9 @@ * in multiple source files. * * All parameter must be the same as in related handler defined by - * the CBKPROXY_HANDLER macro except callback_name which should be skipped in this macro. + * the NRF_RPC_CBKPROXY_HANDLER macro except callback_name which should be skipped in this macro. */ -#define CBKPROXY_HANDLER_DECL(...) _CBKPROXY_HANDLER_CAT(_CBKPROXY_HANDLER_DECL_, \ +#define NRF_RPC_CBKPROXY_HANDLER_DECL(...) _CBKPROXY_HANDLER_CAT(_CBKPROXY_HANDLER_DECL_, \ _CBKPROXY_HANDLER_DECL_CNT(__VA_ARGS__)) (__VA_ARGS__) #define _CBKPROXY_HANDLER_DECL_CNT(...) \ _CBKPROXY_HANDLER_CNT2(_, __VA_ARGS__, RET_PARAM, VOID_PARAM, RET_VOID, VOID_VOID) @@ -121,14 +128,14 @@ * * @param index Slot index. * @param handler Pointer to handler function. The function has to be created - * by the @ref CBKPROXY_HANDLER macro. + * by the @ref NRF_RPC_CBKPROXY_HANDLER macro. * @returns Pointer to function that calls provided handler using * provided slot index. The pointer has to be casted to * the same type as handler. NULL when index is too high or * the function was called again with the same index, but * different handler. */ -void *cbkproxy_out_get(int index, void *handler); +void *nrf_rpc_cbkproxy_out_get(int index, void *handler); /** @brief Sets input callback proxy. * @@ -139,7 +146,7 @@ void *cbkproxy_out_get(int index, void *handler); * * @returns Slot number or -1 if no more slots are available. */ -int cbkproxy_in_set(void *callback); +int nrf_rpc_cbkproxy_in_set(void *callback); /** @brief Gets input callback proxy. * @@ -147,6 +154,12 @@ int cbkproxy_in_set(void *callback); * * @returns Callback function or NULL if slot index is invalid. */ -void *cbkproxy_in_get(int index); +void *nrf_rpc_cbkproxy_in_get(int index); + +#ifdef __cplusplus +} +#endif + +/** @} */ -#endif /* CBKPROXY_H */ +#endif /* NRF_RPC_CBKPROXY_H */ diff --git a/subsys/bluetooth/rpc/common/serialize.h b/include/nrf_rpc/nrf_rpc_serialize.h similarity index 62% rename from subsys/bluetooth/rpc/common/serialize.h rename to include/nrf_rpc/nrf_rpc_serialize.h index 279dde5edc52..f877a1e8f141 100644 --- a/subsys/bluetooth/rpc/common/serialize.h +++ b/include/nrf_rpc/nrf_rpc_serialize.h @@ -6,19 +6,21 @@ /** * @file - * @defgroup bt_rpc_serialize Bluetooth RPC serialize API + * @defgroup nrf_rpc_serialize NRF RPC serialize API * @{ - * @brief API for the Bluetooth RPC serialization. + * @brief API for the NRF RPC serialization. */ - -#ifndef SERIALIZE_H_ -#define SERIALIZE_H_ +#ifndef NRF_RPC_SERIALIZE_H_ +#define NRF_RPC_SERIALIZE_H_ #include #include #include +#ifdef __cplusplus +extern "C" { +#endif /** @brief Get a scratchpad item size aligned to 4-byte boundary. * @@ -26,7 +28,7 @@ * * @retval The scratchpad item size rounded up to the next multiple of 4. */ -#define SCRATCHPAD_ALIGN(size) WB_UP(size) +#define NRF_RPC_SCRATCHPAD_ALIGN(size) WB_UP(size) /** @brief Alloc the scratchpad. Scratchpad is used to store a data when decoding serialized data. * @@ -34,16 +36,15 @@ * @param[in] _ctx CBOR decoding context. One unsigned integer will be decoded * from this value that contains scratchpad buffer size. */ -#define SER_SCRATCHPAD_DECLARE(_scratchpad, _ctx) \ - (_scratchpad)->ctx = _ctx; \ - uint32_t _scratchpad_size = ser_decode_uint(_ctx); \ - uint32_t _scratchpad_data[SCRATCHPAD_ALIGN(_scratchpad_size) / sizeof(uint32_t)]; \ - net_buf_simple_init_with_data(&(_scratchpad)->buf, _scratchpad_data, _scratchpad_size); \ +#define NRF_RPC_SCRATCHPAD_DECLARE(_scratchpad, _ctx) \ + (_scratchpad)->ctx = _ctx; \ + uint32_t _scratchpad_size = nrf_rpc_decode_uint(_ctx); \ + uint32_t _scratchpad_data[NRF_RPC_SCRATCHPAD_ALIGN(_scratchpad_size) / sizeof(uint32_t)]; \ + net_buf_simple_init_with_data(&(_scratchpad)->buf, _scratchpad_data, _scratchpad_size); \ net_buf_simple_reset(&(_scratchpad)->buf) - /** @brief Scratchpad structure. */ -struct ser_scratchpad { +struct nrf_rpc_scratchpad { /* CBOR decoding context */ struct nrf_rpc_cbor_ctx *ctx; @@ -59,72 +60,59 @@ struct ser_scratchpad { * * @retval Pointer to the scratchpad item data. */ -static inline void *ser_scratchpad_add(struct ser_scratchpad *scratchpad, size_t size) +static inline void *nrf_rpc_scratchpad_add(struct nrf_rpc_scratchpad *scratchpad, size_t size) { - return net_buf_simple_add(&scratchpad->buf, SCRATCHPAD_ALIGN(size)); + return net_buf_simple_add(&scratchpad->buf, NRF_RPC_SCRATCHPAD_ALIGN(size)); } /** @brief Encode a null value. * * @param[in,out] ctx Structure used to encode CBOR stream. */ -void ser_encode_null(struct nrf_rpc_cbor_ctx *ctx); +void nrf_rpc_encode_null(struct nrf_rpc_cbor_ctx *ctx); /** @brief Encode an undefined value. * * @param[in,out] ctx Structure used to encode CBOR stream. */ -void ser_encode_undefined(struct nrf_rpc_cbor_ctx *ctx); +void nrf_rpc_encode_undefined(struct nrf_rpc_cbor_ctx *ctx); /** @brief Encode a boolean value. * * @param[in,out] ctx Structure used to encode CBOR stream. + * @param[in] value Encoded value. */ -void ser_encode_bool(struct nrf_rpc_cbor_ctx *ctx, bool value); +void nrf_rpc_encode_bool(struct nrf_rpc_cbor_ctx *ctx, bool value); /** @brief Encode an unsigned integer value. * * @param[in,out] ctx Structure used to encode CBOR stream. + * @param[in] value Encoded value. */ -void ser_encode_uint(struct nrf_rpc_cbor_ctx *ctx, uint32_t value); +void nrf_rpc_encode_uint(struct nrf_rpc_cbor_ctx *ctx, uint32_t value); /** @brief Encode an integer value. * * @param[in,out] ctx Structure used to encode CBOR stream. + * @param[in] value Encoded value. */ -void ser_encode_int(struct nrf_rpc_cbor_ctx *ctx, int32_t value); - -/** @brief Encode an unsigned 64-bit integer value. - * - * @param[in,out] ctx Structure used to encode CBOR stream. - */ -void ser_encode_uint64(struct nrf_rpc_cbor_ctx *ctx, uint64_t value); - -/** @brief Encode a 64-bit integer value. - * - * @param[in,out] ctx Structure used to encode CBOR stream. - */ -void ser_encode_int64(struct nrf_rpc_cbor_ctx *ctx, int64_t value); +void nrf_rpc_encode_int(struct nrf_rpc_cbor_ctx *ctx, int32_t value); /** @brief Encode a string value. * * @param[in,out] ctx CBOR encoding context. * @param[in] value String to encode. * @param[in] len String length. - * - * @param[in,out] encoder Structure used to encode CBOR stream. */ -void ser_encode_str(struct nrf_rpc_cbor_ctx *ctx, const char *value, int len); +void nrf_rpc_encode_str(struct nrf_rpc_cbor_ctx *ctx, const char *value, int len); /** @brief Encode a buffer. * * @param[in,out] ctx CBOR encoding context. * @param[in] data Buffer to encode. * @param[in] size Buffer size. - * - * @param[in,out] encoder Structure used to encode CBOR stream. */ -void ser_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t size); +void nrf_rpc_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t size); /** @brief Encode a callback. * @@ -134,16 +122,16 @@ void ser_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t si * @param[in,out] ctx CBOR encoding context. * @param[in] callback Callback to encode. */ -void ser_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback); +void nrf_rpc_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback); /** @brief Encode a callback slot number. * * @param[in,out] ctx CBOR encoding context. * @param[in] slot Callback slot number to encode. */ -static inline void ser_encode_callback_call(struct nrf_rpc_cbor_ctx *ctx, uint32_t slot) +static inline void nrf_rpc_encode_callback_call(struct nrf_rpc_cbor_ctx *ctx, uint32_t slot) { - ser_encode_uint(ctx, slot); + nrf_rpc_encode_uint(ctx, slot); } /** @brief Put encode into an invalid state. All further encoding on this encoder will be ignored. @@ -151,13 +139,13 @@ static inline void ser_encode_callback_call(struct nrf_rpc_cbor_ctx *ctx, uint32 * * @param[in,out] ctx CBOR encoding context. */ -void ser_encoder_invalid(struct nrf_rpc_cbor_ctx *ctx); +void nrf_rpc_encoder_invalid(struct nrf_rpc_cbor_ctx *ctx); /** @brief Skip one value to decode. * * @param[in] ctx CBOR decoding context. */ -void ser_decode_skip(struct nrf_rpc_cbor_ctx *ctx); +void nrf_rpc_decode_skip(struct nrf_rpc_cbor_ctx *ctx); /** @brief Check if value is a null. This function will not consume the value. * @@ -166,7 +154,7 @@ void ser_decode_skip(struct nrf_rpc_cbor_ctx *ctx); * @retval True, if value is a null. * Otherwise, false will be returned. */ -bool ser_decode_is_null(struct nrf_rpc_cbor_ctx *ctx); +bool nrf_rpc_decode_is_null(struct nrf_rpc_cbor_ctx *ctx); /** @brief Check if value is an undefined. This function will not consume the value. * @@ -175,7 +163,7 @@ bool ser_decode_is_null(struct nrf_rpc_cbor_ctx *ctx); * @retval True, if value is an undefined. * Otherwise, false will be returned. */ -bool ser_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx); +bool nrf_rpc_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx); /** @brief Decode a boolean value. * @@ -183,7 +171,7 @@ bool ser_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx); * * @retval Decoded boolean value. */ -bool ser_decode_bool(struct nrf_rpc_cbor_ctx *ctx); +bool nrf_rpc_decode_bool(struct nrf_rpc_cbor_ctx *ctx); /** @brief Decode an unsigned integer value. * @@ -191,7 +179,7 @@ bool ser_decode_bool(struct nrf_rpc_cbor_ctx *ctx); * * @retval Decoded unsigned integer value. */ -uint32_t ser_decode_uint(struct nrf_rpc_cbor_ctx *ctx); +uint32_t nrf_rpc_decode_uint(struct nrf_rpc_cbor_ctx *ctx); /** @brief Decode a integer value. * @@ -199,33 +187,17 @@ uint32_t ser_decode_uint(struct nrf_rpc_cbor_ctx *ctx); * * @retval Decoded integer value. */ -int32_t ser_decode_int(struct nrf_rpc_cbor_ctx *ctx); - -/** @brief Decode an unsigned 64-bit integer value. - * - * @param[in,out] ctx CBOR decoding context. - * - * @retval Decoded an unsigned 64-bit integer value. - */ -uint64_t ser_decode_uint64(struct nrf_rpc_cbor_ctx *ctx); - -/** @brief Decode a 64-bit integer value. - * - * @param[in,out] ctx CBOR decoding context. - * - * @retval Decoded a 64-bit integer value. - */ -int64_t ser_decode_int64(struct nrf_rpc_cbor_ctx *ctx); +int32_t nrf_rpc_decode_int(struct nrf_rpc_cbor_ctx *ctx); /** @brief Decode a string value. * * @param[in,out] ctx CBOR decoding context. * @param[out] buffer Buffer for decoded string. - * @param[in] size Buffer size. + * @param[in] buffer_size Buffer size. * * @retval Pointer to a decoded string. */ -char *ser_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_size); +char *nrf_rpc_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_size); /** Decode a string value into a scratchpad. * @@ -234,17 +206,17 @@ char *ser_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_s * * @retval Pointer to a decoded string. */ -char *ser_decode_str_into_scratchpad(struct ser_scratchpad *scratchpad, size_t *len); +char *nrf_rpc_decode_str_into_scratchpad(struct nrf_rpc_scratchpad *scratchpad, size_t *len); /** @brief Decode a buffer. * * @param[in,out] ctx CBOR decoding context. * @param[out] buffer Buffer for a decoded buffer data. - * @param[in] size Buffer size. + * @param[in] buffer_size Buffer size. * * @retval Pointer to a decoded buffer. */ -void *ser_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffer_size); +void *nrf_rpc_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffer_size); /** @brief Decode buffer pointer and length. Moves CBOR buffer pointer past buffer on success. * @@ -253,7 +225,7 @@ void *ser_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffe * * @retval Pointer to a buffer within CBOR stream or NULL on error. */ -const void *ser_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t *size); +const void *nrf_rpc_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t *size); /** @brief Decode buffer into a scratchpad. * @@ -262,21 +234,21 @@ const void *ser_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t * * @retval Pointer to a decoded buffer data. */ -void *ser_decode_buffer_into_scratchpad(struct ser_scratchpad *scratchpad, size_t *len); +void *nrf_rpc_decode_buffer_into_scratchpad(struct nrf_rpc_scratchpad *scratchpad, size_t *len); /** @brief Decode a callback. * * This function will use callback proxy module to associate decoded integer * (slot number) with provided handler and returned function pointer. * - * @param[in] value Value parsed from the CBOR stream. + * @param[in] ctx CBOR decoding context. * @param[in] handler Function which will be called when callback returned by * this function is called. The handler must be defined by - * @ref CBKPROXY_HANDLER. + * @ref NRF_RPC_CBKPROXY_HANDLER. * * @retval Decoded callback. */ -void *ser_decode_callback(struct nrf_rpc_cbor_ctx *ctx, void *handler); +void *nrf_rpc_decode_callbackd(struct nrf_rpc_cbor_ctx *ctx, void *handler); /** @brief Decode callback slot. * @@ -287,16 +259,16 @@ void *ser_decode_callback(struct nrf_rpc_cbor_ctx *ctx, void *handler); * * @retval Callback assigned to the slot encoded in the value parameter. */ -void *ser_decode_callback_call(struct nrf_rpc_cbor_ctx *value); +void *nrf_rpc_decode_callback_call(struct nrf_rpc_cbor_ctx *ctx); /** @brief Put decoder into an invalid state and set error code that caused it. * All further decoding on this decoder will be ignored. - * Invalid state can be checked with the ser_decode_valid() function. + * Invalid state can be checked with the nrf_rpc_decode_valid() function. * - * @param[in] value Value parsed from the CBOR stream. + * @param[in] ctx CBOR decoding context. * @param[in] err Cbor error code to set. */ -void ser_decoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err); +void nrf_rpc_decoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err); /** @brief Returns if decoder is in valid state. * @@ -305,7 +277,7 @@ void ser_decoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err); * @retval True if decoder is in valid state which means that no error occurred * so far. Otherwise, false will be returned. */ -bool ser_decode_valid(const struct nrf_rpc_cbor_ctx *ctx); +bool nrf_rpc_decode_valid(const struct nrf_rpc_cbor_ctx *ctx); /** @brief Signalize that decoding is done. Use this function when you finish decoding of the * received serialized packet. @@ -316,7 +288,8 @@ bool ser_decode_valid(const struct nrf_rpc_cbor_ctx *ctx); * @retval True if decoding finshed with success. * Otherwise, false will be returned. */ -bool ser_decoding_done_and_check(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx); +bool nrf_rpc_decoding_done_and_check(const struct nrf_rpc_group *group, + struct nrf_rpc_cbor_ctx *ctx); /** @brief Decode a command response as a boolean value. * @@ -324,8 +297,8 @@ bool ser_decoding_done_and_check(const struct nrf_rpc_group *group, struct nrf_r * @param[in,out] ctx CBOR decoding context. * @param[in] handler_data Pointer to place where value will be decoded. */ -void ser_rsp_decode_bool(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data); +void nrf_rpc_rsp_decode_bool(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data); /** @brief Decode a command response as an unsigned 8-bit integer value. * @@ -333,8 +306,8 @@ void ser_rsp_decode_bool(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ * @param[in,out] ctx CBOR decoding context. * @param[in] handler_data Pointer to place where value will be decoded. */ -void ser_rsp_decode_u8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data); +void nrf_rpc_rsp_decode_u8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data); /** @brief Decode a command response as an unsigned 16-bit integer value. * @@ -342,8 +315,8 @@ void ser_rsp_decode_u8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ct * @param[in,out] ctx CBOR decoding context. * @param[in] handler_data Pointer to place where value will be decoded. */ -void ser_rsp_decode_u16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data); +void nrf_rpc_rsp_decode_u16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data); /** @brief Decode a command response as an integer value. * @@ -351,8 +324,8 @@ void ser_rsp_decode_u16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_c * @param[in,out] ctx CBOR decoding context. * @param[in] handler_data Pointer to place where value will be decoded. */ -void ser_rsp_decode_i32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data); +void nrf_rpc_rsp_decode_i32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data); /** @brief Decode a command response as a void value. * @@ -360,34 +333,40 @@ void ser_rsp_decode_i32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_c * @param[in,out] ctx CBOR decoding context. * @param[in] handler_data Pointer to place where value will be decoded. */ -void ser_rsp_decode_void(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data); +void nrf_rpc_rsp_decode_void(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data); /** @brief Send response to a command as an integer value. * * @param[in] group nRF RPC group. * @param[in] response Integer value to send. */ -void ser_rsp_send_int(const struct nrf_rpc_group *group, int32_t response); +void nrf_rpc_rsp_send_int(const struct nrf_rpc_group *group, int32_t response); /** @brief Send response to a command as an unsigned integer value. * * @param[in] group nRF RPC group. * @param[in] response Unsigned integer value to send. */ -void ser_rsp_send_uint(const struct nrf_rpc_group *group, uint32_t response); +void nrf_rpc_rsp_send_uint(const struct nrf_rpc_group *group, uint32_t response); /** @brief Send response to a command as a boolean value. * * @param[in] group nRF RPC group. * @param[in] response Boolean value to send. */ -void ser_rsp_send_bool(const struct nrf_rpc_group *group, bool response); +void nrf_rpc_rsp_send_bool(const struct nrf_rpc_group *group, bool response); /** @brief Send response to a command as a void. * * @param[in] group nRF RPC group. */ -void ser_rsp_send_void(const struct nrf_rpc_group *group); +void nrf_rpc_rsp_send_void(const struct nrf_rpc_group *group); + +#ifdef __cplusplus +} +#endif + +/** @} */ -#endif /* SERIALIZE_H_ */ +#endif /* NRF_RPC_SERIALIZE_H_ */ diff --git a/subsys/bluetooth/rpc/Kconfig b/subsys/bluetooth/rpc/Kconfig index fa066c52c569..b10e188ef52f 100644 --- a/subsys/bluetooth/rpc/Kconfig +++ b/subsys/bluetooth/rpc/Kconfig @@ -54,27 +54,6 @@ config BT_RPC_INITIALIZE_NRF_RPC Initialize nRF RPC library during the system startup. Disabling this option allow user to initialize it in a different way. -config CBKPROXY_OUT_SLOTS - int "Maximum number of RPC callback proxy output slots" - default 16 - range 0 16383 - help - Output slot is used to save context for one callback that is called - on local side, encoded, sent and finally executed on the remote side. - Each output slot takes 8 bytes of flash memory. Maximum number of - input slots on the remote side should be the same as this value. - - -config CBKPROXY_IN_SLOTS - int "Maximum number of RPC callback proxy input slots" - default 16 - range 0 16383 - help - Input slot is used to save context for one callback that is called - on remote side, encoded, sent and finally executed on the local side. - Each output slot takes 8 bytes of RAM memory. Maximum number of - output slots on the remote side should be the same as this value. - config BT_RPC_GATT_SRV_MAX int "Maximum number of GATT services" default 4 diff --git a/subsys/bluetooth/rpc/client/bt_rpc_conn_client.c b/subsys/bluetooth/rpc/client/bt_rpc_conn_client.c index a1a68aa58eac..c442b7a6ac11 100644 --- a/subsys/bluetooth/rpc/client/bt_rpc_conn_client.c +++ b/subsys/bluetooth/rpc/client/bt_rpc_conn_client.c @@ -9,8 +9,8 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include static void report_decoding_error(uint8_t cmd_evt_id, void *data) @@ -60,7 +60,7 @@ void bt_rpc_encode_bt_conn(struct nrf_rpc_cbor_ctx *encoder, const struct bt_con */ index = conn ? get_conn_index(conn) : CONFIG_BT_MAX_CONN; - ser_encode_uint(encoder, index); + nrf_rpc_encode_uint(encoder, index); } } @@ -69,9 +69,9 @@ struct bt_conn *bt_rpc_decode_bt_conn(struct nrf_rpc_cbor_ctx *ctx) uint8_t index = 0; if (CONFIG_BT_MAX_CONN > 1) { - index = ser_decode_uint(ctx); + index = nrf_rpc_decode_uint(ctx); if (index >= CONFIG_BT_MAX_CONN) { - ser_decoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); + nrf_rpc_decoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); return NULL; } } @@ -86,10 +86,10 @@ static void bt_conn_remote_update_ref(struct bt_conn *conn, int8_t value) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_int(&ctx, value); + nrf_rpc_encode_int(&ctx, value); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_REMOTE_UPDATE_REF_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } static void bt_conn_ref_local(struct bt_conn *conn) @@ -128,16 +128,16 @@ static void bt_conn_foreach_cb_callback_rpc_handler(const struct nrf_rpc_group * bt_conn_foreach_cb callback_slot; conn = bt_rpc_decode_bt_conn(ctx); - data = (void *)ser_decode_uint(ctx); - callback_slot = (bt_conn_foreach_cb)ser_decode_callback_call(ctx); + data = (void *)nrf_rpc_decode_uint(ctx); + callback_slot = (bt_conn_foreach_cb)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(conn, data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -156,12 +156,12 @@ void bt_conn_foreach(enum bt_conn_type type, void (*func)(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_int(&ctx, type); - ser_encode_callback(&ctx, func); - ser_encode_uint(&ctx, (uintptr_t)data); + nrf_rpc_encode_int(&ctx, type); + nrf_rpc_encode_callback(&ctx, func); + nrf_rpc_encode_uint(&ctx, (uintptr_t)data); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_FOREACH_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } struct bt_conn_lookup_addr_le_rpc_res { @@ -190,8 +190,8 @@ struct bt_conn *bt_conn_lookup_addr_le(uint8_t id, const bt_addr_le_t *peer) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); - ser_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_LOOKUP_ADDR_LE_RPC_CMD, &ctx, bt_conn_lookup_addr_le_rpc_rsp, &result); @@ -212,8 +212,8 @@ static void bt_conn_get_dst_out_rpc_rsp(const struct nrf_rpc_group *group, struct bt_conn_get_dst_out_rpc_res *res = (struct bt_conn_get_dst_out_rpc_res *)handler_data; - res->result = ser_decode_bool(ctx); - ser_decode_buffer(ctx, res->dst, sizeof(bt_addr_le_t)); + res->result = nrf_rpc_decode_bool(ctx); + nrf_rpc_decode_buffer(ctx, res->dst, sizeof(bt_addr_le_t)); } static bool bt_conn_get_dst_out(const struct bt_conn *conn, bt_addr_le_t *dst) @@ -255,8 +255,8 @@ uint8_t bt_conn_index(const struct bt_conn *conn) #if defined(CONFIG_BT_USER_PHY_UPDATE) static void bt_conn_le_phy_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn_le_phy_info *data) { - data->tx_phy = ser_decode_uint(ctx); - data->rx_phy = ser_decode_uint(ctx); + data->tx_phy = nrf_rpc_decode_uint(ctx); + data->rx_phy = nrf_rpc_decode_uint(ctx); } #endif /* defined(CONFIG_BT_USER_PHY_UPDATE) */ @@ -264,56 +264,56 @@ static void bt_conn_le_phy_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn static void bt_conn_le_data_len_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn_le_data_len_info *data) { - data->tx_max_len = ser_decode_uint(ctx); - data->tx_max_time = ser_decode_uint(ctx); - data->rx_max_len = ser_decode_uint(ctx); - data->rx_max_time = ser_decode_uint(ctx); + data->tx_max_len = nrf_rpc_decode_uint(ctx); + data->tx_max_time = nrf_rpc_decode_uint(ctx); + data->rx_max_len = nrf_rpc_decode_uint(ctx); + data->rx_max_time = nrf_rpc_decode_uint(ctx); } #endif /* defined(CONFIG_BT_USER_DATA_LEN_UPDATE) */ static void bt_conn_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn *conn, struct bt_conn_info *info) { - info->type = ser_decode_uint(ctx); - info->role = ser_decode_uint(ctx); - info->id = ser_decode_uint(ctx); + info->type = nrf_rpc_decode_uint(ctx); + info->role = nrf_rpc_decode_uint(ctx); + info->id = nrf_rpc_decode_uint(ctx); if (info->type == BT_CONN_TYPE_LE) { - info->le.interval = ser_decode_uint(ctx); - info->le.latency = ser_decode_uint(ctx); - info->le.timeout = ser_decode_uint(ctx); + info->le.interval = nrf_rpc_decode_uint(ctx); + info->le.latency = nrf_rpc_decode_uint(ctx); + info->le.timeout = nrf_rpc_decode_uint(ctx); LOCK_CONN_INFO(); - info->le.src = ser_decode_buffer(ctx, &conn->src, sizeof(bt_addr_le_t)); - info->le.dst = ser_decode_buffer(ctx, &conn->dst, sizeof(bt_addr_le_t)); - info->le.local = ser_decode_buffer(ctx, &conn->local, sizeof(bt_addr_le_t)); - info->le.remote = ser_decode_buffer(ctx, &conn->remote, sizeof(bt_addr_le_t)); + info->le.src = nrf_rpc_decode_buffer(ctx, &conn->src, sizeof(bt_addr_le_t)); + info->le.dst = nrf_rpc_decode_buffer(ctx, &conn->dst, sizeof(bt_addr_le_t)); + info->le.local = nrf_rpc_decode_buffer(ctx, &conn->local, sizeof(bt_addr_le_t)); + info->le.remote = nrf_rpc_decode_buffer(ctx, &conn->remote, sizeof(bt_addr_le_t)); #if defined(CONFIG_BT_USER_PHY_UPDATE) - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { info->le.phy = NULL; } else { info->le.phy = &conn->phy; bt_conn_le_phy_info_dec(ctx, &conn->phy); } #else - ser_decode_skip(ctx); + nrf_rpc_decode_skip(ctx); #endif #if defined(CONFIG_BT_USER_DATA_LEN_UPDATE) - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { info->le.data_len = NULL; } else { info->le.data_len = &conn->data_len; bt_conn_le_data_len_info_dec(ctx, &conn->data_len); } #else - ser_decode_skip(ctx); + nrf_rpc_decode_skip(ctx); #endif - info->state = ser_decode_uint(ctx); + info->state = nrf_rpc_decode_uint(ctx); UNLOCK_CONN_INFO(); } else { /* non-LE connection types are not supported. */ - ser_decoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); + nrf_rpc_decoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); } } @@ -331,7 +331,7 @@ static void bt_conn_get_info_rpc_rsp(const struct nrf_rpc_group *group, struct bt_conn_get_info_rpc_res *res = (struct bt_conn_get_info_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); bt_conn_info_dec(ctx, res->conn, res->info); } @@ -358,19 +358,19 @@ int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info) static void bt_conn_remote_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn *conn, struct bt_conn_remote_info *remote_info) { - remote_info->type = ser_decode_uint(ctx); - remote_info->version = ser_decode_uint(ctx); - remote_info->manufacturer = ser_decode_uint(ctx); - remote_info->subversion = ser_decode_uint(ctx); + remote_info->type = nrf_rpc_decode_uint(ctx); + remote_info->version = nrf_rpc_decode_uint(ctx); + remote_info->manufacturer = nrf_rpc_decode_uint(ctx); + remote_info->subversion = nrf_rpc_decode_uint(ctx); if (remote_info->type == BT_CONN_TYPE_LE && conn != NULL) { LOCK_CONN_INFO(); remote_info->le.features = - ser_decode_buffer(ctx, &conn->features, sizeof(conn->features)); + nrf_rpc_decode_buffer(ctx, &conn->features, sizeof(conn->features)); UNLOCK_CONN_INFO(); } else { /* non-LE connection types are not supported. */ - ser_decoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); + nrf_rpc_decoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); } } @@ -387,7 +387,7 @@ static void bt_conn_get_remote_info_rpc_rsp(const struct nrf_rpc_group *group, struct bt_conn_get_remote_info_rpc_res *res = (struct bt_conn_get_remote_info_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); bt_conn_remote_info_dec(ctx, res->conn, res->remote_info); } @@ -415,18 +415,18 @@ int bt_conn_get_remote_info(struct bt_conn *conn, static void bt_le_conn_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_conn_param *data) { - ser_encode_uint(encoder, data->interval_min); - ser_encode_uint(encoder, data->interval_max); - ser_encode_uint(encoder, data->latency); - ser_encode_uint(encoder, data->timeout); + nrf_rpc_encode_uint(encoder, data->interval_min); + nrf_rpc_encode_uint(encoder, data->interval_max); + nrf_rpc_encode_uint(encoder, data->latency); + nrf_rpc_encode_uint(encoder, data->timeout); } static void bt_le_conn_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_conn_param *data) { - data->interval_min = ser_decode_uint(ctx); - data->interval_max = ser_decode_uint(ctx); - data->latency = ser_decode_uint(ctx); - data->timeout = ser_decode_uint(ctx); + data->interval_min = nrf_rpc_decode_uint(ctx); + data->interval_max = nrf_rpc_decode_uint(ctx); + data->latency = nrf_rpc_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); } int bt_conn_le_param_update(struct bt_conn *conn, @@ -442,7 +442,7 @@ int bt_conn_le_param_update(struct bt_conn *conn, bt_le_conn_param_enc(&ctx, param); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_LE_PARAM_UPDATE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -451,8 +451,8 @@ int bt_conn_le_param_update(struct bt_conn *conn, static void bt_conn_le_data_len_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn_le_data_len_param *data) { - ser_encode_uint(encoder, data->tx_max_len); - ser_encode_uint(encoder, data->tx_max_time); + nrf_rpc_encode_uint(encoder, data->tx_max_len); + nrf_rpc_encode_uint(encoder, data->tx_max_time); } int bt_conn_le_data_len_update(struct bt_conn *conn, @@ -468,7 +468,7 @@ int bt_conn_le_data_len_update(struct bt_conn *conn, bt_conn_le_data_len_param_enc(&ctx, param); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_LE_DATA_LEN_UPDATE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -478,9 +478,9 @@ int bt_conn_le_data_len_update(struct bt_conn *conn, static void bt_conn_le_phy_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn_le_phy_param *data) { - ser_encode_uint(encoder, data->options); - ser_encode_uint(encoder, data->pref_tx_phy); - ser_encode_uint(encoder, data->pref_rx_phy); + nrf_rpc_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->pref_tx_phy); + nrf_rpc_encode_uint(encoder, data->pref_rx_phy); } int bt_conn_le_phy_update(struct bt_conn *conn, @@ -496,7 +496,7 @@ int bt_conn_le_phy_update(struct bt_conn *conn, bt_conn_le_phy_param_enc(&ctx, param); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_LE_PHY_UPDATE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -512,10 +512,10 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, reason); + nrf_rpc_encode_uint(&ctx, reason); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_DISCONNECT_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -524,12 +524,12 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason) static void bt_conn_le_create_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn_le_create_param *data) { - ser_encode_uint(encoder, data->options); - ser_encode_uint(encoder, data->interval); - ser_encode_uint(encoder, data->window); - ser_encode_uint(encoder, data->interval_coded); - ser_encode_uint(encoder, data->window_coded); - ser_encode_uint(encoder, data->timeout); + nrf_rpc_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->interval); + nrf_rpc_encode_uint(encoder, data->window); + nrf_rpc_encode_uint(encoder, data->interval_coded); + nrf_rpc_encode_uint(encoder, data->window_coded); + nrf_rpc_encode_uint(encoder, data->timeout); } struct bt_conn_le_create_rpc_res { @@ -545,7 +545,7 @@ static void bt_conn_le_create_rpc_rsp(const struct nrf_rpc_group *group, struct bt_conn_le_create_rpc_res *res = (struct bt_conn_le_create_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); *(res->conn) = bt_rpc_decode_bt_conn(ctx); bt_conn_ref_local(*(res->conn)); @@ -564,7 +564,7 @@ int bt_conn_le_create(const bt_addr_le_t *peer, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); bt_conn_le_create_param_enc(&ctx, create_param); bt_le_conn_param_enc(&ctx, conn_param); @@ -590,7 +590,7 @@ int bt_conn_le_create_auto(const struct bt_conn_le_create_param *create_param, bt_le_conn_param_enc(&ctx, conn_param); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_LE_CREATE_AUTO_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -604,7 +604,7 @@ int bt_conn_create_auto_stop(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CREATE_AUTO_STOP_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -623,15 +623,15 @@ int bt_le_set_auto_conn(const bt_addr_le_t *addr, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); if (param == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else { bt_le_conn_param_enc(&ctx, param); } nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SET_AUTO_CONN_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -648,10 +648,10 @@ int bt_conn_set_security(struct bt_conn *conn, bt_security_t sec) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uint32_t)sec); + nrf_rpc_encode_uint(&ctx, (uint32_t)sec); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_SET_SECURITY_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -668,7 +668,7 @@ static void bt_conn_get_security_rpc_rsp(const struct nrf_rpc_group *group, struct bt_conn_get_security_rpc_res *res = (struct bt_conn_get_security_rpc_res *)handler_data; - res->result = (bt_security_t)ser_decode_uint(ctx); + res->result = (bt_security_t)nrf_rpc_decode_uint(ctx); } bt_security_t bt_conn_get_security(const struct bt_conn *conn) @@ -698,7 +698,7 @@ uint8_t bt_conn_enc_key_size(const struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_ENC_KEY_SIZE_RPC_CMD, - &ctx, ser_rsp_decode_u8, &result); + &ctx, nrf_rpc_rsp_decode_u8, &result); return result; } @@ -731,15 +731,15 @@ static void bt_conn_cb_connected_call_rpc_handler(const struct nrf_rpc_group *gr uint8_t err; conn = bt_rpc_decode_bt_conn(ctx); - err = ser_decode_uint(ctx); + err = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_connected_call(conn, err); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -774,15 +774,15 @@ static void bt_conn_cb_disconnected_call_rpc_handler(const struct nrf_rpc_group uint8_t reason; conn = bt_rpc_decode_bt_conn(ctx); - reason = ser_decode_uint(ctx); + reason = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_disconnected_call(conn, reason); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -827,13 +827,13 @@ static void bt_conn_cb_le_param_req_call_rpc_handler(const struct nrf_rpc_group conn = bt_rpc_decode_bt_conn(ctx); bt_le_conn_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_cb_le_param_req_call(conn, ¶m); - ser_rsp_send_bool(group, result); + nrf_rpc_rsp_send_bool(group, result); return; decoding_error: @@ -872,17 +872,17 @@ static void bt_conn_cb_le_param_updated_call_rpc_handler(const struct nrf_rpc_gr uint16_t timeout; conn = bt_rpc_decode_bt_conn(ctx); - interval = ser_decode_uint(ctx); - latency = ser_decode_uint(ctx); - timeout = ser_decode_uint(ctx); + interval = nrf_rpc_decode_uint(ctx); + latency = nrf_rpc_decode_uint(ctx); + timeout = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_le_param_updated_call(conn, interval, latency, timeout); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -923,16 +923,16 @@ static void bt_conn_cb_identity_resolved_call_rpc_handler(const struct nrf_rpc_g const bt_addr_le_t *identity; conn = bt_rpc_decode_bt_conn(ctx); - rpa = ser_decode_buffer(ctx, &rpa_data, sizeof(bt_addr_le_t)); - identity = ser_decode_buffer(ctx, &identity_data, sizeof(bt_addr_le_t)); + rpa = nrf_rpc_decode_buffer(ctx, &rpa_data, sizeof(bt_addr_le_t)); + identity = nrf_rpc_decode_buffer(ctx, &identity_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_identity_resolved_call(conn, rpa, identity); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -972,16 +972,16 @@ static void bt_conn_cb_security_changed_call_rpc_handler(const struct nrf_rpc_gr enum bt_security_err err; conn = bt_rpc_decode_bt_conn(ctx); - level = (bt_security_t)ser_decode_uint(ctx); - err = (enum bt_security_err)ser_decode_uint(ctx); + level = (bt_security_t)nrf_rpc_decode_uint(ctx); + err = (enum bt_security_err)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_security_changed_call(conn, level, err); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1024,13 +1024,13 @@ static void bt_conn_cb_remote_info_available_call_rpc_handler(const struct nrf_r bt_conn_remote_info_dec(ctx, conn, &remote_info); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_remote_info_available_call(conn, &remote_info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1070,13 +1070,13 @@ static void bt_conn_cb_le_phy_updated_call_rpc_handler(const struct nrf_rpc_grou conn = bt_rpc_decode_bt_conn(ctx); bt_conn_le_phy_info_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_le_phy_updated_call(conn, ¶m); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1117,13 +1117,13 @@ static void bt_conn_cb_le_data_len_updated_call_rpc_handler(const struct nrf_rpc conn = bt_rpc_decode_bt_conn(ctx); bt_conn_le_data_len_info_dec(ctx, &info); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_cb_le_data_len_updated_call(conn, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1144,7 +1144,7 @@ static void bt_conn_cb_register_on_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_REGISTER_ON_REMOTE_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } int bt_conn_cb_register(struct bt_conn_cb *cb) @@ -1175,7 +1175,7 @@ static int bt_conn_cb_unregister_on_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_UNREGISTER_ON_REMOTE_RPC_CMD, &ctx, - ser_rsp_decode_i32, &result); + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1206,10 +1206,10 @@ void bt_set_bondable(bool enable) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_bool(&ctx, enable); + nrf_rpc_encode_bool(&ctx, enable); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_SET_BONDABLE_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } void bt_le_oob_set_legacy_flag(bool enable) @@ -1219,10 +1219,10 @@ void bt_le_oob_set_legacy_flag(bool enable) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_bool(&ctx, enable); + nrf_rpc_encode_bool(&ctx, enable); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_OOB_SET_LEGACY_FLAG_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } void bt_le_oob_set_sc_flag(bool enable) @@ -1232,10 +1232,10 @@ void bt_le_oob_set_sc_flag(bool enable) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_bool(&ctx, enable); + nrf_rpc_encode_bool(&ctx, enable); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_OOB_SET_SC_FLAG_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } #if !defined(CONFIG_BT_SMP_SC_PAIR_ONLY) @@ -1250,16 +1250,16 @@ int bt_le_oob_set_legacy_tk(struct bt_conn *conn, const uint8_t *tk) tk_size = sizeof(uint8_t) * 16; buffer_size_max += tk_size; - scratchpad_size += SCRATCHPAD_ALIGN(tk_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(tk_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_buffer(&ctx, tk, tk_size); + nrf_rpc_encode_buffer(&ctx, tk, tk_size); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_OOB_SET_LEGACY_TK_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1279,14 +1279,14 @@ size_t bt_le_oob_sc_data_buf_size(const struct bt_le_oob_sc_data *data) static void bt_le_oob_sc_data_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_oob_sc_data *data) { - ser_encode_buffer(encoder, data->r, 16 * sizeof(uint8_t)); - ser_encode_buffer(encoder, data->c, 16 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, data->r, 16 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, data->c, 16 * sizeof(uint8_t)); } static void bt_le_oob_sc_data_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_oob_sc_data *data) { - ser_decode_buffer(ctx, data->r, 16 * sizeof(uint8_t)); - ser_decode_buffer(ctx, data->c, 16 * sizeof(uint8_t)); + nrf_rpc_decode_buffer(ctx, data->r, 16 * sizeof(uint8_t)); + nrf_rpc_decode_buffer(ctx, data->c, 16 * sizeof(uint8_t)); } int bt_le_oob_set_sc_data(struct bt_conn *conn, @@ -1304,18 +1304,18 @@ int bt_le_oob_set_sc_data(struct bt_conn *conn, bt_rpc_encode_bt_conn(&ctx, conn); if (oobd_local == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else { bt_le_oob_sc_data_enc(&ctx, oobd_local); } if (oobd_remote == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else { bt_le_oob_sc_data_enc(&ctx, oobd_remote); } nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_OOB_SET_SC_DATA_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1333,16 +1333,16 @@ static void bt_le_oob_get_sc_data_rpc_rsp(const struct nrf_rpc_group *group, struct bt_le_oob_get_sc_data_rpc_res *res = (struct bt_le_oob_get_sc_data_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { *res->oobd_local = NULL; } else { *res->oobd_local = &res->conn->oobd_local; bt_le_oob_sc_data_dec(ctx, &res->conn->oobd_local); } - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { *res->oobd_remote = NULL; } else { *res->oobd_remote = &res->conn->oobd_remote; @@ -1382,10 +1382,10 @@ int bt_passkey_set(unsigned int passkey) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, passkey); + nrf_rpc_encode_uint(&ctx, passkey); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_PASSKEY_SET_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1397,12 +1397,12 @@ static const struct bt_conn_auth_cb *auth_cb; static void bt_conn_pairing_feat_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn_pairing_feat *data) { - data->io_capability = ser_decode_uint(ctx); - data->oob_data_flag = ser_decode_uint(ctx); - data->auth_req = ser_decode_uint(ctx); - data->max_enc_key_size = ser_decode_uint(ctx); - data->init_key_dist = ser_decode_uint(ctx); - data->resp_key_dist = ser_decode_uint(ctx); + data->io_capability = nrf_rpc_decode_uint(ctx); + data->oob_data_flag = nrf_rpc_decode_uint(ctx); + data->auth_req = nrf_rpc_decode_uint(ctx); + data->max_enc_key_size = nrf_rpc_decode_uint(ctx); + data->init_key_dist = nrf_rpc_decode_uint(ctx); + data->resp_key_dist = nrf_rpc_decode_uint(ctx); } static void bt_rpc_auth_cb_pairing_accept_rpc_handler(const struct nrf_rpc_group *group, @@ -1417,7 +1417,7 @@ static void bt_rpc_auth_cb_pairing_accept_rpc_handler(const struct nrf_rpc_group conn = bt_rpc_decode_bt_conn(ctx); bt_conn_pairing_feat_dec(ctx, &feat); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1432,7 +1432,7 @@ static void bt_rpc_auth_cb_pairing_accept_rpc_handler(const struct nrf_rpc_group NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_uint(&ectx, (uint32_t)result); + nrf_rpc_encode_uint(&ectx, (uint32_t)result); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -1455,9 +1455,9 @@ static void bt_rpc_auth_cb_passkey_display_rpc_handler(const struct nrf_rpc_grou unsigned int passkey; conn = bt_rpc_decode_bt_conn(ctx); - passkey = ser_decode_uint(ctx); + passkey = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1465,7 +1465,7 @@ static void bt_rpc_auth_cb_passkey_display_rpc_handler(const struct nrf_rpc_grou auth_cb->passkey_display(conn, passkey); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1484,7 +1484,7 @@ static void bt_rpc_auth_cb_passkey_entry_rpc_handler(const struct nrf_rpc_group conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1492,7 +1492,7 @@ static void bt_rpc_auth_cb_passkey_entry_rpc_handler(const struct nrf_rpc_group auth_cb->passkey_entry(conn); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1511,9 +1511,9 @@ static void bt_rpc_auth_cb_passkey_confirm_rpc_handler(const struct nrf_rpc_grou unsigned int passkey; conn = bt_rpc_decode_bt_conn(ctx); - passkey = ser_decode_uint(ctx); + passkey = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1521,7 +1521,7 @@ static void bt_rpc_auth_cb_passkey_confirm_rpc_handler(const struct nrf_rpc_grou auth_cb->passkey_confirm(conn, passkey); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1541,9 +1541,9 @@ static void bt_rpc_auth_cb_oob_data_request_rpc_handler(const struct nrf_rpc_gro struct bt_conn_oob_info *info; conn = bt_rpc_decode_bt_conn(ctx); - info = ser_decode_buffer(ctx, &info_data, sizeof(struct bt_conn_oob_info)); + info = nrf_rpc_decode_buffer(ctx, &info_data, sizeof(struct bt_conn_oob_info)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1551,7 +1551,7 @@ static void bt_rpc_auth_cb_oob_data_request_rpc_handler(const struct nrf_rpc_gro auth_cb->oob_data_request(conn, info); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1569,7 +1569,7 @@ static void bt_rpc_auth_cb_cancel_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1577,7 +1577,7 @@ static void bt_rpc_auth_cb_cancel_rpc_handler(const struct nrf_rpc_group *group, auth_cb->cancel(conn); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1595,7 +1595,7 @@ static void bt_rpc_auth_cb_pairing_confirm_rpc_handler(const struct nrf_rpc_grou conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1603,7 +1603,7 @@ static void bt_rpc_auth_cb_pairing_confirm_rpc_handler(const struct nrf_rpc_grou auth_cb->pairing_confirm(conn); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1622,10 +1622,10 @@ static int bt_conn_auth_cb_register_on_remote(uint16_t flags) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, flags); + nrf_rpc_encode_uint(&ctx, flags); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_CB_REGISTER_ON_REMOTE_RPC_CMD, &ctx, - ser_rsp_decode_i32, &result); + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1669,10 +1669,10 @@ static void bt_rpc_auth_info_cb_bond_deleted_rpc_handler(const struct nrf_rpc_gr const bt_addr_le_t *peer; struct bt_conn_auth_info_cb *info_cb; - id = ser_decode_uint(ctx); - peer = ser_decode_buffer(ctx, &peer_data, sizeof(bt_addr_le_t)); + id = nrf_rpc_decode_uint(ctx); + peer = nrf_rpc_decode_buffer(ctx, &peer_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1682,7 +1682,7 @@ static void bt_rpc_auth_info_cb_bond_deleted_rpc_handler(const struct nrf_rpc_gr } } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); decoding_error: report_decoding_error(BT_RPC_AUTH_INFO_CB_BOND_DELETED_RPC_CMD, handler_data); @@ -1701,9 +1701,9 @@ static void bt_rpc_auth_info_cb_pairing_complete_rpc_handler(const struct nrf_rp bool bonded; conn = bt_rpc_decode_bt_conn(ctx); - bonded = ser_decode_bool(ctx); + bonded = nrf_rpc_decode_bool(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1713,7 +1713,7 @@ static void bt_rpc_auth_info_cb_pairing_complete_rpc_handler(const struct nrf_rp } } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1733,9 +1733,9 @@ static void bt_rpc_auth_info_cb_pairing_failed_rpc_handler(const struct nrf_rpc_ enum bt_security_err reason; conn = bt_rpc_decode_bt_conn(ctx); - reason = (enum bt_security_err)ser_decode_uint(ctx); + reason = (enum bt_security_err)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1745,7 +1745,7 @@ static void bt_rpc_auth_info_cb_pairing_failed_rpc_handler(const struct nrf_rpc_ } } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1764,10 +1764,10 @@ static int bt_conn_auth_info_cb_register_on_remote(uint16_t flags) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, flags); + nrf_rpc_encode_uint(&ctx, flags); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_INFO_CB_REGISTER_ON_REMOTE_RPC_CMD, &ctx, - ser_rsp_decode_i32, &result); + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1814,7 +1814,7 @@ static int bt_conn_auth_info_cb_unregister_on_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_INFO_CB_UNREGISTER_ON_REMOTE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1848,10 +1848,10 @@ int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, passkey); + nrf_rpc_encode_uint(&ctx, passkey); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_PASSKEY_ENTRY_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1867,7 +1867,7 @@ int bt_conn_auth_cancel(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_CANCEL_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1883,7 +1883,7 @@ int bt_conn_auth_passkey_confirm(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_PASSKEY_CONFIRM_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1899,7 +1899,7 @@ int bt_conn_auth_pairing_confirm(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_AUTH_PAIRING_CONFIRM_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } diff --git a/subsys/bluetooth/rpc/client/bt_rpc_crypto_client.c b/subsys/bluetooth/rpc/client/bt_rpc_crypto_client.c index 9da687265f7c..603e096b236e 100644 --- a/subsys/bluetooth/rpc/client/bt_rpc_crypto_client.c +++ b/subsys/bluetooth/rpc/client/bt_rpc_crypto_client.c @@ -11,7 +11,7 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" +#include #include "nrf_rpc_cbor.h" struct bt_rand_rpc_res { @@ -26,8 +26,8 @@ static void bt_rand_rpc_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cb struct bt_rand_rpc_res *res = (struct bt_rand_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - ser_decode_buffer(ctx, res->buf, sizeof(uint8_t) * res->len); + res->result = nrf_rpc_decode_int(ctx); + nrf_rpc_decode_buffer(ctx, res->buf, sizeof(uint8_t) * res->len); } int bt_rand(void *buf, size_t len) @@ -37,11 +37,11 @@ int bt_rand(void *buf, size_t len) size_t scratchpad_size = 0; size_t buffer_size_max = 10; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(uint8_t) * len); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(uint8_t) * len); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, len); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, len); result.len = len; result.buf = buf; @@ -70,19 +70,19 @@ int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], enc_data_size = sizeof(uint8_t) * 16; buffer_size_max += enc_data_size; - scratchpad_size += SCRATCHPAD_ALIGN(key_size); - scratchpad_size += SCRATCHPAD_ALIGN(plaintext_size); - scratchpad_size += SCRATCHPAD_ALIGN(enc_data_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(key_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(plaintext_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(enc_data_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, key, key_size); - ser_encode_buffer(&ctx, plaintext, plaintext_size); - ser_encode_buffer(&ctx, enc_data, enc_data_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_buffer(&ctx, key, key_size); + nrf_rpc_encode_buffer(&ctx, plaintext, plaintext_size); + nrf_rpc_encode_buffer(&ctx, enc_data, enc_data_size); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ENCRYPT_LE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -105,19 +105,19 @@ int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], enc_data_size = sizeof(uint8_t) * 16; buffer_size_max += enc_data_size; - scratchpad_size += SCRATCHPAD_ALIGN(key_size); - scratchpad_size += SCRATCHPAD_ALIGN(plaintext_size); - scratchpad_size += SCRATCHPAD_ALIGN(enc_data_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(key_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(plaintext_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(enc_data_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, key, key_size); - ser_encode_buffer(&ctx, plaintext, plaintext_size); - ser_encode_buffer(&ctx, enc_data, enc_data_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_buffer(&ctx, key, key_size); + nrf_rpc_encode_buffer(&ctx, plaintext, plaintext_size); + nrf_rpc_encode_buffer(&ctx, enc_data, enc_data_size); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ENCRYPT_BE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -136,8 +136,8 @@ static void bt_ccm_decrypt_rpc_rsp(const struct nrf_rpc_group *group, struct nrf struct bt_ccm_decrypt_rpc_res *res = (struct bt_ccm_decrypt_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - ser_decode_buffer(ctx, res->plaintext, sizeof(uint8_t) * res->len); + res->result = nrf_rpc_decode_int(ctx); + nrf_rpc_decode_buffer(ctx, res->plaintext, sizeof(uint8_t) * res->len); } int bt_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data, @@ -165,23 +165,23 @@ int bt_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_ plaintext_size = sizeof(uint8_t) * len; buffer_size_max += plaintext_size; - scratchpad_size += SCRATCHPAD_ALIGN(key_size); - scratchpad_size += SCRATCHPAD_ALIGN(nonce_size); - scratchpad_size += SCRATCHPAD_ALIGN(enc_data_size); - scratchpad_size += SCRATCHPAD_ALIGN(aad_size); - scratchpad_size += SCRATCHPAD_ALIGN(plaintext_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(key_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(nonce_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(enc_data_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(aad_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(plaintext_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, key, key_size); - ser_encode_buffer(&ctx, nonce, nonce_size); - ser_encode_uint(&ctx, len); - ser_encode_buffer(&ctx, enc_data, enc_data_size); - ser_encode_uint(&ctx, aad_len); - ser_encode_buffer(&ctx, aad, aad_size); - ser_encode_buffer(&ctx, plaintext, plaintext_size); - ser_encode_uint(&ctx, mic_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_buffer(&ctx, key, key_size); + nrf_rpc_encode_buffer(&ctx, nonce, nonce_size); + nrf_rpc_encode_uint(&ctx, len); + nrf_rpc_encode_buffer(&ctx, enc_data, enc_data_size); + nrf_rpc_encode_uint(&ctx, aad_len); + nrf_rpc_encode_buffer(&ctx, aad, aad_size); + nrf_rpc_encode_buffer(&ctx, plaintext, plaintext_size); + nrf_rpc_encode_uint(&ctx, mic_size); result.len = len; result.plaintext = plaintext; @@ -204,8 +204,8 @@ static void bt_ccm_encrypt_rpc_rsp(const struct nrf_rpc_group *group, struct nrf struct bt_ccm_encrypt_rpc_res *res = (struct bt_ccm_encrypt_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - ser_decode_buffer(ctx, res->plaintext, sizeof(uint8_t) * res->len); + res->result = nrf_rpc_decode_int(ctx); + nrf_rpc_decode_buffer(ctx, res->plaintext, sizeof(uint8_t) * res->len); } int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data, @@ -233,23 +233,23 @@ int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_ plaintext_size = sizeof(uint8_t) * len; buffer_size_max += plaintext_size; - scratchpad_size += SCRATCHPAD_ALIGN(key_size); - scratchpad_size += SCRATCHPAD_ALIGN(nonce_size); - scratchpad_size += SCRATCHPAD_ALIGN(enc_data_size); - scratchpad_size += SCRATCHPAD_ALIGN(aad_size); - scratchpad_size += SCRATCHPAD_ALIGN(plaintext_size + mic_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(key_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(nonce_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(enc_data_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(aad_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(plaintext_size + mic_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, key, key_size); - ser_encode_buffer(&ctx, nonce, nonce_size); - ser_encode_uint(&ctx, len); - ser_encode_buffer(&ctx, enc_data, enc_data_size); - ser_encode_uint(&ctx, aad_len); - ser_encode_buffer(&ctx, aad, aad_size); - ser_encode_buffer(&ctx, plaintext, plaintext_size + mic_size); - ser_encode_uint(&ctx, mic_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_buffer(&ctx, key, key_size); + nrf_rpc_encode_buffer(&ctx, nonce, nonce_size); + nrf_rpc_encode_uint(&ctx, len); + nrf_rpc_encode_buffer(&ctx, enc_data, enc_data_size); + nrf_rpc_encode_uint(&ctx, aad_len); + nrf_rpc_encode_buffer(&ctx, aad, aad_size); + nrf_rpc_encode_buffer(&ctx, plaintext, plaintext_size + mic_size); + nrf_rpc_encode_uint(&ctx, mic_size); result.len = len; result.plaintext = plaintext; diff --git a/subsys/bluetooth/rpc/client/bt_rpc_gap_client.c b/subsys/bluetooth/rpc/client/bt_rpc_gap_client.c index 5a92e1215c22..79de96487fa3 100644 --- a/subsys/bluetooth/rpc/client/bt_rpc_gap_client.c +++ b/subsys/bluetooth/rpc/client/bt_rpc_gap_client.c @@ -11,12 +11,11 @@ #include - #include "bt_rpc_gatt_client.h" #include "bt_rpc_conn_client.h" #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include #include @@ -35,13 +34,12 @@ struct bt_rpc_get_check_list_rpc_res { }; static void bt_rpc_get_check_list_rpc_rsp(const struct nrf_rpc_group *group, - struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) + struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { struct bt_rpc_get_check_list_rpc_res *res = (struct bt_rpc_get_check_list_rpc_res *)handler_data; - ser_decode_buffer(ctx, res->data, sizeof(uint8_t) * (res->size)); + nrf_rpc_decode_buffer(ctx, res->data, sizeof(uint8_t) * (res->size)); } static void bt_rpc_get_check_list(uint8_t *data, size_t size) @@ -51,18 +49,18 @@ static void bt_rpc_get_check_list(uint8_t *data, size_t size) size_t scratchpad_size = 0; size_t buffer_size_max = 10; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(uint8_t) * size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(uint8_t) * size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, size); + nrf_rpc_encode_uint(&ctx, size); result.size = size; result.data = data; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GET_CHECK_LIST_RPC_CMD, - &ctx, bt_rpc_get_check_list_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GET_CHECK_LIST_RPC_CMD, &ctx, + bt_rpc_get_check_list_rpc_rsp, &result); } static void validate_config(void) @@ -75,23 +73,22 @@ static void validate_config(void) validated = true; bt_rpc_get_check_list(data, size); if (!bt_rpc_validate_check_list(data, size)) { - nrf_rpc_err(-EINVAL, NRF_RPC_ERR_SRC_RECV, &bt_rpc_grp, - BT_ENABLE_RPC_CMD, NRF_RPC_PACKET_TYPE_CMD); + nrf_rpc_err(-EINVAL, NRF_RPC_ERR_SRC_RECV, &bt_rpc_grp, BT_ENABLE_RPC_CMD, + NRF_RPC_PACKET_TYPE_CMD); } } } static void bt_ready_cb_t_callback_rpc_handler(const struct nrf_rpc_group *group, - struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) + struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { int err; bt_ready_cb_t callback_slot; - err = ser_decode_int(ctx); - callback_slot = (bt_ready_cb_t)ser_decode_callback_call(ctx); + err = nrf_rpc_decode_int(ctx); + callback_slot = (bt_ready_cb_t)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -125,10 +122,10 @@ int bt_enable(bt_ready_cb_t cb) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_callback(&ctx, cb); + nrf_rpc_encode_callback(&ctx, cb); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ENABLE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ENABLE_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); /* In case if the Bluetooth was disabled, we don't need to init again * dependencies. @@ -137,13 +134,12 @@ int bt_enable(bt_ready_cb_t cb) return result; } - if (IS_ENABLED(CONFIG_SETTINGS)) { buffer_size_max = 0; NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_SETTINGS_LOAD_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_SETTINGS_LOAD_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_void, NULL); } return result; @@ -157,7 +153,8 @@ int bt_disable(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_DISABLE_RPC_CMD, &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_DISABLE_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } @@ -170,7 +167,7 @@ bool bt_is_ready(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_IS_READY_RPC_CMD, &ctx, ser_rsp_decode_bool, + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_IS_READY_RPC_CMD, &ctx, nrf_rpc_rsp_decode_bool, &result); return result; @@ -188,15 +185,15 @@ int bt_set_name(const char *name) name_strlen = strlen(name); buffer_size_max += name_strlen; - scratchpad_size += SCRATCHPAD_ALIGN(name_strlen + 1); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(name_strlen + 1); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_str(&ctx, name, name_strlen); + nrf_rpc_encode_str(&ctx, name, name_strlen); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_SET_NAME_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_SET_NAME_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; #else @@ -212,14 +209,13 @@ struct bt_get_name_out_rpc_res { char *name; }; -static void bt_get_name_out_rpc_rsp(const struct nrf_rpc_group *group, - struct nrf_rpc_cbor_ctx *ctx, void *handler_data) +static void bt_get_name_out_rpc_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data) { - struct bt_get_name_out_rpc_res *res = - (struct bt_get_name_out_rpc_res *)handler_data; + struct bt_get_name_out_rpc_res *res = (struct bt_get_name_out_rpc_res *)handler_data; - res->result = ser_decode_bool(ctx); - (void)ser_decode_str(ctx, res->name, (res->size)); + res->result = nrf_rpc_decode_bool(ctx); + (void)nrf_rpc_decode_str(ctx, res->name, (res->size)); } static bool bt_get_name_out(char *name, size_t size) @@ -229,18 +225,18 @@ static bool bt_get_name_out(char *name, size_t size) size_t scratchpad_size = 0; size_t buffer_size_max = 10; - scratchpad_size += SCRATCHPAD_ALIGN(size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, size); + nrf_rpc_encode_uint(&ctx, size); result.size = size; result.name = name; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GET_NAME_OUT_RPC_CMD, - &ctx, bt_get_name_out_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GET_NAME_OUT_RPC_CMD, &ctx, bt_get_name_out_rpc_rsp, + &result); return result.result; } @@ -271,9 +267,9 @@ int bt_set_appearance(uint16_t new_appearance) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, new_appearance); + nrf_rpc_encode_uint(&ctx, new_appearance); - nrf_rpc_cbor_cmd(&bt_rpc_grp, BT_SET_APPEARANCE_RPC_CMD, &ctx, ser_rsp_decode_u16, + nrf_rpc_cbor_cmd(&bt_rpc_grp, BT_SET_APPEARANCE_RPC_CMD, &ctx, nrf_rpc_rsp_decode_u16, &result); return result; @@ -287,7 +283,7 @@ static uint16_t bt_get_appearance_from_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd(&bt_rpc_grp, BT_GET_APPEARANCE_RPC_CMD, &ctx, ser_rsp_decode_u16, + nrf_rpc_cbor_cmd(&bt_rpc_grp, BT_GET_APPEARANCE_RPC_CMD, &ctx, nrf_rpc_rsp_decode_u16, &appearance); return appearance; @@ -311,11 +307,10 @@ struct bt_id_get_rpc_res { static void bt_id_get_rpc_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { - struct bt_id_get_rpc_res *res = - (struct bt_id_get_rpc_res *)handler_data; + struct bt_id_get_rpc_res *res = (struct bt_id_get_rpc_res *)handler_data; - *(res->count) = ser_decode_uint(ctx); - ser_decode_buffer(ctx, res->addrs, *(res->count) * sizeof(bt_addr_le_t)); + *(res->count) = nrf_rpc_decode_uint(ctx); + nrf_rpc_decode_buffer(ctx, res->addrs, *(res->count) * sizeof(bt_addr_le_t)); } void bt_id_get(bt_addr_le_t *addrs, size_t *count) @@ -325,18 +320,17 @@ void bt_id_get(bt_addr_le_t *addrs, size_t *count) size_t scratchpad_size = 0; size_t buffer_size_max = 10; - scratchpad_size += SCRATCHPAD_ALIGN(*count * sizeof(bt_addr_le_t)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(*count * sizeof(bt_addr_le_t)); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, *count); + nrf_rpc_encode_uint(&ctx, *count); result.count = count; result.addrs = addrs; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_GET_RPC_CMD, - &ctx, bt_id_get_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_GET_RPC_CMD, &ctx, bt_id_get_rpc_rsp, &result); } struct bt_id_create_rpc_res { @@ -348,12 +342,11 @@ struct bt_id_create_rpc_res { static void bt_id_create_rpc_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { - struct bt_id_create_rpc_res *res = - (struct bt_id_create_rpc_res *)handler_data; + struct bt_id_create_rpc_res *res = (struct bt_id_create_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - ser_decode_buffer(ctx, res->addr, sizeof(bt_addr_le_t)); - ser_decode_buffer(ctx, res->irk, sizeof(uint8_t) * 16); + res->result = nrf_rpc_decode_int(ctx); + nrf_rpc_decode_buffer(ctx, res->addr, sizeof(bt_addr_le_t)); + nrf_rpc_decode_buffer(ctx, res->irk, sizeof(uint8_t) * 16); } int bt_id_create(bt_addr_le_t *addr, uint8_t *irk) @@ -368,19 +361,19 @@ int bt_id_create(bt_addr_le_t *addr, uint8_t *irk) irk_size = !irk ? 0 : sizeof(uint8_t) * 16; buffer_size_max += irk_size; - scratchpad_size += SCRATCHPAD_ALIGN(irk_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(irk_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - ser_encode_buffer(&ctx, irk, irk_size); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, irk, irk_size); result.addr = addr; result.irk = irk; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_CREATE_RPC_CMD, - &ctx, bt_id_create_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_CREATE_RPC_CMD, &ctx, bt_id_create_rpc_rsp, + &result); return result.result; } @@ -394,12 +387,11 @@ struct bt_id_reset_rpc_res { static void bt_id_reset_rpc_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { - struct bt_id_reset_rpc_res *res = - (struct bt_id_reset_rpc_res *)handler_data; + struct bt_id_reset_rpc_res *res = (struct bt_id_reset_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - ser_decode_buffer(ctx, res->addr, sizeof(bt_addr_le_t)); - ser_decode_buffer(ctx, res->irk, sizeof(uint8_t) * 16); + res->result = nrf_rpc_decode_int(ctx); + nrf_rpc_decode_buffer(ctx, res->addr, sizeof(bt_addr_le_t)); + nrf_rpc_decode_buffer(ctx, res->irk, sizeof(uint8_t) * 16); } int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk) @@ -414,20 +406,20 @@ int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk) irk_size = !irk ? 0 : sizeof(uint8_t) * 16; buffer_size_max += irk_size; - scratchpad_size += SCRATCHPAD_ALIGN(irk_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(irk_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, id); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - ser_encode_buffer(&ctx, irk, irk_size); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, irk, irk_size); result.addr = addr; result.irk = irk; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_RESET_RPC_CMD, - &ctx, bt_id_reset_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_RESET_RPC_CMD, &ctx, bt_id_reset_rpc_rsp, + &result); return result.result; } @@ -440,10 +432,10 @@ int bt_id_delete(uint8_t id) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); + nrf_rpc_encode_uint(&ctx, id); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_DELETE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ID_DELETE_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } @@ -461,37 +453,37 @@ size_t bt_data_sp_size(const struct bt_data *data) { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(uint8_t) * data->data_len); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(uint8_t) * data->data_len); return scratchpad_size; } static void bt_data_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_data *data) { - ser_encode_uint(encoder, data->type); - ser_encode_uint(encoder, data->data_len); - ser_encode_buffer(encoder, data->data, sizeof(uint8_t) * data->data_len); + nrf_rpc_encode_uint(encoder, data->type); + nrf_rpc_encode_uint(encoder, data->data_len); + nrf_rpc_encode_buffer(encoder, data->data, sizeof(uint8_t) * data->data_len); } #if defined(CONFIG_BT_OBSERVER) static void bt_le_scan_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_scan_param *data) { - ser_encode_uint(encoder, data->type); - ser_encode_uint(encoder, data->options); - ser_encode_uint(encoder, data->interval); - ser_encode_uint(encoder, data->window); - ser_encode_uint(encoder, data->timeout); - ser_encode_uint(encoder, data->interval_coded); - ser_encode_uint(encoder, data->window_coded); + nrf_rpc_encode_uint(encoder, data->type); + nrf_rpc_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->interval); + nrf_rpc_encode_uint(encoder, data->window); + nrf_rpc_encode_uint(encoder, data->timeout); + nrf_rpc_encode_uint(encoder, data->interval_coded); + nrf_rpc_encode_uint(encoder, data->window_coded); } #endif /* defined(CONFIG_BT_OBSERVER) */ -static void net_buf_simple_dec(struct ser_scratchpad *scratchpad, struct net_buf_simple *data) +static void net_buf_simple_dec(struct nrf_rpc_scratchpad *scratchpad, struct net_buf_simple *data) { size_t len; - data->data = ser_decode_buffer_into_scratchpad(scratchpad, &len); + data->data = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, &len); data->len = len; data->size = data->len; data->__buf = data->data; @@ -506,23 +498,23 @@ static void bt_le_scan_cb_t_callback_rpc_handler(const struct nrf_rpc_group *gro uint8_t adv_type; struct net_buf_simple buf; bt_le_scan_cb_t *callback_slot; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - rssi = ser_decode_int(ctx); - adv_type = ser_decode_uint(ctx); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + rssi = nrf_rpc_decode_int(ctx); + adv_type = nrf_rpc_decode_uint(ctx); net_buf_simple_dec(&scratchpad, &buf); - callback_slot = (bt_le_scan_cb_t *)ser_decode_callback_call(ctx); + callback_slot = (bt_le_scan_cb_t *)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(addr, rssi, adv_type, &buf); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -536,7 +528,7 @@ static size_t bt_le_adv_param_sp_size(const struct bt_le_adv_param *data) { size_t scratchpad_size = 0; - scratchpad_size += !data->peer ? 0 : SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); + scratchpad_size += !data->peer ? 0 : NRF_RPC_SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); return scratchpad_size; } @@ -553,17 +545,16 @@ static size_t bt_le_adv_param_buf_size(const struct bt_le_adv_param *data) static void bt_le_adv_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_adv_param *data) { - ser_encode_uint(encoder, data->id); - ser_encode_uint(encoder, data->sid); - ser_encode_uint(encoder, data->secondary_max_skip); - ser_encode_uint(encoder, data->options); - ser_encode_uint(encoder, data->interval_min); - ser_encode_uint(encoder, data->interval_max); - ser_encode_buffer(encoder, data->peer, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, data->id); + nrf_rpc_encode_uint(encoder, data->sid); + nrf_rpc_encode_uint(encoder, data->secondary_max_skip); + nrf_rpc_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->interval_min); + nrf_rpc_encode_uint(encoder, data->interval_max); + nrf_rpc_encode_buffer(encoder, data->peer, sizeof(bt_addr_le_t)); } -int bt_le_adv_start(const struct bt_le_adv_param *param, - const struct bt_data *ad, size_t ad_len, +int bt_le_adv_start(const struct bt_le_adv_param *param, const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, size_t sd_len) { struct nrf_rpc_cbor_ctx ctx; @@ -575,43 +566,42 @@ int bt_le_adv_start(const struct bt_le_adv_param *param, for (size_t i = 0; i < ad_len; i++) { buffer_size_max += bt_data_buf_size(&ad[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&ad[i]); } for (size_t i = 0; i < sd_len; i++) { buffer_size_max += bt_data_buf_size(&sd[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&sd[i]); } scratchpad_size += bt_le_adv_param_sp_size(param); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_le_adv_param_enc(&ctx, param); - ser_encode_uint(&ctx, ad_len); + nrf_rpc_encode_uint(&ctx, ad_len); for (size_t i = 0; i < ad_len; i++) { bt_data_enc(&ctx, &ad[i]); } - ser_encode_uint(&ctx, sd_len); + nrf_rpc_encode_uint(&ctx, sd_len); for (size_t i = 0; i < sd_len; i++) { bt_data_enc(&ctx, &sd[i]); } - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ADV_START_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ADV_START_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } - -int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len, - const struct bt_data *sd, size_t sd_len) +int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, + size_t sd_len) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -620,31 +610,31 @@ int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len, for (size_t i = 0; i < ad_len; i++) { buffer_size_max += bt_data_buf_size(&ad[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&ad[i]); } for (size_t i = 0; i < sd_len; i++) { buffer_size_max += bt_data_buf_size(&sd[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&sd[i]); } NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, ad_len); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, ad_len); for (size_t i = 0; i < ad_len; i++) { bt_data_enc(&ctx, &ad[i]); } - ser_encode_uint(&ctx, sd_len); + nrf_rpc_encode_uint(&ctx, sd_len); for (size_t i = 0; i < sd_len; i++) { bt_data_enc(&ctx, &sd[i]); } - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ADV_UPDATE_DATA_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ADV_UPDATE_DATA_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -657,30 +647,30 @@ int bt_le_adv_stop(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ADV_STOP_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ADV_STOP_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } static void bt_le_oob_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_oob *data) { - ser_decode_buffer(ctx, &data->addr, sizeof(bt_addr_le_t)); - ser_decode_buffer(ctx, data->le_sc_data.r, 16 * sizeof(uint8_t)); - ser_decode_buffer(ctx, data->le_sc_data.c, 16 * sizeof(uint8_t)); + nrf_rpc_decode_buffer(ctx, &data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_decode_buffer(ctx, data->le_sc_data.r, 16 * sizeof(uint8_t)); + nrf_rpc_decode_buffer(ctx, data->le_sc_data.c, 16 * sizeof(uint8_t)); } #if defined(CONFIG_BT_EXT_ADV) static void bt_le_ext_adv_sent_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_ext_adv_sent_info *data) { - data->num_sent = ser_decode_uint(ctx); + data->num_sent = nrf_rpc_decode_uint(ctx); } -static void bt_le_ext_adv_scanned_info_dec(struct ser_scratchpad *scratchpad, +static void bt_le_ext_adv_scanned_info_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_le_ext_adv_scanned_info *data) { - data->addr = ser_decode_buffer_into_scratchpad(scratchpad, NULL); + data->addr = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); } static void bt_le_ext_adv_cb_sent_callback_rpc_handler(const struct nrf_rpc_group *group, @@ -691,17 +681,17 @@ static void bt_le_ext_adv_cb_sent_callback_rpc_handler(const struct nrf_rpc_grou struct bt_le_ext_adv_sent_info info; bt_le_ext_adv_cb_sent callback_slot; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_ext_adv_sent_info_dec(ctx, &info); - callback_slot = (bt_le_ext_adv_cb_sent)ser_decode_callback_call(ctx); + callback_slot = (bt_le_ext_adv_cb_sent)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(adv, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -727,17 +717,17 @@ static void bt_le_ext_adv_cb_connected_callback_rpc_handler(const struct nrf_rpc struct bt_le_ext_adv_connected_info info; bt_le_ext_adv_cb_connected callback_slot; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_ext_adv_connected_info_dec(ctx, &info); - callback_slot = (bt_le_ext_adv_cb_connected)ser_decode_callback_call(ctx); + callback_slot = (bt_le_ext_adv_cb_connected)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(adv, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -756,21 +746,21 @@ static void bt_le_ext_adv_cb_scanned_callback_rpc_handler(const struct nrf_rpc_g struct bt_le_ext_adv *adv; struct bt_le_ext_adv_scanned_info info; bt_le_ext_adv_cb_scanned callback_slot; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_ext_adv_scanned_info_dec(&scratchpad, &info); - callback_slot = (bt_le_ext_adv_cb_scanned)ser_decode_callback_call(ctx); + callback_slot = (bt_le_ext_adv_cb_scanned)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(adv, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -786,9 +776,9 @@ static const size_t bt_le_ext_adv_cb_buf_size = 15; static void bt_le_ext_adv_cb_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_ext_adv_cb *data) { - ser_encode_callback(encoder, data->sent); - ser_encode_callback(encoder, data->connected); - ser_encode_callback(encoder, data->scanned); + nrf_rpc_encode_callback(encoder, data->sent); + nrf_rpc_encode_callback(encoder, data->connected); + nrf_rpc_encode_callback(encoder, data->scanned); } struct bt_le_ext_adv_create_rpc_res { @@ -802,12 +792,11 @@ static void bt_le_ext_adv_create_rpc_rsp(const struct nrf_rpc_group *group, struct bt_le_ext_adv_create_rpc_res *res = (struct bt_le_ext_adv_create_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - *(res->adv) = (struct bt_le_ext_adv *)(uintptr_t)ser_decode_uint(ctx); + res->result = nrf_rpc_decode_int(ctx); + *(res->adv) = (struct bt_le_ext_adv *)(uintptr_t)nrf_rpc_decode_uint(ctx); } -int bt_le_ext_adv_create(const struct bt_le_adv_param *param, - const struct bt_le_ext_adv_cb *cb, +int bt_le_ext_adv_create(const struct bt_le_adv_param *param, const struct bt_le_ext_adv_cb *cb, struct bt_le_ext_adv **adv) { struct nrf_rpc_cbor_ctx ctx; @@ -822,20 +811,20 @@ int bt_le_ext_adv_create(const struct bt_le_adv_param *param, scratchpad_size += bt_le_adv_param_sp_size(param); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_le_adv_param_enc(&ctx, param); if (cb == NULL) { - ser_encode_undefined(&ctx); + nrf_rpc_encode_undefined(&ctx); } else { bt_le_ext_adv_cb_enc(&ctx, cb); } result.adv = adv; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_CREATE_RPC_CMD, - &ctx, bt_le_ext_adv_create_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_CREATE_RPC_CMD, &ctx, + bt_le_ext_adv_create_rpc_rsp, &result); return result.result; } @@ -843,12 +832,11 @@ int bt_le_ext_adv_create(const struct bt_le_adv_param *param, static void bt_le_ext_adv_start_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_ext_adv_start_param *data) { - ser_encode_uint(encoder, data->timeout); - ser_encode_uint(encoder, data->num_events); + nrf_rpc_encode_uint(encoder, data->timeout); + nrf_rpc_encode_uint(encoder, data->num_events); } -int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, - struct bt_le_ext_adv_start_param *param) +int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_start_param *param) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -856,11 +844,11 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_ext_adv_start_param_enc(&ctx, param); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_START_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_START_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -873,16 +861,15 @@ int bt_le_ext_adv_stop(struct bt_le_ext_adv *adv) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_STOP_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_STOP_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } -int bt_le_ext_adv_set_data(struct bt_le_ext_adv *adv, - const struct bt_data *ad, size_t ad_len, +int bt_le_ext_adv_set_data(struct bt_le_ext_adv *adv, const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, size_t sd_len) { struct nrf_rpc_cbor_ctx ctx; @@ -892,39 +879,38 @@ int bt_le_ext_adv_set_data(struct bt_le_ext_adv *adv, for (size_t i = 0; i < ad_len; i++) { buffer_size_max += bt_data_buf_size(&ad[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&ad[i]); } for (size_t i = 0; i < sd_len; i++) { buffer_size_max += bt_data_buf_size(&sd[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&sd[i]); } NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)adv); - ser_encode_uint(&ctx, ad_len); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, ad_len); for (size_t i = 0; i < ad_len; i++) { bt_data_enc(&ctx, &ad[i]); } - ser_encode_uint(&ctx, sd_len); + nrf_rpc_encode_uint(&ctx, sd_len); for (size_t i = 0; i < sd_len; i++) { bt_data_enc(&ctx, &sd[i]); } - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_SET_DATA_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_SET_DATA_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } -int bt_le_ext_adv_update_param(struct bt_le_ext_adv *adv, - const struct bt_le_adv_param *param) +int bt_le_ext_adv_update_param(struct bt_le_ext_adv *adv, const struct bt_le_adv_param *param) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -936,13 +922,13 @@ int bt_le_ext_adv_update_param(struct bt_le_ext_adv *adv, scratchpad_size += bt_le_adv_param_sp_size(param); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_adv_param_enc(&ctx, param); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_UPDATE_PARAM_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_UPDATE_PARAM_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -955,10 +941,10 @@ int bt_le_ext_adv_delete(struct bt_le_ext_adv *adv) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_DELETE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_DELETE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -971,10 +957,10 @@ uint8_t bt_le_ext_adv_get_index(struct bt_le_ext_adv *adv) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_GET_INDEX_RPC_CMD, - &ctx, ser_rsp_decode_u8, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_GET_INDEX_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_u8, &result); return result; } @@ -982,12 +968,11 @@ uint8_t bt_le_ext_adv_get_index(struct bt_le_ext_adv *adv) static void bt_le_ext_adv_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_ext_adv_info *data) { - ser_encode_uint(encoder, data->id); - ser_encode_int(encoder, data->tx_power); + nrf_rpc_encode_uint(encoder, data->id); + nrf_rpc_encode_int(encoder, data->tx_power); } -int bt_le_ext_adv_get_info(const struct bt_le_ext_adv *adv, - struct bt_le_ext_adv_info *info) +int bt_le_ext_adv_get_info(const struct bt_le_ext_adv *adv, struct bt_le_ext_adv_info *info) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -995,11 +980,11 @@ int bt_le_ext_adv_get_info(const struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_ext_adv_info_enc(&ctx, info); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_GET_INFO_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_GET_INFO_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1015,12 +1000,11 @@ static void bt_le_ext_adv_oob_get_local_rpc_rsp(const struct nrf_rpc_group *grou struct bt_le_ext_adv_oob_get_local_rpc_res *res = (struct bt_le_ext_adv_oob_get_local_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); bt_le_oob_dec(ctx, res->oob); } -int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv, - struct bt_le_oob *oob) +int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv, struct bt_le_oob *oob) { struct nrf_rpc_cbor_ctx ctx; struct bt_le_ext_adv_oob_get_local_rpc_res result; @@ -1028,12 +1012,12 @@ int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); result.oob = oob; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_OOB_GET_LOCAL_RPC_CMD, - &ctx, bt_le_ext_adv_oob_get_local_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_OOB_GET_LOCAL_RPC_CMD, &ctx, + bt_le_ext_adv_oob_get_local_rpc_rsp, &result); return result.result; } @@ -1043,13 +1027,12 @@ int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv, static void bt_le_per_adv_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_param *data) { - ser_encode_uint(encoder, data->interval_min); - ser_encode_uint(encoder, data->interval_max); - ser_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->interval_min); + nrf_rpc_encode_uint(encoder, data->interval_max); + nrf_rpc_encode_uint(encoder, data->options); } -int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv, - const struct bt_le_per_adv_param *param) +int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv, const struct bt_le_per_adv_param *param) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -1057,17 +1040,16 @@ int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_per_adv_param_enc(&ctx, param); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SET_PARAM_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SET_PARAM_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } -int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv, - const struct bt_data *ad, size_t ad_len) +int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv, const struct bt_data *ad, size_t ad_len) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -1076,21 +1058,21 @@ int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv, for (size_t i = 0; i < ad_len; i++) { buffer_size_max += bt_data_buf_size(&ad[i]); - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(struct bt_data)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(struct bt_data)); scratchpad_size += bt_data_sp_size(&ad[i]); } NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)adv); - ser_encode_uint(&ctx, ad_len); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, ad_len); for (size_t i = 0; i < ad_len; i++) { bt_data_enc(&ctx, &ad[i]); } - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SET_DATA_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SET_DATA_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1103,10 +1085,10 @@ int bt_le_per_adv_start(struct bt_le_ext_adv *adv) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_START_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_START_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1119,17 +1101,16 @@ int bt_le_per_adv_stop(struct bt_le_ext_adv *adv) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_STOP_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_STOP_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } #if defined(CONFIG_BT_CONN) -int bt_le_per_adv_set_info_transfer(const struct bt_le_ext_adv *adv, - const struct bt_conn *conn, +int bt_le_per_adv_set_info_transfer(const struct bt_le_ext_adv *adv, const struct bt_conn *conn, uint16_t service_data) { struct nrf_rpc_cbor_ctx ctx; @@ -1138,17 +1119,17 @@ int bt_le_per_adv_set_info_transfer(const struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, service_data); + nrf_rpc_encode_uint(&ctx, service_data); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SET_INFO_TRANSFER_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SET_INFO_TRANSFER_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } -#endif /* defined(CONFIG_BT_CONN) || */ -#endif /* defined(CONFIG_BT_PER_ADV) */ +#endif /* defined(CONFIG_BT_CONN) || */ +#endif /* defined(CONFIG_BT_PER_ADV) */ #if defined(CONFIG_BT_PER_ADV_SYNC) uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync) @@ -1159,10 +1140,10 @@ uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)per_adv_sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)per_adv_sync); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_GET_INDEX_RPC_CMD, - &ctx, ser_rsp_decode_u8, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_GET_INDEX_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_u8, &result); return result; } @@ -1173,17 +1154,16 @@ size_t bt_le_per_adv_sync_param_buf_size(const struct bt_le_per_adv_sync_param * buffer_size_max += sizeof(bt_addr_le_t); return buffer_size_max; - } void bt_le_per_adv_sync_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_sync_param *data) { - ser_encode_buffer(encoder, &data->addr, sizeof(bt_addr_le_t)); - ser_encode_uint(encoder, data->sid); - ser_encode_uint(encoder, data->options); - ser_encode_uint(encoder, data->skip); - ser_encode_uint(encoder, data->timeout); + nrf_rpc_encode_buffer(encoder, &data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, data->sid); + nrf_rpc_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->skip); + nrf_rpc_encode_uint(encoder, data->timeout); } struct bt_le_per_adv_sync_create_rpc_res { @@ -1197,8 +1177,8 @@ static void bt_le_per_adv_sync_create_rpc_rsp(const struct nrf_rpc_group *group, struct bt_le_per_adv_sync_create_rpc_res *res = (struct bt_le_per_adv_sync_create_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); - *(res->out_sync) = (struct bt_le_per_adv_sync *)(uintptr_t)ser_decode_uint(ctx); + res->result = nrf_rpc_decode_int(ctx); + *(res->out_sync) = (struct bt_le_per_adv_sync *)(uintptr_t)nrf_rpc_decode_uint(ctx); } int bt_le_per_adv_sync_create(const struct bt_le_per_adv_sync_param *param, @@ -1216,8 +1196,8 @@ int bt_le_per_adv_sync_create(const struct bt_le_per_adv_sync_param *param, result.out_sync = out_sync; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_CREATE_RPC_CMD, - &ctx, bt_le_per_adv_sync_create_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_CREATE_RPC_CMD, &ctx, + bt_le_per_adv_sync_create_rpc_rsp, &result); return result.result; } @@ -1230,10 +1210,10 @@ int bt_le_per_adv_sync_delete(struct bt_le_per_adv_sync *per_adv_sync) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)per_adv_sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)per_adv_sync); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_DELETE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_DELETE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1248,7 +1228,7 @@ static void bt_le_per_adv_sync_cb_register_on_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_CB_REGISTER_ON_REMOTE_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } int bt_le_per_adv_sync_cb_register(struct bt_le_per_adv_sync_cb *cb) @@ -1278,10 +1258,10 @@ int bt_le_per_adv_sync_recv_enable(struct bt_le_per_adv_sync *per_adv_sync) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)per_adv_sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)per_adv_sync); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_RECV_ENABLE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_RECV_ENABLE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1294,18 +1274,17 @@ int bt_le_per_adv_sync_recv_disable(struct bt_le_per_adv_sync *per_adv_sync) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)per_adv_sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)per_adv_sync); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_RECV_DISABLE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_RECV_DISABLE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } #if defined(CONFIG_BT_CONN) int bt_le_per_adv_sync_transfer(const struct bt_le_per_adv_sync *per_adv_sync, - const struct bt_conn *conn, - uint16_t service_data) + const struct bt_conn *conn, uint16_t service_data) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -1313,12 +1292,12 @@ int bt_le_per_adv_sync_transfer(const struct bt_le_per_adv_sync *per_adv_sync, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)per_adv_sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)per_adv_sync); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, service_data); + nrf_rpc_encode_uint(&ctx, service_data); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_TRANSFER_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_TRANSFER_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1327,14 +1306,13 @@ static void bt_le_per_adv_sync_transfer_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_sync_transfer_param *data) { - ser_encode_uint(encoder, data->skip); - ser_encode_uint(encoder, data->timeout); - ser_encode_uint(encoder, data->options); + nrf_rpc_encode_uint(encoder, data->skip); + nrf_rpc_encode_uint(encoder, data->timeout); + nrf_rpc_encode_uint(encoder, data->options); } -int bt_le_per_adv_sync_transfer_subscribe( - const struct bt_conn *conn, - const struct bt_le_per_adv_sync_transfer_param *param) +int bt_le_per_adv_sync_transfer_subscribe(const struct bt_conn *conn, + const struct bt_le_per_adv_sync_transfer_param *param) { struct nrf_rpc_cbor_ctx ctx; int result; @@ -1345,8 +1323,8 @@ int bt_le_per_adv_sync_transfer_subscribe( bt_rpc_encode_bt_conn(&ctx, conn); bt_le_per_adv_sync_transfer_param_enc(&ctx, param); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_TRANSFER_SUBSCRIBE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_TRANSFER_SUBSCRIBE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1361,8 +1339,8 @@ int bt_le_per_adv_sync_transfer_unsubscribe(const struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_TRANSFER_UNSUBSCRIBE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_SYNC_TRANSFER_UNSUBSCRIBE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1378,11 +1356,11 @@ int bt_le_per_adv_list_add(const bt_addr_le_t *addr, uint8_t sid) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - ser_encode_uint(&ctx, sid); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, sid); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_LIST_ADD_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_LIST_ADD_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1397,11 +1375,11 @@ int bt_le_per_adv_list_remove(const bt_addr_le_t *addr, uint8_t sid) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - ser_encode_uint(&ctx, sid); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, sid); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_LIST_REMOVE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_LIST_REMOVE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1414,23 +1392,23 @@ int bt_le_per_adv_list_clear(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_LIST_CLEAR_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_PER_ADV_LIST_CLEAR_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } -static void bt_le_per_adv_sync_synced_info_dec(struct ser_scratchpad *scratchpad, +static void bt_le_per_adv_sync_synced_info_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_le_per_adv_sync_synced_info *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; - data->addr = ser_decode_buffer_into_scratchpad(scratchpad, NULL); - data->sid = ser_decode_uint(ctx); - data->interval = ser_decode_uint(ctx); - data->phy = ser_decode_uint(ctx); - data->recv_enabled = ser_decode_bool(ctx); - data->service_data = ser_decode_uint(ctx); + data->addr = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); + data->sid = nrf_rpc_decode_uint(ctx); + data->interval = nrf_rpc_decode_uint(ctx); + data->phy = nrf_rpc_decode_uint(ctx); + data->recv_enabled = nrf_rpc_decode_bool(ctx); + data->service_data = nrf_rpc_decode_uint(ctx); #if defined(CONFIG_BT_CONN) data->conn = bt_rpc_decode_bt_conn(ctx); #else @@ -1455,20 +1433,20 @@ static void per_adv_sync_cb_synced_rpc_handler(const struct nrf_rpc_group *group { struct bt_le_per_adv_sync *sync; struct bt_le_per_adv_sync_synced_info info; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); bt_le_per_adv_sync_synced_info_dec(&scratchpad, &info); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } per_adv_sync_cb_synced(sync, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1478,31 +1456,31 @@ static void per_adv_sync_cb_synced_rpc_handler(const struct nrf_rpc_group *group NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, per_adv_sync_cb_synced, PER_ADV_SYNC_CB_SYNCED_RPC_CMD, per_adv_sync_cb_synced_rpc_handler, NULL); -static void bt_le_per_adv_sync_term_info_dec(struct ser_scratchpad *scratchpad, +static void bt_le_per_adv_sync_term_info_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_le_per_adv_sync_term_info *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; - data->addr = ser_decode_buffer_into_scratchpad(scratchpad, NULL); - data->sid = ser_decode_uint(ctx); + data->addr = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); + data->sid = nrf_rpc_decode_uint(ctx); } -static void bt_le_per_adv_sync_recv_info_dec(struct ser_scratchpad *scratchpad, +static void bt_le_per_adv_sync_recv_info_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_le_per_adv_sync_recv_info *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; - data->addr = ser_decode_buffer_into_scratchpad(scratchpad, NULL); - data->sid = ser_decode_uint(ctx); - data->tx_power = ser_decode_int(ctx); - data->rssi = ser_decode_int(ctx); - data->cte_type = ser_decode_uint(ctx); + data->addr = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); + data->sid = nrf_rpc_decode_uint(ctx); + data->tx_power = nrf_rpc_decode_int(ctx); + data->rssi = nrf_rpc_decode_int(ctx); + data->cte_type = nrf_rpc_decode_uint(ctx); } static void bt_le_per_adv_sync_state_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_per_adv_sync_state_info *data) { - data->recv_enabled = ser_decode_bool(ctx); + data->recv_enabled = nrf_rpc_decode_bool(ctx); } static void per_adv_sync_cb_term(struct bt_le_per_adv_sync *sync, @@ -1522,20 +1500,20 @@ static void per_adv_sync_cb_term_rpc_handler(const struct nrf_rpc_group *group, { struct bt_le_per_adv_sync *sync; struct bt_le_per_adv_sync_term_info info; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); bt_le_per_adv_sync_term_info_dec(&scratchpad, &info); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } per_adv_sync_cb_term(sync, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1567,21 +1545,21 @@ static void per_adv_sync_cb_recv_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_per_adv_sync *sync; struct bt_le_per_adv_sync_recv_info info; struct net_buf_simple buf; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); bt_le_per_adv_sync_recv_info_dec(&scratchpad, &info); net_buf_simple_dec(&scratchpad, &buf); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } per_adv_sync_cb_recv(sync, &info, &buf); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1610,16 +1588,16 @@ static void per_adv_sync_cb_state_changed_rpc_handler(const struct nrf_rpc_group struct bt_le_per_adv_sync *sync; struct bt_le_per_adv_sync_state_info info; - sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); bt_le_per_adv_sync_state_info_dec(ctx, &info); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } per_adv_sync_cb_state_changed(sync, &info); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1643,10 +1621,10 @@ int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_le_scan_param_enc(&ctx, param); - ser_encode_callback(&ctx, cb); + nrf_rpc_encode_callback(&ctx, cb); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_START_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_START_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } @@ -1659,32 +1637,31 @@ int bt_le_scan_stop(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_STOP_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_STOP_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } -static void bt_le_scan_recv_info_dec(struct ser_scratchpad *scratchpad, +static void bt_le_scan_recv_info_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_le_scan_recv_info *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; - data->addr = ser_decode_buffer_into_scratchpad(scratchpad, NULL); - data->sid = ser_decode_uint(ctx); - data->rssi = ser_decode_int(ctx); - data->tx_power = ser_decode_int(ctx); - data->adv_type = ser_decode_uint(ctx); - data->adv_props = ser_decode_uint(ctx); - data->interval = ser_decode_uint(ctx); - data->primary_phy = ser_decode_uint(ctx); - data->secondary_phy = ser_decode_uint(ctx); + data->addr = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); + data->sid = nrf_rpc_decode_uint(ctx); + data->rssi = nrf_rpc_decode_int(ctx); + data->tx_power = nrf_rpc_decode_int(ctx); + data->adv_type = nrf_rpc_decode_uint(ctx); + data->adv_props = nrf_rpc_decode_uint(ctx); + data->interval = nrf_rpc_decode_uint(ctx); + data->primary_phy = nrf_rpc_decode_uint(ctx); + data->secondary_phy = nrf_rpc_decode_uint(ctx); } static sys_slist_t scan_cbs = SYS_SLIST_STATIC_INIT(&scan_cbs); -static void bt_le_scan_cb_recv(const struct bt_le_scan_recv_info *info, - struct net_buf_simple *buf) +static void bt_le_scan_cb_recv(const struct bt_le_scan_recv_info *info, struct net_buf_simple *buf) { struct bt_le_scan_cb *listener; struct net_buf_simple_state state; @@ -1701,20 +1678,20 @@ static void bt_le_scan_cb_recv_rpc_handler(const struct nrf_rpc_group *group, { struct bt_le_scan_recv_info info; struct net_buf_simple buf; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); bt_le_scan_recv_info_dec(&scratchpad, &info); net_buf_simple_dec(&scratchpad, &buf); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_le_scan_cb_recv(&info, &buf); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1740,7 +1717,7 @@ static void bt_le_scan_cb_timeout_rpc_handler(const struct nrf_rpc_group *group, bt_le_scan_cb_timeout(); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_scan_cb_timeout, BT_LE_SCAN_CB_TIMEOUT_RPC_CMD, @@ -1753,8 +1730,8 @@ static void bt_le_scan_cb_register_on_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_CB_REGISTER_ON_REMOTE_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_CB_REGISTER_ON_REMOTE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_void, NULL); } int bt_le_scan_cb_register(struct bt_le_scan_cb *cb) @@ -1788,15 +1765,14 @@ int bt_le_filter_accept_list_add(const bt_addr_le_t *addr) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_FILTER_ACCEPT_LIST_ADD_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_FILTER_ACCEPT_LIST_ADD_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } - int bt_le_filter_accept_list_remove(const bt_addr_le_t *addr) { struct nrf_rpc_cbor_ctx ctx; @@ -1807,15 +1783,14 @@ int bt_le_filter_accept_list_remove(const bt_addr_le_t *addr) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_FILTER_ACCEPT_LIST_REMOVE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_FILTER_ACCEPT_LIST_REMOVE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } - int bt_le_filter_accept_list_clear(void) { struct nrf_rpc_cbor_ctx ctx; @@ -1824,8 +1799,8 @@ int bt_le_filter_accept_list_clear(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ACCEPT_LIST_CLEAR_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_ACCEPT_LIST_CLEAR_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1842,21 +1817,20 @@ int bt_le_set_chan_map(uint8_t chan_map[5]) chan_map_size = sizeof(uint8_t) * 5; buffer_size_max += chan_map_size; - scratchpad_size += SCRATCHPAD_ALIGN(chan_map_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(chan_map_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, chan_map, chan_map_size); + nrf_rpc_encode_buffer(&ctx, chan_map, chan_map_size); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SET_CHAN_MAP_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SET_CHAN_MAP_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } -void bt_data_parse(struct net_buf_simple *ad, - bool (*func)(struct bt_data *data, void *user_data), +void bt_data_parse(struct net_buf_simple *ad, bool (*func)(struct bt_data *data, void *user_data), void *user_data) { while (ad->len > 1) { @@ -1897,7 +1871,7 @@ static void bt_le_oob_get_local_rpc_rsp(const struct nrf_rpc_group *group, struct bt_le_oob_get_local_rpc_res *res = (struct bt_le_oob_get_local_rpc_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); bt_le_oob_dec(ctx, res->oob); } @@ -1909,12 +1883,12 @@ int bt_le_oob_get_local(uint8_t id, struct bt_le_oob *oob) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); + nrf_rpc_encode_uint(&ctx, id); result.oob = oob; - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_OOB_GET_LOCAL_RPC_CMD, - &ctx, bt_le_oob_get_local_rpc_rsp, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_OOB_GET_LOCAL_RPC_CMD, &ctx, + bt_le_oob_get_local_rpc_rsp, &result); return result.result; } @@ -1983,11 +1957,11 @@ int bt_unpair(uint8_t id, const bt_addr_le_t *addr) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_UNPAIR_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_UNPAIR_RPC_CMD, &ctx, nrf_rpc_rsp_decode_i32, + &result); return result; } @@ -1996,7 +1970,7 @@ int bt_unpair(uint8_t id, const bt_addr_le_t *addr) #if (defined(CONFIG_BT_CONN) && defined(CONFIG_BT_SMP)) static void bt_bond_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_bond_info *data) { - ser_decode_buffer(ctx, &data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_decode_buffer(ctx, &data->addr, sizeof(bt_addr_le_t)); } static void bt_foreach_bond_cb_callback_rpc_handler(const struct nrf_rpc_group *group, @@ -2008,16 +1982,16 @@ static void bt_foreach_bond_cb_callback_rpc_handler(const struct nrf_rpc_group * bt_foreach_bond_cb callback_slot; bt_bond_info_dec(ctx, &info); - user_data = (void *)ser_decode_uint(ctx); - callback_slot = (bt_foreach_bond_cb)ser_decode_callback_call(ctx); + user_data = (void *)nrf_rpc_decode_uint(ctx); + callback_slot = (bt_foreach_bond_cb)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(&info, user_data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -2028,8 +2002,7 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_foreach_bond_cb_callback, BT_FOREACH_BOND_CB_CALLBACK_RPC_CMD, bt_foreach_bond_cb_callback_rpc_handler, NULL); -void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info, - void *user_data), +void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info, void *user_data), void *user_data) { struct nrf_rpc_cbor_ctx ctx; @@ -2037,11 +2010,11 @@ void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); - ser_encode_callback(&ctx, func); - ser_encode_uint(&ctx, (uintptr_t)user_data); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_callback(&ctx, func); + nrf_rpc_encode_uint(&ctx, (uintptr_t)user_data); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_FOREACH_BOND_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_FOREACH_BOND_RPC_CMD, &ctx, nrf_rpc_rsp_decode_void, + NULL); } #endif /* (defined(CONFIG_BT_CONN) && defined(CONFIG_BT_SMP)) */ diff --git a/subsys/bluetooth/rpc/client/bt_rpc_gatt_client.c b/subsys/bluetooth/rpc/client/bt_rpc_gatt_client.c index 2c5162c8d0e3..47e287d83510 100644 --- a/subsys/bluetooth/rpc/client/bt_rpc_gatt_client.c +++ b/subsys/bluetooth/rpc/client/bt_rpc_gatt_client.c @@ -15,8 +15,8 @@ #include "bt_rpc_common.h" #include "bt_rpc_gatt_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include "nrf_rpc_cbor.h" #include @@ -71,13 +71,13 @@ void bt_rpc_encode_gatt_attr(struct nrf_rpc_cbor_ctx *encoder, const struct bt_g err = bt_rpc_gatt_attr_to_index(attr, &attr_index); __ASSERT(err == 0, "Service attribute not found. Service database might be out of sync"); - ser_encode_uint(encoder, attr_index); + nrf_rpc_encode_uint(encoder, attr_index); } const struct bt_gatt_attr *bt_rpc_decode_gatt_attr(struct nrf_rpc_cbor_ctx *ctx) { uint32_t attr_index; - attr_index = ser_decode_uint(ctx); + attr_index = nrf_rpc_decode_uint(ctx); return bt_rpc_gatt_index_to_attr(attr_index); } @@ -116,16 +116,16 @@ static void bt_gatt_complete_func_t_callback_rpc_handler(const struct nrf_rpc_gr void *user_data; conn = bt_rpc_decode_bt_conn(ctx); - user_data = (void *)ser_decode_uint(ctx); - callback_slot = (bt_gatt_complete_func_t)ser_decode_callback_call(ctx); + user_data = (void *)nrf_rpc_decode_uint(ctx); + callback_slot = (bt_gatt_complete_func_t)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } callback_slot(conn, user_data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -145,10 +145,10 @@ static void bt_rpc_gatt_ccc_cfg_changed_cb_rpc_handler(const struct nrf_rpc_grou const struct bt_gatt_attr *attr; struct _bt_gatt_ccc *ccc; - attr_index = ser_decode_uint(ctx); - ccc_value = ser_decode_uint(ctx); + attr_index = nrf_rpc_decode_uint(ctx); + ccc_value = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -163,7 +163,7 @@ static void bt_rpc_gatt_ccc_cfg_changed_cb_rpc_handler(const struct nrf_rpc_grou ccc->cfg_changed(attr, ccc_value); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -186,10 +186,10 @@ static void bt_rpc_gatt_ccc_cfg_write_cb_rpc_handler(const struct nrf_rpc_group ssize_t write_len = 0; conn = bt_rpc_decode_bt_conn(ctx); - attr_index = ser_decode_uint(ctx); - ccc_value = ser_decode_uint(ctx); + attr_index = nrf_rpc_decode_uint(ctx); + ccc_value = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -204,7 +204,7 @@ static void bt_rpc_gatt_ccc_cfg_write_cb_rpc_handler(const struct nrf_rpc_group write_len = ccc->cfg_write(conn, attr, ccc_value); } - ser_rsp_send_int(group, write_len); + nrf_rpc_rsp_send_int(group, write_len); return; decoding_error: @@ -226,9 +226,9 @@ static void bt_rpc_gatt_ccc_cfg_match_cb_rpc_handler(const struct nrf_rpc_group bool match = false; conn = bt_rpc_decode_bt_conn(ctx); - attr_index = ser_decode_int(ctx); + attr_index = nrf_rpc_decode_int(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -243,7 +243,7 @@ static void bt_rpc_gatt_ccc_cfg_match_cb_rpc_handler(const struct nrf_rpc_group match = ccc->cfg_match(conn, attr); } - ser_rsp_send_bool(group, match); + nrf_rpc_rsp_send_bool(group, match); return; decoding_error: @@ -258,7 +258,7 @@ static void bt_rpc_gatt_attr_read_cb_rpc_handler(const struct nrf_rpc_group *gro struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { struct bt_conn *conn; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; size_t buffer_size_max = 9; const struct bt_gatt_attr *attr; uint32_t service_index; @@ -267,14 +267,14 @@ static void bt_rpc_gatt_attr_read_cb_rpc_handler(const struct nrf_rpc_group *gro uint16_t len; uint8_t *buf = NULL; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - service_index = ser_decode_uint(ctx); - len = ser_decode_uint(ctx); - offset = ser_decode_uint(ctx); + service_index = nrf_rpc_decode_uint(ctx); + len = nrf_rpc_decode_uint(ctx); + offset = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -283,7 +283,7 @@ static void bt_rpc_gatt_attr_read_cb_rpc_handler(const struct nrf_rpc_group *gro LOG_WRN("Service database may not be synchronized with client"); read_len = BT_GATT_ERR(BT_ATT_ERR_ATTRIBUTE_NOT_FOUND); } else { - buf = ser_scratchpad_add(&scratchpad, len); + buf = nrf_rpc_scratchpad_add(&scratchpad, len); if (attr->read) { read_len = attr->read(conn, attr, buf, len, offset); @@ -297,8 +297,8 @@ static void bt_rpc_gatt_attr_read_cb_rpc_handler(const struct nrf_rpc_group *gro NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, read_len); - ser_encode_buffer(&ectx, buf, read_len); + nrf_rpc_encode_int(&ectx, read_len); + nrf_rpc_encode_buffer(&ectx, buf, read_len); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -314,7 +314,7 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_gatt_attr_read_cb, BT_RPC_GATT_CB_AT static void bt_rpc_gatt_attr_write_cb_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; struct bt_conn *conn; const struct bt_gatt_attr *attr; int service_index; @@ -324,16 +324,16 @@ static void bt_rpc_gatt_attr_write_cb_rpc_handler(const struct nrf_rpc_group *gr uint8_t flags; uint8_t *buf; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - service_index = ser_decode_int(ctx); - len = ser_decode_uint(ctx); - offset = ser_decode_uint(ctx); - flags = ser_decode_uint(ctx); - buf = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + service_index = nrf_rpc_decode_int(ctx); + len = nrf_rpc_decode_uint(ctx); + offset = nrf_rpc_decode_uint(ctx); + flags = nrf_rpc_decode_uint(ctx); + buf = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -347,7 +347,7 @@ static void bt_rpc_gatt_attr_write_cb_rpc_handler(const struct nrf_rpc_group *gr } } - ser_rsp_send_int(group, write_len); + nrf_rpc_rsp_send_int(group, write_len); return; decoding_error: @@ -365,11 +365,11 @@ static int bt_rpc_gatt_start_service(uint8_t service_index, size_t attr_count) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, service_index); - ser_encode_uint(&ctx, attr_count); + nrf_rpc_encode_uint(&ctx, service_index); + nrf_rpc_encode_uint(&ctx, attr_count); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_START_SERVICE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -408,13 +408,13 @@ static size_t bt_uuid_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_uuid break; default: if (encoder != NULL) { - ser_encoder_invalid(encoder); + nrf_rpc_encoder_invalid(encoder); } return 1; } } if (encoder != NULL) { - ser_encode_buffer(encoder, uuid, size); + nrf_rpc_encode_buffer(encoder, uuid, size); } return 1 + size; } @@ -423,7 +423,7 @@ static size_t bt_uuid_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_uuid static struct bt_uuid *bt_uuid_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_uuid *uuid) { - return (struct bt_uuid *)ser_decode_buffer(ctx, uuid, sizeof(struct bt_uuid_128)); + return (struct bt_uuid *)nrf_rpc_decode_buffer(ctx, uuid, sizeof(struct bt_uuid_128)); } #endif /* CONFIG_BT_GATT_CLIENT */ @@ -441,11 +441,11 @@ static int bt_rpc_gatt_send_simple_attr(uint8_t special_attr, const struct bt_uu bt_uuid_enc(&ctx, uuid); - ser_encode_uint(&ctx, special_attr); - ser_encode_uint(&ctx, data); + nrf_rpc_encode_uint(&ctx, special_attr); + nrf_rpc_encode_uint(&ctx, data); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_SEND_SIMPLE_ATTR_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -493,18 +493,18 @@ static int bt_rpc_gatt_send_desc_attr(uint8_t special_attr, uint16_t param, uint buffer_size = sizeof(uint8_t) * size; buffer_size_max += buffer_size; - scratchpad_size += SCRATCHPAD_ALIGN(buffer_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(buffer_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, special_attr); - ser_encode_uint(&ctx, param); - ser_encode_uint(&ctx, size); - ser_encode_buffer(&ctx, buffer, buffer_size); + nrf_rpc_encode_uint(&ctx, special_attr); + nrf_rpc_encode_uint(&ctx, param); + nrf_rpc_encode_uint(&ctx, size); + nrf_rpc_encode_buffer(&ctx, buffer, buffer_size); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_SEND_DESC_ATTR_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -561,7 +561,7 @@ static int bt_rpc_gatt_end_service(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_END_SERVICE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -703,10 +703,10 @@ int bt_gatt_service_unregister(struct bt_gatt_service *svc) return err; } - ser_encode_uint(&ctx, svc_index); + nrf_rpc_encode_uint(&ctx, svc_index); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_SERVICE_UNREGISTER_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); if (result) { return result; @@ -731,7 +731,7 @@ static size_t bt_gatt_notify_params_sp_size(const struct bt_gatt_notify_params * { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(uint8_t) * data->len); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(uint8_t) * data->len); scratchpad_size += data->len; @@ -742,15 +742,15 @@ static void bt_gatt_notify_params_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_gatt_notify_params *data) { bt_rpc_encode_gatt_attr(encoder, data->attr); - ser_encode_uint(encoder, data->len); - ser_encode_buffer(encoder, data->data, sizeof(uint8_t) * data->len); - ser_encode_callback(encoder, data->func); - ser_encode_uint(encoder, (uintptr_t)data->user_data); + nrf_rpc_encode_uint(encoder, data->len); + nrf_rpc_encode_buffer(encoder, data->data, sizeof(uint8_t) * data->len); + nrf_rpc_encode_callback(encoder, data->func); + nrf_rpc_encode_uint(encoder, (uintptr_t)data->user_data); if (data->uuid) { bt_uuid_enc(encoder, data->uuid); } else { - ser_encode_null(encoder); + nrf_rpc_encode_null(encoder); } } @@ -767,13 +767,13 @@ int bt_gatt_notify_cb(struct bt_conn *conn, scratchpad_size += bt_gatt_notify_params_sp_size(params); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); bt_gatt_notify_params_enc(&ctx, params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_NOTIFY_CB_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -803,7 +803,7 @@ static size_t bt_gatt_indicate_params_sp_size(const struct bt_gatt_indicate_para { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(uint8_t) * data->len); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(uint8_t) * data->len); scratchpad_size += data->uuid ? bt_uuid_buf_size(data->uuid) : 0; @@ -824,14 +824,14 @@ static void bt_gatt_indicate_params_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_gatt_indicate_params *data) { bt_rpc_encode_gatt_attr(encoder, data->attr); - ser_encode_uint(encoder, data->len); - ser_encode_buffer(encoder, data->data, sizeof(uint8_t) * data->len); - ser_encode_uint(encoder, data->_ref); + nrf_rpc_encode_uint(encoder, data->len); + nrf_rpc_encode_buffer(encoder, data->data, sizeof(uint8_t) * data->len); + nrf_rpc_encode_uint(encoder, data->_ref); if (data->uuid) { bt_uuid_enc(encoder, data->uuid); } else { - ser_encode_null(encoder); + nrf_rpc_encode_null(encoder); } } @@ -847,14 +847,14 @@ int bt_gatt_indicate(struct bt_conn *conn, struct bt_gatt_indicate_params *param scratchpad_size += bt_gatt_indicate_params_sp_size(params); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); bt_gatt_indicate_params_enc(&ctx, params); - ser_encode_uint(&ctx, params_addr); + nrf_rpc_encode_uint(&ctx, params_addr); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_INDICATE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -868,10 +868,10 @@ static void bt_gatt_indicate_func_t_callback_rpc_handler(const struct nrf_rpc_gr struct bt_gatt_indicate_params *params; conn = bt_rpc_decode_bt_conn(ctx); - err = ser_decode_uint(ctx); - params = (struct bt_gatt_indicate_params *) ser_decode_uint(ctx); + err = nrf_rpc_decode_uint(ctx); + params = (struct bt_gatt_indicate_params *) nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -879,7 +879,7 @@ static void bt_gatt_indicate_func_t_callback_rpc_handler(const struct nrf_rpc_gr params->func(conn, params, err); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -896,9 +896,9 @@ static void bt_gatt_indicate_params_destroy_t_callback_rpc_handler( { struct bt_gatt_indicate_params *params; - params = (struct bt_gatt_indicate_params *)ser_decode_uint(ctx); + params = (struct bt_gatt_indicate_params *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -906,7 +906,7 @@ static void bt_gatt_indicate_params_destroy_t_callback_rpc_handler( params->destroy(params); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -928,10 +928,10 @@ bool bt_gatt_is_subscribed(struct bt_conn *conn, bt_rpc_encode_bt_conn(&ctx, conn); bt_rpc_encode_gatt_attr(&ctx, attr); - ser_encode_uint(&ctx, ccc_value); + nrf_rpc_encode_uint(&ctx, ccc_value); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_IS_SUBSCRIBED_RPC_CMD, - &ctx, ser_rsp_decode_bool, &result); + &ctx, nrf_rpc_rsp_decode_bool, &result); return result; } @@ -947,7 +947,7 @@ uint16_t bt_gatt_get_mtu(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_GET_MTU_RPC_CMD, - &ctx, ser_rsp_decode_u16, &result); + &ctx, nrf_rpc_rsp_decode_u16, &result); return result; } @@ -963,16 +963,16 @@ static void bt_gatt_exchange_mtu_callback_rpc_handler(const struct nrf_rpc_group struct bt_gatt_exchange_params *params; conn = bt_rpc_decode_bt_conn(ctx); - err = ser_decode_uint(ctx); - params = (struct bt_gatt_exchange_params *)ser_decode_uint(ctx); + err = nrf_rpc_decode_uint(ctx); + params = (struct bt_gatt_exchange_params *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } params->func(conn, err, params); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; @@ -992,10 +992,10 @@ int bt_gatt_exchange_mtu(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, 8); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_EXCHANGE_MTU_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1047,7 +1047,7 @@ uint16_t bt_gatt_attr_get_handle(const struct bt_gatt_attr *attr) bt_rpc_encode_gatt_attr(&ctx, attr); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_ATTR_GET_HANDLE_RPC_CMD, - &ctx, ser_rsp_decode_u16, &result); + &ctx, nrf_rpc_rsp_decode_u16, &result); return result; } @@ -1094,7 +1094,7 @@ static void bt_le_gatt_cb_register_on_remote(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_GATT_CB_REGISTER_ON_REMOTE_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } void bt_gatt_cb_register(struct bt_gatt_cb *cb) @@ -1120,10 +1120,10 @@ static void bt_gatt_cb_att_mtu_update_call_rpc_handler(const struct nrf_rpc_grou uint16_t rx; conn = bt_rpc_decode_bt_conn(ctx); - tx = ser_decode_uint(ctx); - rx = ser_decode_uint(ctx); + tx = nrf_rpc_decode_uint(ctx); + rx = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1131,7 +1131,7 @@ static void bt_gatt_cb_att_mtu_update_call_rpc_handler(const struct nrf_rpc_grou listener->att_mtu_updated(conn, tx, rx); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1153,9 +1153,9 @@ static void bt_gatt_discover_params_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_gatt_discover_params *data) { bt_uuid_enc(encoder, data->uuid); - ser_encode_uint(encoder, data->start_handle); - ser_encode_uint(encoder, data->end_handle); - ser_encode_uint(encoder, data->type); + nrf_rpc_encode_uint(encoder, data->start_handle); + nrf_rpc_encode_uint(encoder, data->end_handle); + nrf_rpc_encode_uint(encoder, data->type); } int bt_gatt_discover(struct bt_conn *conn, struct bt_gatt_discover_params *params) @@ -1167,10 +1167,10 @@ int bt_gatt_discover(struct bt_conn *conn, struct bt_gatt_discover_params *param bt_rpc_encode_bt_conn(&ctx, conn); bt_gatt_discover_params_enc(&ctx, params); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_DISCOVER_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1198,16 +1198,16 @@ static void bt_gatt_discover_callback_rpc_handler(const struct nrf_rpc_group *gr struct bt_gatt_attr *attr = &attr_instance; conn = bt_rpc_decode_bt_conn(ctx); - params_pointer = ser_decode_uint(ctx); + params_pointer = nrf_rpc_decode_uint(ctx); params = (struct bt_gatt_discover_params *)params_pointer; - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { attr = NULL; } else { attr->uuid = bt_uuid_dec(ctx, &uuid_buffers[0].uuid); - attr->handle = ser_decode_uint(ctx); + attr->handle = nrf_rpc_decode_uint(ctx); attr_uuid_16 = (struct bt_uuid_16 *)attr->uuid; - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { attr->user_data = NULL; } else if (attr->uuid == NULL || attr->uuid->type != BT_UUID_TYPE_16) { LOG_ERR("Invalid attribute UUID"); @@ -1215,33 +1215,33 @@ static void bt_gatt_discover_callback_rpc_handler(const struct nrf_rpc_group *gr } else if (attr_uuid_16->val == BT_UUID_GATT_PRIMARY_VAL || attr_uuid_16->val == BT_UUID_GATT_SECONDARY_VAL) { user_data.service.uuid = bt_uuid_dec(ctx, &uuid_buffers[1].uuid); - user_data.service.end_handle = ser_decode_uint(ctx); + user_data.service.end_handle = nrf_rpc_decode_uint(ctx); } else if (attr_uuid_16->val == BT_UUID_GATT_INCLUDE_VAL) { user_data.include.uuid = bt_uuid_dec(ctx, &uuid_buffers[1].uuid); - user_data.include.start_handle = ser_decode_uint(ctx); - user_data.include.end_handle = ser_decode_uint(ctx); + user_data.include.start_handle = nrf_rpc_decode_uint(ctx); + user_data.include.end_handle = nrf_rpc_decode_uint(ctx); } else if (attr_uuid_16->val == BT_UUID_GATT_CHRC_VAL) { user_data.chrc.uuid = bt_uuid_dec(ctx, &uuid_buffers[1].uuid); - user_data.chrc.value_handle = ser_decode_uint(ctx); - user_data.chrc.properties = ser_decode_uint(ctx); + user_data.chrc.value_handle = nrf_rpc_decode_uint(ctx); + user_data.chrc.properties = nrf_rpc_decode_uint(ctx); } else { LOG_ERR("Unsupported attribute UUID"); goto decoding_done_with_error; } } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = params->func(conn, attr, params); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_done_with_error: - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); decoding_error: report_decoding_error(BT_GATT_DISCOVER_CALLBACK_RPC_CMD, handler_data); } @@ -1266,18 +1266,18 @@ static size_t bt_gatt_read_params_buf_size(const struct bt_gatt_read_params *dat static void bt_gatt_read_params_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_gatt_read_params *data) { - ser_encode_uint(encoder, data->handle_count); + nrf_rpc_encode_uint(encoder, data->handle_count); if (data->handle_count == 0) { - ser_encode_uint(encoder, data->by_uuid.start_handle); - ser_encode_uint(encoder, data->by_uuid.end_handle); + nrf_rpc_encode_uint(encoder, data->by_uuid.start_handle); + nrf_rpc_encode_uint(encoder, data->by_uuid.end_handle); bt_uuid_enc(encoder, data->by_uuid.uuid); } else if (data->handle_count == 1) { - ser_encode_uint(encoder, data->single.handle); - ser_encode_uint(encoder, data->single.offset); + nrf_rpc_encode_uint(encoder, data->single.handle); + nrf_rpc_encode_uint(encoder, data->single.offset); } else { - ser_encode_buffer(encoder, data->multiple.handles, + nrf_rpc_encode_buffer(encoder, data->multiple.handles, sizeof(data->multiple.handles[0]) * data->handle_count); - ser_encode_bool(encoder, data->multiple.variable); + nrf_rpc_encode_bool(encoder, data->multiple.variable); } } @@ -1290,10 +1290,10 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params) bt_rpc_encode_bt_conn(&ctx, conn); bt_gatt_read_params_enc(&ctx, params); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_READ_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1301,7 +1301,7 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params) static void bt_gatt_read_callback_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; struct bt_conn *conn; uintptr_t params_pointer; uint8_t err; @@ -1310,22 +1310,22 @@ static void bt_gatt_read_callback_rpc_handler(const struct nrf_rpc_group *group, void *data; size_t length; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - err = ser_decode_uint(ctx); - params_pointer = ser_decode_uint(ctx); + err = nrf_rpc_decode_uint(ctx); + params_pointer = nrf_rpc_decode_uint(ctx); params = (struct bt_gatt_read_params *)params_pointer; - data = ser_decode_buffer_into_scratchpad(&scratchpad, &length); + data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, &length); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = params->func(conn, err, params, data, (uint16_t)length); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; @@ -1344,9 +1344,9 @@ static size_t bt_gatt_write_params_buf_size(const struct bt_gatt_write_params *d static void bt_gatt_write_params_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_gatt_write_params *data) { - ser_encode_buffer(encoder, data->data, data->length); - ser_encode_uint(encoder, data->handle); - ser_encode_uint(encoder, data->offset); + nrf_rpc_encode_buffer(encoder, data->data, data->length); + nrf_rpc_encode_uint(encoder, data->handle); + nrf_rpc_encode_uint(encoder, data->offset); } int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params) @@ -1358,10 +1358,10 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params) bt_rpc_encode_bt_conn(&ctx, conn); bt_gatt_write_params_enc(&ctx, params); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_WRITE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1374,16 +1374,16 @@ static void bt_gatt_write_callback_rpc_handler(const struct nrf_rpc_group *group struct bt_gatt_write_params *params; conn = bt_rpc_decode_bt_conn(ctx); - err = ser_decode_uint(ctx); - params = (struct bt_gatt_write_params *)ser_decode_uint(ctx); + err = nrf_rpc_decode_uint(ctx); + params = (struct bt_gatt_write_params *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } params->func(conn, err, params); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; @@ -1408,21 +1408,21 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle, _data_size = sizeof(uint8_t) * length; buffer_size_max += _data_size; - scratchpad_size += SCRATCHPAD_ALIGN(_data_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(_data_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, handle); - ser_encode_uint(&ctx, length); - ser_encode_buffer(&ctx, data, _data_size); - ser_encode_bool(&ctx, sign); - ser_encode_callback(&ctx, func); - ser_encode_uint(&ctx, (uintptr_t)user_data); + nrf_rpc_encode_uint(&ctx, handle); + nrf_rpc_encode_uint(&ctx, length); + nrf_rpc_encode_buffer(&ctx, data, _data_size); + nrf_rpc_encode_bool(&ctx, sign); + nrf_rpc_encode_callback(&ctx, func); + nrf_rpc_encode_uint(&ctx, (uintptr_t)user_data); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_WRITE_WITHOUT_RESPONSE_CB_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1443,15 +1443,15 @@ static const size_t bt_gatt_subscribe_params_buf_size = static void bt_gatt_subscribe_params_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_gatt_subscribe_params *data) { - ser_encode_bool(encoder, data->notify != NULL); - ser_encode_callback(encoder, data->write); - ser_encode_uint(encoder, data->value_handle); - ser_encode_uint(encoder, data->ccc_handle); - ser_encode_uint(encoder, data->value); + nrf_rpc_encode_bool(encoder, data->notify != NULL); + nrf_rpc_encode_callback(encoder, data->write); + nrf_rpc_encode_uint(encoder, data->value_handle); + nrf_rpc_encode_uint(encoder, data->ccc_handle); + nrf_rpc_encode_uint(encoder, data->value); #if defined(CONFIG_BT_SMP) - ser_encode_uint(encoder, data->min_security); + nrf_rpc_encode_uint(encoder, data->min_security); #endif /* defined(CONFIG_BT_SMP) */ - ser_encode_uint(encoder, (uint16_t)atomic_get(data->flags)); + nrf_rpc_encode_uint(encoder, (uint16_t)atomic_get(data->flags)); } int bt_gatt_subscribe(struct bt_conn *conn, @@ -1466,11 +1466,11 @@ int bt_gatt_subscribe(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); bt_gatt_subscribe_params_enc(&ctx, params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_SUBSCRIBE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1488,14 +1488,14 @@ int bt_gatt_resubscribe(uint8_t id, const bt_addr_le_t *peer, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); - ser_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); bt_gatt_subscribe_params_enc(&ctx, params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_RESUBSCRIBE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1510,10 +1510,10 @@ int bt_gatt_unsubscribe(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_UNSUBSCRIBE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1527,12 +1527,12 @@ static int bt_rpc_gatt_subscribe_flag_update(struct bt_gatt_subscribe_params *pa NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)params); - ser_encode_uint(&ctx, flags_bit); - ser_encode_int(&ctx, val); + nrf_rpc_encode_uint(&ctx, (uintptr_t)params); + nrf_rpc_encode_uint(&ctx, flags_bit); + nrf_rpc_encode_int(&ctx, val); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_SUBSCRIBE_FLAG_UPDATE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + &ctx, nrf_rpc_rsp_decode_i32, &result); return result; } @@ -1561,15 +1561,15 @@ static void bt_gatt_subscribe_params_notify_rpc_handler(const struct nrf_rpc_gro size_t length; uint8_t *data; uint8_t result = BT_GATT_ITER_CONTINUE; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - params = (struct bt_gatt_subscribe_params *)ser_decode_uint(ctx); - data = ser_decode_buffer_into_scratchpad(&scratchpad, &length); + params = (struct bt_gatt_subscribe_params *)nrf_rpc_decode_uint(ctx); + data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, &length); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1577,7 +1577,7 @@ static void bt_gatt_subscribe_params_notify_rpc_handler(const struct nrf_rpc_gro result = params->notify(conn, params, data, (uint16_t)length); } - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_error: @@ -1595,34 +1595,34 @@ static void bt_gatt_subscribe_params_write_rpc_handler(const struct nrf_rpc_grou uint8_t err; struct bt_gatt_write_params params; struct bt_gatt_write_params *params_ptr; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; bt_gatt_write_func_t func; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - err = ser_decode_uint(ctx); - if (ser_decode_is_null(ctx)) { + err = nrf_rpc_decode_uint(ctx); + if (nrf_rpc_decode_is_null(ctx)) { params_ptr = NULL; } else { size_t len; - params.handle = ser_decode_uint(ctx); - params.offset = ser_decode_uint(ctx); - params.data = ser_decode_buffer_into_scratchpad(&scratchpad, &len); + params.handle = nrf_rpc_decode_uint(ctx); + params.offset = nrf_rpc_decode_uint(ctx); + params.data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, &len); params.length = len; params_ptr = ¶ms; } - func = (bt_gatt_write_func_t)ser_decode_callback_call(ctx); + func = (bt_gatt_write_func_t)nrf_rpc_decode_callback_call(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } if (func != NULL) { func(conn, err, params_ptr); } - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: diff --git a/subsys/bluetooth/rpc/client/bt_rpc_internal_client.c b/subsys/bluetooth/rpc/client/bt_rpc_internal_client.c index adfb32764e51..5ec6fe5945b7 100644 --- a/subsys/bluetooth/rpc/client/bt_rpc_internal_client.c +++ b/subsys/bluetooth/rpc/client/bt_rpc_internal_client.c @@ -8,8 +8,8 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include #include @@ -29,10 +29,10 @@ bool bt_addr_le_is_bonded(uint8_t id, const bt_addr_le_t *addr) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_ADDR_LE_IS_BONDED_CMD, - &ctx, ser_rsp_decode_bool, &result); + &ctx, nrf_rpc_rsp_decode_bool, &result); return result; } @@ -43,12 +43,12 @@ struct bt_hci_cmd_send_sync_res { struct net_buf **rsp; }; -static void decode_net_buf(struct ser_scratchpad *scratchpad, struct net_buf *data) +static void decode_net_buf(struct nrf_rpc_scratchpad *scratchpad, struct net_buf *data) { size_t len; void *buf; - buf = ser_decode_buffer_into_scratchpad(scratchpad, &len); + buf = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, &len); net_buf_add_mem(data, buf, len); } @@ -56,16 +56,16 @@ static void bt_hci_cmd_send_sync_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { struct bt_hci_cmd_send_sync_res *res; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; res = (struct bt_hci_cmd_send_sync_res *)handler_data; - res->result = ser_decode_int(ctx); + res->result = nrf_rpc_decode_int(ctx); - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { *res->rsp = NULL; } else { - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); *res->rsp = net_buf_alloc(&hci_cmd_pool, K_FOREVER); decode_net_buf(&scratchpad, *res->rsp); } @@ -82,20 +82,20 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, struct net_buf ** buffer_size_max += rsp == NULL ? 1 : 0; NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, opcode); + nrf_rpc_encode_uint(&ctx, opcode); if (buf == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else { - scratchpad_size = SCRATCHPAD_ALIGN(buf->len); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, buf->len); - ser_encode_buffer(&ctx, buf->data, buf->len); + scratchpad_size = NRF_RPC_SCRATCHPAD_ALIGN(buf->len); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, buf->len); + nrf_rpc_encode_buffer(&ctx, buf->data, buf->len); } if (rsp == NULL) { /* The caller is not interested in the response. */ - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } result.buf = buf; diff --git a/subsys/bluetooth/rpc/common/CMakeLists.txt b/subsys/bluetooth/rpc/common/CMakeLists.txt index 1b96d9b8f7f5..deaab518af47 100644 --- a/subsys/bluetooth/rpc/common/CMakeLists.txt +++ b/subsys/bluetooth/rpc/common/CMakeLists.txt @@ -7,9 +7,7 @@ zephyr_library() zephyr_library_link_libraries(subsys_bluetooth_rpc) -zephyr_library_sources(bt_rpc_common.c - cbkproxy.c - serialize.c) +zephyr_library_sources(bt_rpc_common.c) zephyr_library_sources_ifdef( CONFIG_BT_CONN diff --git a/subsys/bluetooth/rpc/common/bt_rpc_common.c b/subsys/bluetooth/rpc/common/bt_rpc_common.c index ee089195aaaa..5927797915f5 100644 --- a/subsys/bluetooth/rpc/common/bt_rpc_common.c +++ b/subsys/bluetooth/rpc/common/bt_rpc_common.c @@ -237,7 +237,7 @@ static const CHECK_LIST_ENTRY_TYPE check_table[] = { CHECK_UINT8(CONFIG_BT_DEVICE_NAME_MAX), CHECK_UINT8(CONFIG_BT_PER_ADV_SYNC_MAX), CHECK_UINT16(CONFIG_BT_DEVICE_APPEARANCE), - CHECK_UINT16_PAIR(CONFIG_CBKPROXY_OUT_SLOTS, CONFIG_CBKPROXY_IN_SLOTS), + CHECK_UINT16_PAIR(CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS, CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS), }; static const STR_CHECK_LIST_ENTRY_TYPE str_check_list[] = diff --git a/subsys/bluetooth/rpc/common/bt_rpc_common.h b/subsys/bluetooth/rpc/common/bt_rpc_common.h index 7ce96b69c153..0427bcc39729 100644 --- a/subsys/bluetooth/rpc/common/bt_rpc_common.h +++ b/subsys/bluetooth/rpc/common/bt_rpc_common.h @@ -19,7 +19,7 @@ #include #include -#include +#include #define BT_RPC_SIZE_OF_FIELD(structure, field) (sizeof(((structure *)NULL)->field)) @@ -289,7 +289,7 @@ struct bt_conn *bt_rpc_decode_bt_conn(struct nrf_rpc_cbor_ctx *ctx); /** @brief Declaration of callback proxy encoder for bt_gatt_complete_func_t. */ -CBKPROXY_HANDLER_DECL(bt_gatt_complete_func_t_encoder, +NRF_RPC_CBKPROXY_HANDLER_DECL(bt_gatt_complete_func_t_encoder, (struct bt_conn *conn, void *user_data), (conn, user_data)); #endif /* BT_RPC_COMMON_H_ */ diff --git a/subsys/bluetooth/rpc/host/bt_rpc_conn_host.c b/subsys/bluetooth/rpc/host/bt_rpc_conn_host.c index a6704d82c304..3f11a228ec00 100644 --- a/subsys/bluetooth/rpc/host/bt_rpc_conn_host.c +++ b/subsys/bluetooth/rpc/host/bt_rpc_conn_host.c @@ -12,8 +12,8 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include @@ -29,7 +29,7 @@ void bt_rpc_encode_bt_conn(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn *conn) { if (CONFIG_BT_MAX_CONN > 1) { - ser_encode_uint(encoder, (uint8_t)bt_conn_index((struct bt_conn *)conn)); + nrf_rpc_encode_uint(encoder, (uint8_t)bt_conn_index((struct bt_conn *)conn)); } } @@ -42,7 +42,7 @@ struct bt_conn *bt_rpc_decode_bt_conn(struct nrf_rpc_cbor_ctx *ctx) uint8_t index; if (CONFIG_BT_MAX_CONN > 1) { - index = ser_decode_uint(ctx); + index = nrf_rpc_decode_uint(ctx); } else { index = 0; } @@ -71,15 +71,15 @@ static void bt_conn_remote_update_ref_rpc_handler(const struct nrf_rpc_group *gr int8_t count; conn = bt_rpc_decode_bt_conn(ctx); - count = ser_decode_int(ctx); + count = nrf_rpc_decode_int(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_remote_update_ref(conn, count); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -99,14 +99,14 @@ static inline void bt_conn_foreach_cb_callback(struct bt_conn *conn, void *data, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uintptr_t)data); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_uint(&ctx, (uintptr_t)data); + nrf_rpc_encode_callback_call(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_FOREACH_CB_CALLBACK_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_conn_foreach_cb_encoder, bt_conn_foreach_cb_callback, +NRF_RPC_CBKPROXY_HANDLER(bt_conn_foreach_cb_encoder, bt_conn_foreach_cb_callback, (struct bt_conn *conn, void *data), (conn, data)); static void bt_conn_foreach_rpc_handler(const struct nrf_rpc_group *group, @@ -116,17 +116,17 @@ static void bt_conn_foreach_rpc_handler(const struct nrf_rpc_group *group, bt_conn_foreach_cb func; void *data; - type = ser_decode_int(ctx); - func = (bt_conn_foreach_cb)ser_decode_callback(ctx, bt_conn_foreach_cb_encoder); - data = (void *)ser_decode_uint(ctx); + type = nrf_rpc_decode_int(ctx); + func = (bt_conn_foreach_cb)nrf_rpc_decode_callbackd(ctx, bt_conn_foreach_cb_encoder); + data = (void *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_conn_foreach(type, func, data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -146,10 +146,10 @@ static void bt_conn_lookup_addr_le_rpc_handler(const struct nrf_rpc_group *group const bt_addr_le_t *peer; size_t buffer_size_max = 3; - id = ser_decode_uint(ctx); - peer = ser_decode_buffer(ctx, &peer_data, sizeof(bt_addr_le_t)); + id = nrf_rpc_decode_uint(ctx); + peer = nrf_rpc_decode_buffer(ctx, &peer_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -184,7 +184,7 @@ static void bt_conn_get_dst_out_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -198,8 +198,8 @@ static void bt_conn_get_dst_out_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_bool(&ectx, result); - ser_encode_buffer(&ectx, dst, sizeof(bt_addr_le_t)); + nrf_rpc_encode_bool(&ectx, result); + nrf_rpc_encode_buffer(&ectx, dst, sizeof(bt_addr_le_t)); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -220,8 +220,8 @@ static const size_t bt_conn_le_phy_info_buf_size = static bt_conn_le_phy_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn_le_phy_info *data) { - ser_encode_uint(encoder, data->tx_phy); - ser_encode_uint(encoder, data->rx_phy); + nrf_rpc_encode_uint(encoder, data->tx_phy); + nrf_rpc_encode_uint(encoder, data->rx_phy); } #endif /* defined(CONFIG_BT_USER_PHY_UPDATE) */ @@ -235,10 +235,10 @@ static const size_t bt_conn_le_data_len_info_buf_size = static void bt_conn_le_data_len_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn_le_data_len_info *data) { - ser_encode_uint(encoder, data->tx_max_len); - ser_encode_uint(encoder, data->tx_max_time); - ser_encode_uint(encoder, data->rx_max_len); - ser_encode_uint(encoder, data->rx_max_time); + nrf_rpc_encode_uint(encoder, data->tx_max_len); + nrf_rpc_encode_uint(encoder, data->tx_max_time); + nrf_rpc_encode_uint(encoder, data->rx_max_len); + nrf_rpc_encode_uint(encoder, data->rx_max_time); } #endif /* defined(CONFIG_BT_USER_DATA_LEN_UPDATE) */ @@ -264,32 +264,32 @@ static const size_t bt_conn_info_buf_size = static void bt_conn_info_enc(struct nrf_rpc_cbor_ctx *encoder, struct bt_conn_info *info) { - ser_encode_uint(encoder, info->type); - ser_encode_uint(encoder, info->role); - ser_encode_uint(encoder, info->id); + nrf_rpc_encode_uint(encoder, info->type); + nrf_rpc_encode_uint(encoder, info->role); + nrf_rpc_encode_uint(encoder, info->id); if (info->type == BT_CONN_TYPE_LE) { - ser_encode_uint(encoder, info->le.interval); - ser_encode_uint(encoder, info->le.latency); - ser_encode_uint(encoder, info->le.timeout); - ser_encode_buffer(encoder, info->le.src, sizeof(bt_addr_le_t)); - ser_encode_buffer(encoder, info->le.dst, sizeof(bt_addr_le_t)); - ser_encode_buffer(encoder, info->le.local, sizeof(bt_addr_le_t)); - ser_encode_buffer(encoder, info->le.remote, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, info->le.interval); + nrf_rpc_encode_uint(encoder, info->le.latency); + nrf_rpc_encode_uint(encoder, info->le.timeout); + nrf_rpc_encode_buffer(encoder, info->le.src, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(encoder, info->le.dst, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(encoder, info->le.local, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(encoder, info->le.remote, sizeof(bt_addr_le_t)); #if defined(CONFIG_BT_USER_PHY_UPDATE) bt_conn_le_phy_info_enc(encoder, info->le.phy); #else - ser_encode_null(encoder); + nrf_rpc_encode_null(encoder); #endif #if defined(CONFIG_BT_USER_DATA_LEN_UPDATE) bt_conn_le_data_len_info_enc(encoder, info->le.data_len); #else - ser_encode_null(encoder); + nrf_rpc_encode_null(encoder); #endif - ser_encode_uint(encoder, info->state); + nrf_rpc_encode_uint(encoder, info->state); } else { /* non-LE connection types are not supported. */ - ser_encoder_invalid(encoder); + nrf_rpc_encoder_invalid(encoder); } } @@ -304,7 +304,7 @@ static void bt_conn_get_info_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -317,7 +317,7 @@ static void bt_conn_get_info_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); + nrf_rpc_encode_int(&ectx, result); bt_conn_info_enc(&ectx, &info); @@ -343,16 +343,16 @@ static const size_t bt_conn_remote_info_buf_size = static void bt_conn_remote_info_enc(struct nrf_rpc_cbor_ctx *encoder, struct bt_conn_remote_info *remote_info) { - ser_encode_uint(encoder, remote_info->type); - ser_encode_uint(encoder, remote_info->version); - ser_encode_uint(encoder, remote_info->manufacturer); - ser_encode_uint(encoder, remote_info->subversion); + nrf_rpc_encode_uint(encoder, remote_info->type); + nrf_rpc_encode_uint(encoder, remote_info->version); + nrf_rpc_encode_uint(encoder, remote_info->manufacturer); + nrf_rpc_encode_uint(encoder, remote_info->subversion); if (remote_info->type == BT_CONN_TYPE_LE) { - ser_encode_buffer(encoder, remote_info->le.features, 8 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, remote_info->le.features, 8 * sizeof(uint8_t)); } else { /* non-LE connection types are not supported. */ - ser_encoder_invalid(encoder); + nrf_rpc_encoder_invalid(encoder); } } @@ -367,7 +367,7 @@ static void bt_conn_get_remote_info_rpc_handler(const struct nrf_rpc_group *grou conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -380,7 +380,7 @@ static void bt_conn_get_remote_info_rpc_handler(const struct nrf_rpc_group *grou NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); + nrf_rpc_encode_int(&ectx, result); bt_conn_remote_info_enc(&ectx, &remote_info); @@ -398,18 +398,18 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_get_remote_info, BT_CONN_GET_REMOTE static void bt_le_conn_param_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_conn_param *data) { - ser_encode_uint(encoder, data->interval_min); - ser_encode_uint(encoder, data->interval_max); - ser_encode_uint(encoder, data->latency); - ser_encode_uint(encoder, data->timeout); + nrf_rpc_encode_uint(encoder, data->interval_min); + nrf_rpc_encode_uint(encoder, data->interval_max); + nrf_rpc_encode_uint(encoder, data->latency); + nrf_rpc_encode_uint(encoder, data->timeout); } static void bt_le_conn_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_conn_param *data) { - data->interval_min = ser_decode_uint(ctx); - data->interval_max = ser_decode_uint(ctx); - data->latency = ser_decode_uint(ctx); - data->timeout = ser_decode_uint(ctx); + data->interval_min = nrf_rpc_decode_uint(ctx); + data->interval_max = nrf_rpc_decode_uint(ctx); + data->latency = nrf_rpc_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); } static void bt_conn_le_param_update_rpc_handler(const struct nrf_rpc_group *group, @@ -422,13 +422,13 @@ static void bt_conn_le_param_update_rpc_handler(const struct nrf_rpc_group *grou conn = bt_rpc_decode_bt_conn(ctx); bt_le_conn_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_le_param_update(conn, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -442,8 +442,8 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_le_param_update, BT_CONN_LE_PARAM_U static void bt_conn_le_data_len_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn_le_data_len_param *data) { - data->tx_max_len = ser_decode_uint(ctx); - data->tx_max_time = ser_decode_uint(ctx); + data->tx_max_len = nrf_rpc_decode_uint(ctx); + data->tx_max_time = nrf_rpc_decode_uint(ctx); } static void bt_conn_le_data_len_update_rpc_handler(const struct nrf_rpc_group *group, @@ -456,13 +456,13 @@ static void bt_conn_le_data_len_update_rpc_handler(const struct nrf_rpc_group *g conn = bt_rpc_decode_bt_conn(ctx); bt_conn_le_data_len_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_le_data_len_update(conn, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -477,9 +477,9 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_le_data_len_update, BT_CONN_LE_DATA static void bt_conn_le_phy_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn_le_phy_param *data) { - data->options = ser_decode_uint(ctx); - data->pref_tx_phy = ser_decode_uint(ctx); - data->pref_rx_phy = ser_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); + data->pref_tx_phy = nrf_rpc_decode_uint(ctx); + data->pref_rx_phy = nrf_rpc_decode_uint(ctx); } static void bt_conn_le_phy_update_rpc_handler(const struct nrf_rpc_group *group, @@ -492,13 +492,13 @@ static void bt_conn_le_phy_update_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); bt_conn_le_phy_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_le_phy_update(conn, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -517,15 +517,15 @@ static void bt_conn_disconnect_rpc_handler(const struct nrf_rpc_group *group, int result; conn = bt_rpc_decode_bt_conn(ctx); - reason = ser_decode_uint(ctx); + reason = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_disconnect(conn, reason); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -539,12 +539,12 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_disconnect, BT_CONN_DISCONNECT_RPC_ static void bt_conn_le_create_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn_le_create_param *data) { - data->options = ser_decode_uint(ctx); - data->interval = ser_decode_uint(ctx); - data->window = ser_decode_uint(ctx); - data->interval_coded = ser_decode_uint(ctx); - data->window_coded = ser_decode_uint(ctx); - data->timeout = ser_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); + data->interval = nrf_rpc_decode_uint(ctx); + data->window = nrf_rpc_decode_uint(ctx); + data->interval_coded = nrf_rpc_decode_uint(ctx); + data->window_coded = nrf_rpc_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); } static void bt_conn_le_create_rpc_handler(const struct nrf_rpc_group *group, @@ -559,11 +559,11 @@ static void bt_conn_le_create_rpc_handler(const struct nrf_rpc_group *group, struct bt_conn **conn = &conn_data; size_t buffer_size_max = 8; - peer = ser_decode_buffer(ctx, &peer_data, sizeof(bt_addr_le_t)); + peer = nrf_rpc_decode_buffer(ctx, &peer_data, sizeof(bt_addr_le_t)); bt_conn_le_create_param_dec(ctx, &create_param); bt_le_conn_param_dec(ctx, &conn_param); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -574,7 +574,7 @@ static void bt_conn_le_create_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); + nrf_rpc_encode_int(&ectx, result); bt_rpc_encode_bt_conn(&ectx, *conn); nrf_rpc_cbor_rsp_no_err(group, &ectx); @@ -599,13 +599,13 @@ static void bt_conn_le_create_auto_rpc_handler(const struct nrf_rpc_group *group bt_conn_le_create_param_dec(ctx, &create_param); bt_le_conn_param_dec(ctx, &conn_param); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_le_create_auto(&create_param, &conn_param); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -624,7 +624,7 @@ static void bt_conn_create_auto_stop_rpc_handler(const struct nrf_rpc_group *gro result = bt_conn_create_auto_stop(); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_create_auto_stop, BT_CONN_CREATE_AUTO_STOP_RPC_CMD, @@ -641,21 +641,21 @@ static void bt_le_set_auto_conn_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_conn_param *param; int result; - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - if (ser_decode_is_null(ctx)) { + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + if (nrf_rpc_decode_is_null(ctx)) { param = NULL; } else { param = ¶m_data; bt_le_conn_param_dec(ctx, param); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_set_auto_conn(addr, param); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -676,15 +676,15 @@ static void bt_conn_set_security_rpc_handler(const struct nrf_rpc_group *group, int result; conn = bt_rpc_decode_bt_conn(ctx); - sec = (bt_security_t)ser_decode_uint(ctx); + sec = (bt_security_t)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_set_security(conn, sec); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -703,7 +703,7 @@ static void bt_conn_get_security_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -714,7 +714,7 @@ static void bt_conn_get_security_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_uint(&ectx, (uint32_t)result); + nrf_rpc_encode_uint(&ectx, (uint32_t)result); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -735,13 +735,13 @@ static void bt_conn_enc_key_size_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_enc_key_size(conn); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_error: @@ -760,10 +760,10 @@ static void bt_conn_cb_connected_call(struct bt_conn *conn, uint8_t err) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, err); + nrf_rpc_encode_uint(&ctx, err); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_CONNECTED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } static void bt_conn_cb_disconnected_call(struct bt_conn *conn, uint8_t reason) @@ -774,10 +774,10 @@ static void bt_conn_cb_disconnected_call(struct bt_conn *conn, uint8_t reason) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, reason); + nrf_rpc_encode_uint(&ctx, reason); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_DISCONNECTED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } static bool bt_conn_cb_le_param_req_call(struct bt_conn *conn, struct bt_le_conn_param *param) @@ -792,7 +792,7 @@ static bool bt_conn_cb_le_param_req_call(struct bt_conn *conn, struct bt_le_conn bt_le_conn_param_enc(&ctx, param); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_LE_PARAM_REQ_CALL_RPC_CMD, - &ctx, ser_rsp_decode_bool, &result); + &ctx, nrf_rpc_rsp_decode_bool, &result); return result; } @@ -806,12 +806,12 @@ static void bt_conn_cb_le_param_updated_call(struct bt_conn *conn, uint16_t inte NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, interval); - ser_encode_uint(&ctx, latency); - ser_encode_uint(&ctx, timeout); + nrf_rpc_encode_uint(&ctx, interval); + nrf_rpc_encode_uint(&ctx, latency); + nrf_rpc_encode_uint(&ctx, timeout); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_LE_PARAM_UPDATED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } #if defined(CONFIG_BT_SMP) @@ -827,11 +827,11 @@ static void bt_conn_cb_identity_resolved_call(struct bt_conn *conn, const bt_add NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_buffer(&ctx, rpa, sizeof(bt_addr_le_t)); - ser_encode_buffer(&ctx, identity, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, rpa, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ctx, identity, sizeof(bt_addr_le_t)); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_IDENTITY_RESOLVED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } static void bt_conn_cb_security_changed_call(struct bt_conn *conn, bt_security_t level, @@ -843,11 +843,11 @@ static void bt_conn_cb_security_changed_call(struct bt_conn *conn, bt_security_t NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uint32_t)level); - ser_encode_uint(&ctx, (uint32_t)err); + nrf_rpc_encode_uint(&ctx, (uint32_t)level); + nrf_rpc_encode_uint(&ctx, (uint32_t)err); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_SECURITY_CHANGED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } #endif /* defined(CONFIG_BT_SMP) */ @@ -867,7 +867,7 @@ static void bt_conn_cb_remote_info_available_call(struct bt_conn *conn, bt_conn_remote_info_enc(&ctx, remote_info); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_REMOTE_INFO_AVAILABLE_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } #endif /* defined(CONFIG_BT_REMOTE_INFO) */ @@ -883,7 +883,7 @@ static void bt_conn_cb_le_phy_updated_call(struct bt_conn *conn, struct bt_conn_ bt_conn_le_phy_info_enc(&ctx, param); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_LE_PHY_UPDATED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } #endif /* defined(CONFIG_BT_USER_PHY_UPDATE) */ @@ -900,7 +900,7 @@ static void bt_conn_cb_le_data_len_updated_call(struct bt_conn *conn, bt_conn_le_data_len_info_enc(&ctx, info); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_CONN_CB_LE_DATA_LEN_UPDATED_CALL_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } #endif /* defined(CONFIG_BT_USER_DATA_LEN_UPDATE) */ @@ -933,7 +933,7 @@ static void bt_conn_cb_register_on_remote_rpc_handler(const struct nrf_rpc_group bt_conn_cb_register(&bt_conn_cb_register_data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_cb_register_on_remote, @@ -950,7 +950,7 @@ static void bt_conn_cb_unregister_on_remote_rpc_handler(const struct nrf_rpc_gro result = bt_conn_cb_unregister(&bt_conn_cb_register_data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_conn_cb_unregister_on_remote, @@ -963,15 +963,15 @@ static void bt_set_bondable_rpc_handler(const struct nrf_rpc_group *group, { bool enable; - enable = ser_decode_bool(ctx); + enable = nrf_rpc_decode_bool(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_set_bondable(enable); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -987,15 +987,15 @@ static void bt_le_oob_set_legacy_flag_rpc_handler(const struct nrf_rpc_group *gr { bool enable; - enable = ser_decode_bool(ctx); + enable = nrf_rpc_decode_bool(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_le_oob_set_legacy_flag(enable); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1011,15 +1011,15 @@ static void bt_le_oob_set_sc_flag_rpc_handler(const struct nrf_rpc_group *group, { bool enable; - enable = ser_decode_bool(ctx); + enable = nrf_rpc_decode_bool(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_le_oob_set_sc_flag(enable); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1037,20 +1037,20 @@ static void bt_le_oob_set_legacy_tk_rpc_handler(const struct nrf_rpc_group *grou struct bt_conn *conn; const uint8_t *tk; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - tk = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + tk = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_oob_set_legacy_tk(conn, tk); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1075,14 +1075,14 @@ static size_t bt_le_oob_sc_data_buf_size(const struct bt_le_oob_sc_data *data) static void bt_le_oob_sc_data_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_oob_sc_data *data) { - ser_encode_buffer(encoder, data->r, 16 * sizeof(uint8_t)); - ser_encode_buffer(encoder, data->c, 16 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, data->r, 16 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, data->c, 16 * sizeof(uint8_t)); } static void bt_le_oob_sc_data_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_oob_sc_data *data) { - ser_decode_buffer(ctx, data->r, 16 * sizeof(uint8_t)); - ser_decode_buffer(ctx, data->c, 16 * sizeof(uint8_t)); + nrf_rpc_decode_buffer(ctx, data->r, 16 * sizeof(uint8_t)); + nrf_rpc_decode_buffer(ctx, data->c, 16 * sizeof(uint8_t)); } static void bt_le_oob_set_sc_data_rpc_handler(const struct nrf_rpc_group *group, @@ -1096,26 +1096,26 @@ static void bt_le_oob_set_sc_data_rpc_handler(const struct nrf_rpc_group *group, int result; conn = bt_rpc_decode_bt_conn(ctx); - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { oobd_local = NULL; } else { oobd_local = &oobd_local_data; bt_le_oob_sc_data_dec(ctx, oobd_local); } - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { oobd_remote = NULL; } else { oobd_remote = &oobd_remote_data; bt_le_oob_sc_data_dec(ctx, oobd_remote); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_oob_set_sc_data(conn, oobd_local, oobd_remote); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1137,7 +1137,7 @@ static void bt_le_oob_get_sc_data_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1151,16 +1151,16 @@ static void bt_le_oob_get_sc_data_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); + nrf_rpc_encode_int(&ectx, result); if (!oobd_local) { - ser_encode_null(&ectx); + nrf_rpc_encode_null(&ectx); } else { bt_le_oob_sc_data_enc(&ectx, oobd_local); } if (!oobd_remote) { - ser_encode_null(&ectx); + nrf_rpc_encode_null(&ectx); } else { bt_le_oob_sc_data_enc(&ectx, oobd_remote); } @@ -1184,15 +1184,15 @@ static void bt_passkey_set_rpc_handler(const struct nrf_rpc_group *group, unsigned int passkey; int result; - passkey = ser_decode_uint(ctx); + passkey = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_passkey_set(passkey); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1211,12 +1211,12 @@ static const size_t bt_conn_pairing_feat_buf_size = 12; void bt_conn_pairing_feat_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_conn_pairing_feat *data) { - ser_encode_uint(encoder, data->io_capability); - ser_encode_uint(encoder, data->oob_data_flag); - ser_encode_uint(encoder, data->auth_req); - ser_encode_uint(encoder, data->max_enc_key_size); - ser_encode_uint(encoder, data->init_key_dist); - ser_encode_uint(encoder, data->resp_key_dist); + nrf_rpc_encode_uint(encoder, data->io_capability); + nrf_rpc_encode_uint(encoder, data->oob_data_flag); + nrf_rpc_encode_uint(encoder, data->auth_req); + nrf_rpc_encode_uint(encoder, data->max_enc_key_size); + nrf_rpc_encode_uint(encoder, data->init_key_dist); + nrf_rpc_encode_uint(encoder, data->resp_key_dist); } struct bt_rpc_auth_cb_pairing_accept_rpc_res { @@ -1231,7 +1231,7 @@ static void bt_rpc_auth_cb_pairing_accept_rpc_rsp(const struct nrf_rpc_group *gr struct bt_rpc_auth_cb_pairing_accept_rpc_res *res = (struct bt_rpc_auth_cb_pairing_accept_rpc_res *)handler_data; - res->result = (enum bt_security_err)ser_decode_uint(ctx); + res->result = (enum bt_security_err)nrf_rpc_decode_uint(ctx); } static enum bt_security_err @@ -1263,10 +1263,10 @@ static void bt_rpc_auth_cb_passkey_display(struct bt_conn *conn, unsigned int pa NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, passkey); + nrf_rpc_encode_uint(&ctx, passkey); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_CB_PASSKEY_DISPLAY_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_cb_passkey_entry(struct bt_conn *conn) @@ -1279,7 +1279,7 @@ static void bt_rpc_auth_cb_passkey_entry(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_CB_PASSKEY_ENTRY_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_cb_passkey_confirm(struct bt_conn *conn, unsigned int passkey) @@ -1290,10 +1290,10 @@ static void bt_rpc_auth_cb_passkey_confirm(struct bt_conn *conn, unsigned int pa NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, passkey); + nrf_rpc_encode_uint(&ctx, passkey); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_CB_PASSKEY_CONFIRM_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_cb_oob_data_request(struct bt_conn *conn, struct bt_conn_oob_info *info) @@ -1306,10 +1306,10 @@ static void bt_rpc_auth_cb_oob_data_request(struct bt_conn *conn, struct bt_conn NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_buffer(&ctx, info, sizeof(struct bt_conn_oob_info)); + nrf_rpc_encode_buffer(&ctx, info, sizeof(struct bt_conn_oob_info)); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_CB_OOB_DATA_REQUEST_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_cb_cancel(struct bt_conn *conn) @@ -1322,7 +1322,7 @@ static void bt_rpc_auth_cb_cancel(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_CB_CANCEL_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_cb_pairing_confirm(struct bt_conn *conn) @@ -1335,7 +1335,7 @@ static void bt_rpc_auth_cb_pairing_confirm(struct bt_conn *conn) bt_rpc_encode_bt_conn(&ctx, conn); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_CB_PAIRING_CONFIRM_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static int bt_conn_auth_cb_register_on_remote(uint16_t flags) @@ -1370,15 +1370,15 @@ static void bt_conn_auth_cb_register_on_remote_rpc_handler(const struct nrf_rpc_ uint16_t flags; int result; - flags = ser_decode_uint(ctx); + flags = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_cb_register_on_remote(flags); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1399,10 +1399,10 @@ static void bt_rpc_auth_info_cb_pairing_complete(struct bt_conn *conn, bool bond NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_bool(&ctx, bonded); + nrf_rpc_encode_bool(&ctx, bonded); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_INFO_CB_PAIRING_COMPLETE_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_info_cb_pairing_failed(struct bt_conn *conn, enum bt_security_err reason) @@ -1413,10 +1413,10 @@ static void bt_rpc_auth_info_cb_pairing_failed(struct bt_conn *conn, enum bt_sec NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uint32_t)reason); + nrf_rpc_encode_uint(&ctx, (uint32_t)reason); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_INFO_CB_PAIRING_FAILED_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_rpc_auth_info_cb_bond_deleted(uint8_t id, const bt_addr_le_t *peer) @@ -1428,11 +1428,11 @@ static void bt_rpc_auth_info_cb_bond_deleted(uint8_t id, const bt_addr_le_t *pee NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, id); - ser_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ctx, id); + nrf_rpc_encode_buffer(&ctx, peer, sizeof(bt_addr_le_t)); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_AUTH_INFO_CB_BOND_DELETED_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static int bt_conn_auth_info_cb_register_on_remote(uint16_t flags) @@ -1458,15 +1458,15 @@ static void bt_conn_auth_info_cb_register_on_remote_rpc_handler(const struct nrf uint16_t flags; int result; - flags = ser_decode_uint(ctx); + flags = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_info_cb_register_on_remote(flags); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1483,13 +1483,13 @@ static void bt_conn_auth_info_cb_unregister_on_remote_rpc_handler(const struct n { int result; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_info_cb_unregister(&remote_auth_info_cb); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; @@ -1509,15 +1509,15 @@ static void bt_conn_auth_passkey_entry_rpc_handler(const struct nrf_rpc_group *g int result; conn = bt_rpc_decode_bt_conn(ctx); - passkey = ser_decode_uint(ctx); + passkey = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_passkey_entry(conn, passkey); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1535,13 +1535,13 @@ static void bt_conn_auth_cancel_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_cancel(conn); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1560,13 +1560,13 @@ static void bt_conn_auth_passkey_confirm_rpc_handler(const struct nrf_rpc_group conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_passkey_confirm(conn); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1586,13 +1586,13 @@ static void bt_conn_auth_pairing_confirm_rpc_handler(const struct nrf_rpc_group conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_conn_auth_pairing_confirm(conn); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: diff --git a/subsys/bluetooth/rpc/host/bt_rpc_crypto_host.c b/subsys/bluetooth/rpc/host/bt_rpc_crypto_host.c index 5bcece048b44..6d6eeb4ca562 100644 --- a/subsys/bluetooth/rpc/host/bt_rpc_crypto_host.c +++ b/subsys/bluetooth/rpc/host/bt_rpc_crypto_host.c @@ -10,7 +10,7 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" +#include #include static void report_decoding_error(uint8_t cmd_evt_id, void *data) @@ -27,21 +27,21 @@ static void bt_encrypt_le_rpc_handler(const struct nrf_rpc_group *group, const uint8_t *plaintext; uint8_t *enc_data; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - key = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - plaintext = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - enc_data = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + key = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + plaintext = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + enc_data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_encrypt_le(key, plaintext, enc_data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -60,21 +60,21 @@ static void bt_encrypt_be_rpc_handler(const struct nrf_rpc_group *group, const uint8_t *plaintext; uint8_t *enc_data; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - key = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - plaintext = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - enc_data = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + key = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + plaintext = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + enc_data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_encrypt_be(key, plaintext, enc_data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -93,14 +93,14 @@ static void bt_rand_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rp size_t len; uint8_t *buf; size_t buffer_size_max = 10; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - len = ser_decode_uint(ctx); - buf = ser_scratchpad_add(&scratchpad, sizeof(uint8_t) * len); + len = nrf_rpc_decode_uint(ctx); + buf = nrf_rpc_scratchpad_add(&scratchpad, sizeof(uint8_t) * len); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -113,8 +113,8 @@ static void bt_rand_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rp NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_buffer(&ectx, buf, sizeof(uint8_t) * len); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_buffer(&ectx, buf, sizeof(uint8_t) * len); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -143,20 +143,20 @@ static void bt_ccm_encrypt_rpc_handler(const struct nrf_rpc_group *group, uint8_t *plaintext; size_t mic_size; size_t buffer_size_max = 10; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - key = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - nonce = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - len = ser_decode_uint(ctx); - enc_data = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - aad_len = ser_decode_uint(ctx); - aad = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - plaintext = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - mic_size = ser_decode_uint(ctx); + key = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + nonce = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + len = nrf_rpc_decode_uint(ctx); + enc_data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + aad_len = nrf_rpc_decode_uint(ctx); + aad = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + plaintext = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + mic_size = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -169,8 +169,8 @@ static void bt_ccm_encrypt_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_buffer(&ectx, plaintext, sizeof(uint8_t) * (len + mic_size); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_buffer(&ectx, plaintext, sizeof(uint8_t) * (len + mic_size); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -198,20 +198,20 @@ static void bt_ccm_decrypt_rpc_handler(const struct nrf_rpc_group *group, uint8_t *plaintext; size_t mic_size; size_t buffer_size_max = 10; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - key = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - nonce = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - len = ser_decode_uint(ctx); - enc_data = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - aad_len = ser_decode_uint(ctx); - aad = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - plaintext = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - mic_size = ser_decode_uint(ctx); + key = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + nonce = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + len = nrf_rpc_decode_uint(ctx); + enc_data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + aad_len = nrf_rpc_decode_uint(ctx); + aad = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + plaintext = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + mic_size = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -224,8 +224,8 @@ static void bt_ccm_decrypt_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_buffer(&ectx, plaintext, sizeof(uint8_t) * len); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_buffer(&ectx, plaintext, sizeof(uint8_t) * len); nrf_rpc_cbor_rsp_no_err(group, &ectx); } diff --git a/subsys/bluetooth/rpc/host/bt_rpc_gap_host.c b/subsys/bluetooth/rpc/host/bt_rpc_gap_host.c index 46e05dfce4db..e48ebcd74f2f 100644 --- a/subsys/bluetooth/rpc/host/bt_rpc_gap_host.c +++ b/subsys/bluetooth/rpc/host/bt_rpc_gap_host.c @@ -11,8 +11,8 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include static void report_decoding_error(uint8_t cmd_evt_id, void *data) @@ -27,14 +27,14 @@ static void bt_rpc_get_check_list_rpc_handler(const struct nrf_rpc_group *group, size_t size; uint8_t *data; size_t buffer_size_max = 5; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - size = ser_decode_uint(ctx); - data = ser_scratchpad_add(&scratchpad, sizeof(uint8_t) * size); + size = nrf_rpc_decode_uint(ctx); + data = nrf_rpc_scratchpad_add(&scratchpad, sizeof(uint8_t) * size); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -47,7 +47,7 @@ static void bt_rpc_get_check_list_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_buffer(&ectx, data, sizeof(uint8_t) * size); + nrf_rpc_encode_buffer(&ectx, data, sizeof(uint8_t) * size); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -55,29 +55,25 @@ static void bt_rpc_get_check_list_rpc_handler(const struct nrf_rpc_group *group, return; decoding_error: report_decoding_error(BT_RPC_GET_CHECK_LIST_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_get_check_list, BT_RPC_GET_CHECK_LIST_RPC_CMD, bt_rpc_get_check_list_rpc_handler, NULL); - -static inline void bt_ready_cb_t_callback(int err, - uint32_t callback_slot) +static inline void bt_ready_cb_t_callback(int err, uint32_t callback_slot) { struct nrf_rpc_cbor_ctx ctx; size_t buffer_size_max = 8; NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_int(&ctx, err); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_int(&ctx, err); + nrf_rpc_encode_callback_call(&ctx, callback_slot); - nrf_rpc_cbor_evt_no_err(&bt_rpc_grp, - BT_READY_CB_T_CALLBACK_RPC_EVT, &ctx); + nrf_rpc_cbor_evt_no_err(&bt_rpc_grp, BT_READY_CB_T_CALLBACK_RPC_EVT, &ctx); } -CBKPROXY_HANDLER(bt_ready_cb_t_encoder, bt_ready_cb_t_callback, (int err), (err)); +NRF_RPC_CBKPROXY_HANDLER(bt_ready_cb_t_encoder, bt_ready_cb_t_callback, (int err), (err)); static void bt_enable_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -85,36 +81,35 @@ static void bt_enable_rpc_handler(const struct nrf_rpc_group *group, struct nrf_ bt_ready_cb_t cb; int result; - cb = (bt_ready_cb_t)ser_decode_callback(ctx, bt_ready_cb_t_encoder); + cb = (bt_ready_cb_t)nrf_rpc_decode_callbackd(ctx, bt_ready_cb_t_encoder); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_enable(cb); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_ENABLE_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_enable, BT_ENABLE_RPC_CMD, - bt_enable_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_enable, BT_ENABLE_RPC_CMD, bt_enable_rpc_handler, NULL); static void bt_disable_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { int result; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_disable(); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; @@ -122,21 +117,20 @@ static void bt_disable_rpc_handler(const struct nrf_rpc_group *group, struct nrf report_decoding_error(BT_DISABLE_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_disable, BT_DISABLE_RPC_CMD, - bt_disable_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_disable, BT_DISABLE_RPC_CMD, bt_disable_rpc_handler, NULL); static void bt_is_ready_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { bool result; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_is_ready(); - ser_rsp_send_bool(group, result); + nrf_rpc_rsp_send_bool(group, result); return; @@ -144,8 +138,8 @@ static void bt_is_ready_rpc_handler(const struct nrf_rpc_group *group, struct nr report_decoding_error(BT_IS_READY_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_is_ready, BT_IS_READY_RPC_CMD, - bt_is_ready_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_is_ready, BT_IS_READY_RPC_CMD, bt_is_ready_rpc_handler, + NULL); #if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC) @@ -154,27 +148,27 @@ static void bt_set_name_rpc_handler(const struct nrf_rpc_group *group, struct nr { const char *name; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - name = ser_decode_str_into_scratchpad(&scratchpad, NULL); + name = nrf_rpc_decode_str_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_set_name(name); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_SET_NAME_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_set_name, BT_SET_NAME_RPC_CMD, - bt_set_name_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_set_name, BT_SET_NAME_RPC_CMD, bt_set_name_rpc_handler, + NULL); static bool bt_get_name_out(char *name, size_t size) { @@ -199,17 +193,17 @@ static void bt_get_name_out_rpc_handler(const struct nrf_rpc_group *group, size_t name_strlen; char *name; size_t buffer_size_max = 6; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - size = ser_decode_uint(ctx); + size = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } - name = ser_scratchpad_add(&scratchpad, size); + name = nrf_rpc_scratchpad_add(&scratchpad, size); result = bt_get_name_out(name, size); @@ -221,8 +215,8 @@ static void bt_get_name_out_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_bool(&ectx, result); - ser_encode_str(&ectx, name, name_strlen); + nrf_rpc_encode_bool(&ectx, result); + nrf_rpc_encode_str(&ectx, name, name_strlen); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -242,13 +236,13 @@ static void bt_get_appearance_rpc_handler(const struct nrf_rpc_group *group, { uint16_t appearance; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } appearance = bt_get_appearance(); - ser_rsp_send_uint(group, appearance); + nrf_rpc_rsp_send_uint(group, appearance); return; @@ -265,15 +259,15 @@ static void bt_set_appearance_rpc_handler(const struct nrf_rpc_group *group, int result; uint16_t appearance; - appearance = ser_decode_uint(ctx); + appearance = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_set_appearance(appearance); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -291,17 +285,17 @@ static void bt_id_get_rpc_handler(const struct nrf_rpc_group *group, struct nrf_ size_t *count = &count_data; bt_addr_le_t *addrs; size_t buffer_size_max = 10; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - *count = ser_decode_uint(ctx); + *count = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } - addrs = ser_scratchpad_add(&scratchpad, *count * sizeof(bt_addr_le_t)); + addrs = nrf_rpc_scratchpad_add(&scratchpad, *count * sizeof(bt_addr_le_t)); bt_id_get(addrs, count); @@ -312,8 +306,8 @@ static void bt_id_get_rpc_handler(const struct nrf_rpc_group *group, struct nrf_ NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_uint(&ectx, *count); - ser_encode_buffer(&ectx, addrs, *count * sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(&ectx, *count); + nrf_rpc_encode_buffer(&ectx, addrs, *count * sizeof(bt_addr_le_t)); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -323,8 +317,7 @@ static void bt_id_get_rpc_handler(const struct nrf_rpc_group *group, struct nrf_ report_decoding_error(BT_ID_GET_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_get, BT_ID_GET_RPC_CMD, - bt_id_get_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_get, BT_ID_GET_RPC_CMD, bt_id_get_rpc_handler, NULL); static void bt_id_create_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -334,14 +327,14 @@ static void bt_id_create_rpc_handler(const struct nrf_rpc_group *group, bt_addr_le_t *addr; uint8_t *irk; size_t buffer_size_max = 13; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - irk = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + irk = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -355,9 +348,9 @@ static void bt_id_create_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_buffer(&ectx, addr, sizeof(bt_addr_le_t)); - ser_encode_buffer(&ectx, irk, sizeof(uint8_t) * 16); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_buffer(&ectx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ectx, irk, sizeof(uint8_t) * 16); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -367,8 +360,8 @@ static void bt_id_create_rpc_handler(const struct nrf_rpc_group *group, report_decoding_error(BT_ID_CREATE_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_create, BT_ID_CREATE_RPC_CMD, - bt_id_create_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_create, BT_ID_CREATE_RPC_CMD, bt_id_create_rpc_handler, + NULL); static void bt_id_reset_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -379,15 +372,15 @@ static void bt_id_reset_rpc_handler(const struct nrf_rpc_group *group, struct nr bt_addr_le_t *addr; uint8_t *irk; size_t buffer_size_max = 13; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - id = ser_decode_uint(ctx); - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - irk = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + id = nrf_rpc_decode_uint(ctx); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + irk = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -401,9 +394,9 @@ static void bt_id_reset_rpc_handler(const struct nrf_rpc_group *group, struct nr NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_buffer(&ectx, addr, sizeof(bt_addr_le_t)); - ser_encode_buffer(&ectx, irk, sizeof(uint8_t) * 16); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_buffer(&ectx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(&ectx, irk, sizeof(uint8_t) * 16); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -413,8 +406,8 @@ static void bt_id_reset_rpc_handler(const struct nrf_rpc_group *group, struct nr report_decoding_error(BT_ID_RESET_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_reset, BT_ID_RESET_RPC_CMD, - bt_id_reset_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_reset, BT_ID_RESET_RPC_CMD, bt_id_reset_rpc_handler, + NULL); static void bt_id_delete_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -422,49 +415,49 @@ static void bt_id_delete_rpc_handler(const struct nrf_rpc_group *group, uint8_t id; int result; - id = ser_decode_uint(ctx); + id = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_id_delete(id); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_ID_DELETE_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_delete, BT_ID_DELETE_RPC_CMD, - bt_id_delete_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_id_delete, BT_ID_DELETE_RPC_CMD, bt_id_delete_rpc_handler, + NULL); -static void bt_data_dec(struct ser_scratchpad *scratchpad, struct bt_data *data) +static void bt_data_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_data *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; - data->type = ser_decode_uint(ctx); - data->data_len = ser_decode_uint(ctx); - data->data = ser_decode_buffer_into_scratchpad(scratchpad, NULL); + data->type = nrf_rpc_decode_uint(ctx); + data->data_len = nrf_rpc_decode_uint(ctx); + data->data = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); } #if defined(CONFIG_BT_OBSERVER) static void bt_le_scan_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_scan_param *data) { - data->type = ser_decode_uint(ctx); - data->options = ser_decode_uint(ctx); - data->interval = ser_decode_uint(ctx); - data->window = ser_decode_uint(ctx); - data->timeout = ser_decode_uint(ctx); - data->interval_coded = ser_decode_uint(ctx); - data->window_coded = ser_decode_uint(ctx); + data->type = nrf_rpc_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); + data->interval = nrf_rpc_decode_uint(ctx); + data->window = nrf_rpc_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); + data->interval_coded = nrf_rpc_decode_uint(ctx); + data->window_coded = nrf_rpc_decode_uint(ctx); } #endif /* defined(CONFIG_BT_OBSERVER) */ static size_t net_buf_simple_sp_size(struct net_buf_simple *data) { - return SCRATCHPAD_ALIGN(data->len); + return NRF_RPC_SCRATCHPAD_ALIGN(data->len); } static size_t net_buf_simple_buf_size(struct net_buf_simple *data) @@ -474,7 +467,7 @@ static size_t net_buf_simple_buf_size(struct net_buf_simple *data) static void net_buf_simple_enc(struct nrf_rpc_cbor_ctx *encoder, struct net_buf_simple *data) { - ser_encode_buffer(encoder, data->data, data->len); + nrf_rpc_encode_buffer(encoder, data->data, data->len); } static void bt_le_scan_cb_t_callback(const bt_addr_le_t *addr, int8_t rssi, uint8_t adv_type, @@ -490,35 +483,36 @@ static void bt_le_scan_cb_t_callback(const bt_addr_le_t *addr, int8_t rssi, uint scratchpad_size += net_buf_simple_sp_size(buf); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); - ser_encode_int(&ctx, rssi); - ser_encode_uint(&ctx, adv_type); + nrf_rpc_encode_buffer(&ctx, addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_int(&ctx, rssi); + nrf_rpc_encode_uint(&ctx, adv_type); net_buf_simple_enc(&ctx, buf); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_callback_call(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_CB_T_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_le_scan_cb_t_encoder, bt_le_scan_cb_t_callback, - (const bt_addr_le_t *addr, int8_t rssi, uint8_t adv_type, - struct net_buf_simple *buf), (addr, rssi, adv_type, buf)); +NRF_RPC_CBKPROXY_HANDLER(bt_le_scan_cb_t_encoder, bt_le_scan_cb_t_callback, + (const bt_addr_le_t *addr, int8_t rssi, uint8_t adv_type, + struct net_buf_simple *buf), + (addr, rssi, adv_type, buf)); #if defined(CONFIG_BT_BROADCASTER) -static void bt_le_adv_param_dec(struct ser_scratchpad *scratchpad, struct bt_le_adv_param *data) +static void bt_le_adv_param_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_le_adv_param *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; - data->id = ser_decode_uint(ctx); - data->sid = ser_decode_uint(ctx); - data->secondary_max_skip = ser_decode_uint(ctx); - data->options = ser_decode_uint(ctx); - data->interval_min = ser_decode_uint(ctx); - data->interval_max = ser_decode_uint(ctx); - data->peer = ser_decode_buffer_into_scratchpad(scratchpad, NULL); + data->id = nrf_rpc_decode_uint(ctx); + data->sid = nrf_rpc_decode_uint(ctx); + data->secondary_max_skip = nrf_rpc_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); + data->interval_min = nrf_rpc_decode_uint(ctx); + data->interval_max = nrf_rpc_decode_uint(ctx); + data->peer = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); } static void bt_le_adv_start_rpc_handler(const struct nrf_rpc_group *group, @@ -530,13 +524,13 @@ static void bt_le_adv_start_rpc_handler(const struct nrf_rpc_group *group, size_t sd_len; struct bt_data *sd; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); bt_le_adv_param_dec(&scratchpad, ¶m); - ad_len = ser_decode_uint(ctx); - ad = ser_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); + ad_len = nrf_rpc_decode_uint(ctx); + ad = nrf_rpc_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); if (ad == NULL) { goto decoding_error; } @@ -545,8 +539,8 @@ static void bt_le_adv_start_rpc_handler(const struct nrf_rpc_group *group, bt_data_dec(&scratchpad, &ad[i]); } - sd_len = ser_decode_uint(ctx); - sd = ser_scratchpad_add(&scratchpad, sd_len * sizeof(struct bt_data)); + sd_len = nrf_rpc_decode_uint(ctx); + sd = nrf_rpc_scratchpad_add(&scratchpad, sd_len * sizeof(struct bt_data)); if (sd == NULL) { goto decoding_error; } @@ -555,13 +549,13 @@ static void bt_le_adv_start_rpc_handler(const struct nrf_rpc_group *group, bt_data_dec(&scratchpad, &sd[i]); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_adv_start(¶m, ad, ad_len, sd, sd_len); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -579,12 +573,12 @@ static void bt_le_adv_update_data_rpc_handler(const struct nrf_rpc_group *group, size_t sd_len; struct bt_data *sd; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - ad_len = ser_decode_uint(ctx); - ad = ser_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); + ad_len = nrf_rpc_decode_uint(ctx); + ad = nrf_rpc_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); if (ad == NULL) { goto decoding_error; } @@ -592,8 +586,8 @@ static void bt_le_adv_update_data_rpc_handler(const struct nrf_rpc_group *group, for (size_t i = 0; i < ad_len; i++) { bt_data_dec(&scratchpad, &ad[i]); } - sd_len = ser_decode_uint(ctx); - sd = ser_scratchpad_add(&scratchpad, sd_len * sizeof(struct bt_data)); + sd_len = nrf_rpc_decode_uint(ctx); + sd = nrf_rpc_scratchpad_add(&scratchpad, sd_len * sizeof(struct bt_data)); if (sd == NULL) { goto decoding_error; } @@ -602,13 +596,13 @@ static void bt_le_adv_update_data_rpc_handler(const struct nrf_rpc_group *group, bt_data_dec(&scratchpad, &sd[i]); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_adv_update_data(ad, ad_len, sd, sd_len); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -627,7 +621,7 @@ static void bt_le_adv_stop_rpc_handler(const struct nrf_rpc_group *group, result = bt_le_adv_stop(); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_adv_stop, BT_LE_ADV_STOP_RPC_CMD, @@ -647,23 +641,21 @@ static size_t bt_le_oob_buf_size(const struct bt_le_oob *data) static void bt_le_oob_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_oob *data) { - ser_encode_buffer(encoder, &data->addr, sizeof(bt_addr_le_t)); - ser_encode_buffer(encoder, data->le_sc_data.r, 16 * sizeof(uint8_t)); - ser_encode_buffer(encoder, data->le_sc_data.c, 16 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, &data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(encoder, data->le_sc_data.r, 16 * sizeof(uint8_t)); + nrf_rpc_encode_buffer(encoder, data->le_sc_data.c, 16 * sizeof(uint8_t)); } #if defined(CONFIG_BT_EXT_ADV) -K_MEM_SLAB_DEFINE(bt_rpc_ext_adv_cb_cache, - sizeof(struct bt_le_ext_adv_cb), - CONFIG_BT_EXT_ADV_MAX_ADV_SET, - sizeof(void *)); +K_MEM_SLAB_DEFINE(bt_rpc_ext_adv_cb_cache, sizeof(struct bt_le_ext_adv_cb), + CONFIG_BT_EXT_ADV_MAX_ADV_SET, sizeof(void *)); static struct bt_le_ext_adv_cb *ext_adv_cb_cache_map[CONFIG_BT_EXT_ADV_MAX_ADV_SET]; static void bt_le_ext_adv_sent_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_ext_adv_sent_info *data) { - ser_encode_uint(encoder, data->num_sent); + nrf_rpc_encode_uint(encoder, data->num_sent); } static void bt_le_ext_adv_connected_info_enc(struct nrf_rpc_cbor_ctx *encoder, @@ -676,7 +668,7 @@ static size_t bt_le_ext_adv_scanned_info_sp_size(const struct bt_le_ext_adv_scan { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); return scratchpad_size; } @@ -693,7 +685,7 @@ static size_t bt_le_ext_adv_scanned_info_buf_size(const struct bt_le_ext_adv_sca static void bt_le_ext_adv_scanned_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_ext_adv_scanned_info *data) { - ser_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); } static void bt_le_ext_adv_cb_sent_callback(struct bt_le_ext_adv *adv, @@ -705,17 +697,17 @@ static void bt_le_ext_adv_cb_sent_callback(struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_ext_adv_sent_info_enc(&ctx, info); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_callback_call(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_CB_SENT_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_le_ext_adv_cb_sent_encoder, bt_le_ext_adv_cb_sent_callback, - (struct bt_le_ext_adv *adv, struct bt_le_ext_adv_sent_info *info), - (adv, info)); +NRF_RPC_CBKPROXY_HANDLER(bt_le_ext_adv_cb_sent_encoder, bt_le_ext_adv_cb_sent_callback, + (struct bt_le_ext_adv *adv, struct bt_le_ext_adv_sent_info *info), + (adv, info)); static void bt_le_ext_adv_cb_connected_callback(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_connected_info *info, @@ -726,18 +718,17 @@ static void bt_le_ext_adv_cb_connected_callback(struct bt_le_ext_adv *adv, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_ext_adv_connected_info_enc(&ctx, info); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_callback_call(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_CB_CONNECTED_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_le_ext_adv_cb_connected_encoder, - bt_le_ext_adv_cb_connected_callback, - (struct bt_le_ext_adv *adv, struct bt_le_ext_adv_connected_info *info), - (adv, info)); +NRF_RPC_CBKPROXY_HANDLER(bt_le_ext_adv_cb_connected_encoder, bt_le_ext_adv_cb_connected_callback, + (struct bt_le_ext_adv *adv, struct bt_le_ext_adv_connected_info *info), + (adv, info)); static void bt_le_ext_adv_cb_scanned_callback(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_scanned_info *info, @@ -752,27 +743,27 @@ static void bt_le_ext_adv_cb_scanned_callback(struct bt_le_ext_adv *adv, scratchpad_size += bt_le_ext_adv_scanned_info_sp_size(info); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)adv); + nrf_rpc_encode_uint(&ctx, (uintptr_t)adv); bt_le_ext_adv_scanned_info_enc(&ctx, info); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_callback_call(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_EXT_ADV_CB_SCANNED_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_le_ext_adv_cb_scanned_encoder, - bt_le_ext_adv_cb_scanned_callback, - (struct bt_le_ext_adv *adv, struct bt_le_ext_adv_scanned_info *info), - (adv, info)); +NRF_RPC_CBKPROXY_HANDLER(bt_le_ext_adv_cb_scanned_encoder, bt_le_ext_adv_cb_scanned_callback, + (struct bt_le_ext_adv *adv, struct bt_le_ext_adv_scanned_info *info), + (adv, info)); static void bt_le_ext_adv_cb_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_ext_adv_cb *data) { - data->sent = (bt_le_ext_adv_cb_sent)ser_decode_callback(ctx, bt_le_ext_adv_cb_sent_encoder); - data->connected = (bt_le_ext_adv_cb_connected)ser_decode_callback( + data->sent = + (bt_le_ext_adv_cb_sent)nrf_rpc_decode_callbackd(ctx, bt_le_ext_adv_cb_sent_encoder); + data->connected = (bt_le_ext_adv_cb_connected)nrf_rpc_decode_callbackd( ctx, bt_le_ext_adv_cb_connected_encoder); - data->scanned = (bt_le_ext_adv_cb_scanned)ser_decode_callback( + data->scanned = (bt_le_ext_adv_cb_scanned)nrf_rpc_decode_callbackd( ctx, bt_le_ext_adv_cb_scanned_encoder); } @@ -784,22 +775,22 @@ static void bt_le_ext_adv_create_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_ext_adv *adv_data; struct bt_le_ext_adv **adv = &adv_data; size_t buffer_size_max = 10; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; size_t adv_index; struct bt_le_ext_adv_cb *cb = NULL; result = 0; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); bt_le_adv_param_dec(&scratchpad, ¶m); - if (!ser_decode_is_undefined(ctx)) { + if (!nrf_rpc_decode_is_undefined(ctx)) { result = k_mem_slab_alloc(&bt_rpc_ext_adv_cb_cache, (void **)&cb, K_NO_WAIT); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -819,8 +810,8 @@ static void bt_le_ext_adv_create_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_uint(&ectx, (uintptr_t)(*adv)); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_uint(&ectx, (uintptr_t)(*adv)); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -840,8 +831,8 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_ext_adv_create, BT_LE_EXT_ADV_CREATE_ static void bt_le_ext_adv_start_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_ext_adv_start_param *data) { - data->timeout = ser_decode_uint(ctx); - data->num_events = ser_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); + data->num_events = nrf_rpc_decode_uint(ctx); } static void bt_le_ext_adv_start_rpc_handler(const struct nrf_rpc_group *group, @@ -851,16 +842,16 @@ static void bt_le_ext_adv_start_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_ext_adv_start_param param; int result; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_ext_adv_start_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_ext_adv_start(adv, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -876,15 +867,15 @@ static void bt_le_ext_adv_stop_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_ext_adv *adv; int result; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_ext_adv_stop(adv); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -903,13 +894,13 @@ static void bt_le_ext_adv_set_data_rpc_handler(const struct nrf_rpc_group *group size_t sd_len; struct bt_data *sd; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); - ad_len = ser_decode_uint(ctx); - ad = ser_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); + ad_len = nrf_rpc_decode_uint(ctx); + ad = nrf_rpc_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); if (ad == NULL) { goto decoding_error; } @@ -918,8 +909,8 @@ static void bt_le_ext_adv_set_data_rpc_handler(const struct nrf_rpc_group *group bt_data_dec(&scratchpad, &ad[i]); } - sd_len = ser_decode_uint(ctx); - sd = ser_scratchpad_add(&scratchpad, sd_len * sizeof(struct bt_data)); + sd_len = nrf_rpc_decode_uint(ctx); + sd = nrf_rpc_scratchpad_add(&scratchpad, sd_len * sizeof(struct bt_data)); if (sd == NULL) { goto decoding_error; } @@ -928,13 +919,13 @@ static void bt_le_ext_adv_set_data_rpc_handler(const struct nrf_rpc_group *group bt_data_dec(&scratchpad, &sd[i]); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_ext_adv_set_data(adv, ad, ad_len, sd, sd_len); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -950,20 +941,20 @@ static void bt_le_ext_adv_update_param_rpc_handler(const struct nrf_rpc_group *g struct bt_le_ext_adv *adv; struct bt_le_adv_param param; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_adv_param_dec(&scratchpad, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_ext_adv_update_param(adv, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -982,9 +973,9 @@ static void bt_le_ext_adv_delete_rpc_handler(const struct nrf_rpc_group *group, size_t adv_index; struct bt_le_ext_adv_cb *cb; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -997,7 +988,7 @@ static void bt_le_ext_adv_delete_rpc_handler(const struct nrf_rpc_group *group, k_mem_slab_free(&bt_rpc_ext_adv_cb_cache, (void *)cb); } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1013,15 +1004,15 @@ static void bt_le_ext_adv_get_index_rpc_handler(const struct nrf_rpc_group *grou struct bt_le_ext_adv *adv; uint8_t result; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_ext_adv_get_index(adv); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_error: @@ -1033,8 +1024,8 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_ext_adv_get_index, BT_LE_EXT_ADV_GET_ static void bt_le_ext_adv_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_ext_adv_info *data) { - data->id = ser_decode_uint(ctx); - data->tx_power = ser_decode_int(ctx); + data->id = nrf_rpc_decode_uint(ctx); + data->tx_power = nrf_rpc_decode_int(ctx); } static void bt_le_ext_adv_get_info_rpc_handler(const struct nrf_rpc_group *group, @@ -1044,16 +1035,16 @@ static void bt_le_ext_adv_get_info_rpc_handler(const struct nrf_rpc_group *group struct bt_le_ext_adv_info info; int result; - adv = (const struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (const struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_ext_adv_info_dec(ctx, &info); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_ext_adv_get_info(adv, &info); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1073,9 +1064,9 @@ static void bt_le_ext_adv_oob_get_local_rpc_handler(const struct nrf_rpc_group * struct bt_le_oob *oob = &oob_data; size_t buffer_size_max = 5; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1088,7 +1079,7 @@ static void bt_le_ext_adv_oob_get_local_rpc_handler(const struct nrf_rpc_group * NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); + nrf_rpc_encode_int(&ectx, result); bt_le_oob_enc(&ectx, oob); nrf_rpc_cbor_rsp_no_err(group, &ectx); @@ -1113,15 +1104,15 @@ static void bt_le_scan_start_rpc_handler(const struct nrf_rpc_group *group, int result; bt_le_scan_param_dec(ctx, ¶m); - cb = (bt_le_scan_cb_t *)ser_decode_callback(ctx, bt_le_scan_cb_t_encoder); + cb = (bt_le_scan_cb_t *)nrf_rpc_decode_callbackd(ctx, bt_le_scan_cb_t_encoder); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_scan_start(¶m, cb); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1140,7 +1131,7 @@ static void bt_le_scan_stop_rpc_handler(const struct nrf_rpc_group *group, result = bt_le_scan_stop(); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_scan_stop, BT_LE_SCAN_STOP_RPC_CMD, @@ -1150,7 +1141,7 @@ static size_t bt_le_scan_recv_info_sp_size(const struct bt_le_scan_recv_info *da { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); return scratchpad_size; } @@ -1167,15 +1158,15 @@ static size_t bt_le_scan_recv_info_buf_size(const struct bt_le_scan_recv_info *d static void bt_le_scan_recv_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_scan_recv_info *data) { - ser_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); - ser_encode_uint(encoder, data->sid); - ser_encode_int(encoder, data->rssi); - ser_encode_int(encoder, data->tx_power); - ser_encode_uint(encoder, data->adv_type); - ser_encode_uint(encoder, data->adv_props); - ser_encode_uint(encoder, data->interval); - ser_encode_uint(encoder, data->primary_phy); - ser_encode_uint(encoder, data->secondary_phy); + nrf_rpc_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, data->sid); + nrf_rpc_encode_int(encoder, data->rssi); + nrf_rpc_encode_int(encoder, data->tx_power); + nrf_rpc_encode_uint(encoder, data->adv_type); + nrf_rpc_encode_uint(encoder, data->adv_props); + nrf_rpc_encode_uint(encoder, data->interval); + nrf_rpc_encode_uint(encoder, data->primary_phy); + nrf_rpc_encode_uint(encoder, data->secondary_phy); } static void bt_le_scan_cb_recv(const struct bt_le_scan_recv_info *info, struct net_buf_simple *buf) @@ -1191,13 +1182,13 @@ static void bt_le_scan_cb_recv(const struct bt_le_scan_recv_info *info, struct n scratchpad_size += net_buf_simple_sp_size(buf); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_le_scan_recv_info_enc(&ctx, info); net_buf_simple_enc(&ctx, buf); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_CB_RECV_RPC_CMD, &ctx, ser_rsp_decode_void, - NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_CB_RECV_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_void, NULL); } static void bt_le_scan_cb_timeout(void) @@ -1208,7 +1199,7 @@ static void bt_le_scan_cb_timeout(void) NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_LE_SCAN_CB_TIMEOUT_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static struct bt_le_scan_cb scan_cb = { @@ -1224,7 +1215,7 @@ static void bt_le_scan_cb_register_on_remote_rpc_handler(const struct nrf_rpc_gr bt_le_scan_cb_register(&scan_cb); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_scan_cb_register_on_remote, @@ -1241,15 +1232,15 @@ static void bt_le_filter_accept_list_add_rpc_handler(const struct nrf_rpc_group const bt_addr_le_t *addr; int result; - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_filter_accept_list_add(addr); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1268,15 +1259,15 @@ static void bt_le_filter_accept_list_remove_rpc_handler(const struct nrf_rpc_gro const bt_addr_le_t *addr; int result; - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_filter_accept_list_remove(addr); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1297,7 +1288,7 @@ static void bt_le_filter_accept_list_clear_rpc_handler(const struct nrf_rpc_grou result = bt_le_filter_accept_list_clear(); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_filter_accept_list_clear, @@ -1310,19 +1301,19 @@ static void bt_le_set_chan_map_rpc_handler(const struct nrf_rpc_group *group, { uint8_t *chan_map; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - chan_map = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + chan_map = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_set_chan_map(chan_map); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1341,9 +1332,9 @@ static void bt_le_oob_get_local_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_oob *oob = &oob_data; size_t buffer_size_max = 5; - id = ser_decode_uint(ctx); + id = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1356,7 +1347,7 @@ static void bt_le_oob_get_local_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); + nrf_rpc_encode_int(&ectx, result); bt_le_oob_enc(&ectx, oob); nrf_rpc_cbor_rsp_no_err(group, &ectx); @@ -1379,24 +1370,23 @@ static void bt_unpair_rpc_handler(const struct nrf_rpc_group *group, struct nrf_ const bt_addr_le_t *addr; int result; - id = ser_decode_uint(ctx); - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + id = nrf_rpc_decode_uint(ctx); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_unpair(id, addr); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_UNPAIR_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_unpair, BT_UNPAIR_RPC_CMD, - bt_unpair_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_unpair, BT_UNPAIR_RPC_CMD, bt_unpair_rpc_handler, NULL); #endif /* defined(CONFIG_BT_CONN) */ #if (defined(CONFIG_BT_CONN) && defined(CONFIG_BT_SMP)) @@ -1411,7 +1401,7 @@ static size_t bt_bond_info_buf_size(const struct bt_bond_info *data) void bt_bond_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_bond_info *data) { - ser_encode_buffer(encoder, &data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_buffer(encoder, &data->addr, sizeof(bt_addr_le_t)); } static void bt_foreach_bond_cb_callback(const struct bt_bond_info *info, void *user_data, @@ -1425,15 +1415,15 @@ static void bt_foreach_bond_cb_callback(const struct bt_bond_info *info, void *u NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_bond_info_enc(&ctx, info); - ser_encode_uint(&ctx, (uintptr_t)user_data); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_uint(&ctx, (uintptr_t)user_data); + nrf_rpc_encode_callback_call(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_FOREACH_BOND_CB_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_foreach_bond_cb_encoder, bt_foreach_bond_cb_callback, - (const struct bt_bond_info *info, void *user_data), (info, user_data)); +NRF_RPC_CBKPROXY_HANDLER(bt_foreach_bond_cb_encoder, bt_foreach_bond_cb_callback, + (const struct bt_bond_info *info, void *user_data), (info, user_data)); static void bt_foreach_bond_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -1442,17 +1432,17 @@ static void bt_foreach_bond_rpc_handler(const struct nrf_rpc_group *group, bt_foreach_bond_cb func; void *user_data; - id = ser_decode_uint(ctx); - func = (bt_foreach_bond_cb)ser_decode_callback(ctx, bt_foreach_bond_cb_encoder); - user_data = (void *)ser_decode_uint(ctx); + id = nrf_rpc_decode_uint(ctx); + func = (bt_foreach_bond_cb)nrf_rpc_decode_callbackd(ctx, bt_foreach_bond_cb_encoder); + user_data = (void *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } bt_foreach_bond(id, func, user_data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); return; decoding_error: @@ -1473,7 +1463,7 @@ static void bt_le_per_adv_list_clear_rpc_handler(const struct nrf_rpc_group *gro result = bt_le_per_adv_list_clear(); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_per_adv_list_clear, BT_LE_PER_ADV_LIST_CLEAR_RPC_CMD, @@ -1487,16 +1477,16 @@ static void bt_le_per_adv_list_add_rpc_handler(const struct nrf_rpc_group *group uint8_t sid; int result; - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - sid = ser_decode_uint(ctx); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + sid = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_list_add(addr, sid); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1514,16 +1504,16 @@ static void bt_le_per_adv_list_remove_rpc_handler(const struct nrf_rpc_group *gr uint8_t sid; int result; - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - sid = ser_decode_uint(ctx); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + sid = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_list_remove(addr, sid); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1535,9 +1525,9 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_per_adv_list_remove, BT_LE_PER_ADV_LI static void bt_le_per_adv_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_per_adv_param *data) { - data->interval_min = ser_decode_uint(ctx); - data->interval_max = ser_decode_uint(ctx); - data->options = ser_decode_uint(ctx); + data->interval_min = nrf_rpc_decode_uint(ctx); + data->interval_max = nrf_rpc_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); } static void bt_le_per_adv_set_param_rpc_handler(const struct nrf_rpc_group *group, @@ -1547,16 +1537,16 @@ static void bt_le_per_adv_set_param_rpc_handler(const struct nrf_rpc_group *grou struct bt_le_per_adv_param param; int result; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); bt_le_per_adv_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_set_param(adv, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1573,13 +1563,13 @@ static void bt_le_per_adv_set_data_rpc_handler(const struct nrf_rpc_group *group size_t ad_len; struct bt_data *ad; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - adv = (const struct bt_le_ext_adv *)ser_decode_uint(ctx); - ad_len = ser_decode_uint(ctx); - ad = ser_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); + adv = (const struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); + ad_len = nrf_rpc_decode_uint(ctx); + ad = nrf_rpc_scratchpad_add(&scratchpad, ad_len * sizeof(struct bt_data)); if (ad == NULL) { goto decoding_error; } @@ -1588,13 +1578,13 @@ static void bt_le_per_adv_set_data_rpc_handler(const struct nrf_rpc_group *group bt_data_dec(&scratchpad, &ad[i]); } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_set_data(adv, ad, ad_len); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1610,15 +1600,15 @@ static void bt_le_per_adv_start_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_ext_adv *adv; int result; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_start(adv); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1634,15 +1624,15 @@ static void bt_le_per_adv_stop_rpc_handler(const struct nrf_rpc_group *group, struct bt_le_ext_adv *adv; int result; - adv = (struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_stop(adv); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1662,17 +1652,17 @@ static void bt_le_per_adv_set_info_transfer_rpc_handler(const struct nrf_rpc_gro uint16_t service_data; int result; - adv = (const struct bt_le_ext_adv *)ser_decode_uint(ctx); + adv = (const struct bt_le_ext_adv *)nrf_rpc_decode_uint(ctx); conn = bt_rpc_decode_bt_conn(ctx); - service_data = ser_decode_uint(ctx); + service_data = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_set_info_transfer(adv, conn, service_data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1682,8 +1672,8 @@ static void bt_le_per_adv_set_info_transfer_rpc_handler(const struct nrf_rpc_gro NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_per_adv_set_info_transfer, BT_LE_PER_ADV_SET_INFO_TRANSFER_RPC_CMD, bt_le_per_adv_set_info_transfer_rpc_handler, NULL); -#endif /* defined(CONFIG_BT_CONN) */ -#endif /* defined(CONFIG_BT_PER_ADV) */ +#endif /* defined(CONFIG_BT_CONN) */ +#endif /* defined(CONFIG_BT_PER_ADV) */ #if defined(CONFIG_BT_PER_ADV_SYNC) static void bt_le_per_adv_sync_get_index_rpc_handler(const struct nrf_rpc_group *group, @@ -1693,15 +1683,15 @@ static void bt_le_per_adv_sync_get_index_rpc_handler(const struct nrf_rpc_group struct bt_le_per_adv_sync *per_adv_sync; uint8_t result; - per_adv_sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + per_adv_sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_get_index(per_adv_sync); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_error: @@ -1715,11 +1705,11 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_per_adv_sync_get_index, static void bt_le_per_adv_sync_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_per_adv_sync_param *data) { - ser_decode_buffer(ctx, &data->addr, sizeof(bt_addr_le_t)); - data->sid = ser_decode_uint(ctx); - data->options = ser_decode_uint(ctx); - data->skip = ser_decode_uint(ctx); - data->timeout = ser_decode_uint(ctx); + nrf_rpc_decode_buffer(ctx, &data->addr, sizeof(bt_addr_le_t)); + data->sid = nrf_rpc_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); + data->skip = nrf_rpc_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); } static void bt_le_per_adv_sync_create_rpc_handler(const struct nrf_rpc_group *group, @@ -1733,7 +1723,7 @@ static void bt_le_per_adv_sync_create_rpc_handler(const struct nrf_rpc_group *gr bt_le_per_adv_sync_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1744,8 +1734,8 @@ static void bt_le_per_adv_sync_create_rpc_handler(const struct nrf_rpc_group *gr NRF_RPC_CBOR_ALLOC(group, ectx, buffer_size_max); - ser_encode_int(&ectx, result); - ser_encode_uint(&ectx, (uintptr_t)(*out_sync)); + nrf_rpc_encode_int(&ectx, result); + nrf_rpc_encode_uint(&ectx, (uintptr_t)(*out_sync)); nrf_rpc_cbor_rsp_no_err(group, &ectx); } @@ -1764,15 +1754,15 @@ static void bt_le_per_adv_sync_delete_rpc_handler(const struct nrf_rpc_group *gr struct bt_le_per_adv_sync *per_adv_sync; int result; - per_adv_sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + per_adv_sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_delete(per_adv_sync); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1789,15 +1779,15 @@ static void bt_le_per_adv_sync_recv_enable_rpc_handler(const struct nrf_rpc_grou struct bt_le_per_adv_sync *per_adv_sync; int result; - per_adv_sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + per_adv_sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_recv_enable(per_adv_sync); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1815,15 +1805,15 @@ static void bt_le_per_adv_sync_recv_disable_rpc_handler(const struct nrf_rpc_gro struct bt_le_per_adv_sync *per_adv_sync; int result; - per_adv_sync = (struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + per_adv_sync = (struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_recv_disable(per_adv_sync); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1844,17 +1834,17 @@ static void bt_le_per_adv_sync_transfer_rpc_handler(const struct nrf_rpc_group * uint16_t service_data; int result; - per_adv_sync = (const struct bt_le_per_adv_sync *)ser_decode_uint(ctx); + per_adv_sync = (const struct bt_le_per_adv_sync *)nrf_rpc_decode_uint(ctx); conn = bt_rpc_decode_bt_conn(ctx); - service_data = ser_decode_uint(ctx); + service_data = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_transfer(per_adv_sync, conn, service_data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1874,13 +1864,13 @@ static void bt_le_per_adv_sync_transfer_unsubscribe_rpc_handler(const struct nrf conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_transfer_unsubscribe(conn); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1894,9 +1884,9 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_per_adv_sync_transfer_unsubscribe, static void bt_le_per_adv_sync_transfer_param_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_le_per_adv_sync_transfer_param *data) { - data->skip = ser_decode_uint(ctx); - data->timeout = ser_decode_uint(ctx); - data->options = ser_decode_uint(ctx); + data->skip = nrf_rpc_decode_uint(ctx); + data->timeout = nrf_rpc_decode_uint(ctx); + data->options = nrf_rpc_decode_uint(ctx); } static void bt_le_per_adv_sync_transfer_subscribe_rpc_handler(const struct nrf_rpc_group *group, @@ -1910,13 +1900,13 @@ static void bt_le_per_adv_sync_transfer_subscribe_rpc_handler(const struct nrf_r conn = bt_rpc_decode_bt_conn(ctx); bt_le_per_adv_sync_transfer_param_dec(ctx, ¶m); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_le_per_adv_sync_transfer_subscribe(conn, ¶m); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -1933,7 +1923,7 @@ bt_le_per_adv_sync_synced_info_sp_size(const struct bt_le_per_adv_sync_synced_in { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); return scratchpad_size; } @@ -1951,12 +1941,12 @@ bt_le_per_adv_sync_synced_info_buf_size(const struct bt_le_per_adv_sync_synced_i static void bt_le_per_adv_sync_synced_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_sync_synced_info *data) { - ser_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); - ser_encode_uint(encoder, data->sid); - ser_encode_uint(encoder, data->interval); - ser_encode_uint(encoder, data->phy); - ser_encode_bool(encoder, data->recv_enabled); - ser_encode_uint(encoder, data->service_data); + nrf_rpc_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, data->sid); + nrf_rpc_encode_uint(encoder, data->interval); + nrf_rpc_encode_uint(encoder, data->phy); + nrf_rpc_encode_bool(encoder, data->recv_enabled); + nrf_rpc_encode_uint(encoder, data->service_data); bt_rpc_encode_bt_conn(encoder, data->conn); } @@ -1972,20 +1962,20 @@ static void per_adv_sync_cb_synced(struct bt_le_per_adv_sync *sync, scratchpad_size += bt_le_per_adv_sync_synced_info_sp_size(info); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)sync); bt_le_per_adv_sync_synced_info_enc(&ctx, info); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, PER_ADV_SYNC_CB_SYNCED_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static size_t bt_le_per_adv_sync_term_info_sp_size(const struct bt_le_per_adv_sync_term_info *data) { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); return scratchpad_size; } @@ -2002,8 +1992,8 @@ static size_t bt_le_per_adv_sync_term_info_buf_size(const struct bt_le_per_adv_s static void bt_le_per_adv_sync_term_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_sync_term_info *data) { - ser_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); - ser_encode_uint(encoder, data->sid); + nrf_rpc_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, data->sid); } static void per_adv_sync_cb_term(struct bt_le_per_adv_sync *sync, @@ -2018,20 +2008,20 @@ static void per_adv_sync_cb_term(struct bt_le_per_adv_sync *sync, scratchpad_size += bt_le_per_adv_sync_term_info_sp_size(info); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)sync); bt_le_per_adv_sync_term_info_enc(&ctx, info); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, PER_ADV_SYNC_CB_TERM_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static size_t bt_le_per_adv_sync_recv_info_sp_size(const struct bt_le_per_adv_sync_recv_info *data) { size_t scratchpad_size = 0; - scratchpad_size += SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(sizeof(bt_addr_le_t)); return scratchpad_size; } @@ -2048,11 +2038,11 @@ static size_t bt_le_per_adv_sync_recv_info_buf_size(const struct bt_le_per_adv_s static void bt_le_per_adv_sync_recv_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_sync_recv_info *data) { - ser_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); - ser_encode_uint(encoder, data->sid); - ser_encode_int(encoder, data->tx_power); - ser_encode_int(encoder, data->rssi); - ser_encode_uint(encoder, data->cte_type); + nrf_rpc_encode_buffer(encoder, data->addr, sizeof(bt_addr_le_t)); + nrf_rpc_encode_uint(encoder, data->sid); + nrf_rpc_encode_int(encoder, data->tx_power); + nrf_rpc_encode_int(encoder, data->rssi); + nrf_rpc_encode_uint(encoder, data->cte_type); } static void per_adv_sync_cb_recv(struct bt_le_per_adv_sync *sync, @@ -2070,20 +2060,20 @@ static void per_adv_sync_cb_recv(struct bt_le_per_adv_sync *sync, scratchpad_size += net_buf_simple_sp_size(buf); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); - ser_encode_uint(&ctx, (uintptr_t)sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)sync); bt_le_per_adv_sync_recv_info_enc(&ctx, info); net_buf_simple_enc(&ctx, buf); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, PER_ADV_SYNC_CB_RECV_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } static void bt_le_per_adv_sync_state_info_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_le_per_adv_sync_state_info *data) { - ser_encode_bool(encoder, data->recv_enabled); + nrf_rpc_encode_bool(encoder, data->recv_enabled); } static void per_adv_sync_cb_state_changed(struct bt_le_per_adv_sync *sync, @@ -2094,19 +2084,18 @@ static void per_adv_sync_cb_state_changed(struct bt_le_per_adv_sync *sync, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, (uintptr_t)sync); + nrf_rpc_encode_uint(&ctx, (uintptr_t)sync); bt_le_per_adv_sync_state_info_enc(&ctx, info); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, PER_ADV_SYNC_CB_STATE_CHANGED_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -static struct bt_le_per_adv_sync_cb per_adv_sync_cb = { - .synced = per_adv_sync_cb_synced, - .term = per_adv_sync_cb_term, - .recv = per_adv_sync_cb_recv, - .state_changed = per_adv_sync_cb_state_changed -}; +static struct bt_le_per_adv_sync_cb per_adv_sync_cb = {.synced = per_adv_sync_cb_synced, + .term = per_adv_sync_cb_term, + .recv = per_adv_sync_cb_recv, + .state_changed = + per_adv_sync_cb_state_changed}; static void bt_le_per_adv_sync_cb_register_on_remote_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, @@ -2115,8 +2104,7 @@ static void bt_le_per_adv_sync_cb_register_on_remote_rpc_handler(const struct nr nrf_rpc_cbor_decoding_done(group, ctx); bt_le_per_adv_sync_cb_register(&per_adv_sync_cb); - ser_rsp_send_void(group); - + nrf_rpc_rsp_send_void(group); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_le_per_adv_sync_cb_register_on_remote, @@ -2131,10 +2119,9 @@ static void bt_rpc_settings_load_rpc_handler(const struct nrf_rpc_group *group, nrf_rpc_cbor_decoding_done(group, ctx); settings_load(); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_settings_load, - BT_SETTINGS_LOAD_RPC_CMD, +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_settings_load, BT_SETTINGS_LOAD_RPC_CMD, bt_rpc_settings_load_rpc_handler, NULL); #endif /* defined(CONFIG_SETTINGS) */ diff --git a/subsys/bluetooth/rpc/host/bt_rpc_gatt_host.c b/subsys/bluetooth/rpc/host/bt_rpc_gatt_host.c index 5d213a1bc644..74540459b72f 100644 --- a/subsys/bluetooth/rpc/host/bt_rpc_gatt_host.c +++ b/subsys/bluetooth/rpc/host/bt_rpc_gatt_host.c @@ -15,8 +15,8 @@ #include "bt_rpc_gatt_common.h" #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include @@ -71,22 +71,19 @@ K_MUTEX_DEFINE(subscribe_containers_mutex); #endif -static struct bt_uuid const * const uuid_primary = BT_UUID_GATT_PRIMARY; -static struct bt_uuid const * const uuid_secondary = BT_UUID_GATT_SECONDARY; -static struct bt_uuid const * const uuid_chrc = BT_UUID_GATT_CHRC; -static struct bt_uuid const * const uuid_ccc = BT_UUID_GATT_CCC; -static struct bt_uuid const * const uuid_cep = BT_UUID_GATT_CEP; -static struct bt_uuid const * const uuid_cud = BT_UUID_GATT_CUD; -static struct bt_uuid const * const uuid_cpf = BT_UUID_GATT_CPF; - -static uint32_t gatt_buffer_data[DIV_ROUND_UP(CONFIG_BT_RPC_GATT_BUFFER_SIZE, - sizeof(uint32_t))]; -static struct net_buf_simple gatt_buffer = { - .data = (uint8_t *)gatt_buffer_data, - .len = 0, - .size = sizeof(gatt_buffer_data), - .__buf = (uint8_t *)gatt_buffer_data -}; +static struct bt_uuid const *const uuid_primary = BT_UUID_GATT_PRIMARY; +static struct bt_uuid const *const uuid_secondary = BT_UUID_GATT_SECONDARY; +static struct bt_uuid const *const uuid_chrc = BT_UUID_GATT_CHRC; +static struct bt_uuid const *const uuid_ccc = BT_UUID_GATT_CCC; +static struct bt_uuid const *const uuid_cep = BT_UUID_GATT_CEP; +static struct bt_uuid const *const uuid_cud = BT_UUID_GATT_CUD; +static struct bt_uuid const *const uuid_cpf = BT_UUID_GATT_CPF; + +static uint32_t gatt_buffer_data[DIV_ROUND_UP(CONFIG_BT_RPC_GATT_BUFFER_SIZE, sizeof(uint32_t))]; +static struct net_buf_simple gatt_buffer = {.data = (uint8_t *)gatt_buffer_data, + .len = 0, + .size = sizeof(gatt_buffer_data), + .__buf = (uint8_t *)gatt_buffer_data}; static struct remote_svc current_service; @@ -103,14 +100,14 @@ void bt_rpc_encode_gatt_attr(struct nrf_rpc_cbor_ctx *encoder, const struct bt_g err = bt_rpc_gatt_attr_to_index(attr, &attr_index); __ASSERT(err = 0, "Service attribute not found. Service database might be out of sync"); - ser_encode_uint(encoder, attr_index); + nrf_rpc_encode_uint(encoder, attr_index); } const struct bt_gatt_attr *bt_rpc_decode_gatt_attr(struct nrf_rpc_cbor_ctx *ctx) { uint32_t attr_index; - attr_index = ser_decode_uint(ctx); + attr_index = nrf_rpc_decode_uint(ctx); return bt_rpc_gatt_index_to_attr(attr_index); } @@ -119,7 +116,7 @@ static struct bt_uuid *bt_uuid_svc_dec(struct nrf_rpc_cbor_ctx *ctx) { struct bt_uuid *uuid; size_t buffer_size; - const void *buffer_ptr = ser_decode_buffer_ptr_and_size(ctx, &buffer_size); + const void *buffer_ptr = nrf_rpc_decode_buffer_ptr_and_size(ctx, &buffer_size); if (buffer_ptr == NULL) { return NULL; @@ -132,16 +129,16 @@ static struct bt_uuid *bt_uuid_svc_dec(struct nrf_rpc_cbor_ctx *ctx) } else if (buffer_size == sizeof(struct bt_uuid_128)) { uuid = bt_rpc_gatt_add(&gatt_buffer, sizeof(struct bt_uuid_128)); } else { - ser_decoder_invalid(ctx, ZCBOR_ERR_WRONG_TYPE); + nrf_rpc_decoder_invalid(ctx, ZCBOR_ERR_WRONG_TYPE); return NULL; } if (!uuid) { - ser_decoder_invalid(ctx, ZCBOR_ERR_NO_PAYLOAD); + nrf_rpc_decoder_invalid(ctx, ZCBOR_ERR_NO_PAYLOAD); return NULL; } - memcpy(uuid, buffer_ptr, buffer_size); + memcpy(uuid, buffer_ptr, buffer_size); return uuid; } @@ -164,16 +161,16 @@ static void bt_uuid_enc(struct nrf_rpc_cbor_ctx *encoder, const struct bt_uuid * size = sizeof(struct bt_uuid_128); break; default: - ser_encoder_invalid(encoder); + nrf_rpc_encoder_invalid(encoder); return; } } - ser_encode_buffer(encoder, uuid, size); + nrf_rpc_encode_buffer(encoder, uuid, size); } static struct bt_uuid *bt_uuid_cli_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_uuid *uuid) { - return (struct bt_uuid *)ser_decode_buffer(ctx, uuid, sizeof(struct bt_uuid_128)); + return (struct bt_uuid *)nrf_rpc_decode_buffer(ctx, uuid, sizeof(struct bt_uuid_128)); } static void report_encoding_error(uint8_t cmd_evt_id) @@ -236,25 +233,24 @@ static void bt_rpc_gatt_start_service_rpc_handler(const struct nrf_rpc_group *gr size_t attr_count; int result; - service_index = ser_decode_uint(ctx); - attr_count = ser_decode_uint(ctx); + service_index = nrf_rpc_decode_uint(ctx); + attr_count = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_rpc_gatt_start_service(service_index, attr_count); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_RPC_GATT_START_SERVICE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_gatt_start_service, BT_RPC_GATT_START_SERVICE_RPC_CMD, - bt_rpc_gatt_start_service_rpc_handler, NULL); + bt_rpc_gatt_start_service_rpc_handler, NULL); struct bt_normal_attr_read_res { uint8_t *buf; @@ -264,11 +260,10 @@ struct bt_normal_attr_read_res { static void bt_normal_attr_read_rsp(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) { - struct bt_normal_attr_read_res *res = - (struct bt_normal_attr_read_res *)handler_data; + struct bt_normal_attr_read_res *res = (struct bt_normal_attr_read_res *)handler_data; - res->read_len = ser_decode_int(ctx); - ser_decode_buffer(ctx, res->buf, (res->read_len > 0) ? res->read_len : 0); + res->read_len = nrf_rpc_decode_int(ctx); + nrf_rpc_decode_buffer(ctx, res->buf, (res->read_len > 0) ? res->read_len : 0); } static ssize_t bt_rpc_normal_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, @@ -282,13 +277,13 @@ static ssize_t bt_rpc_normal_attr_read(struct bt_conn *conn, const struct bt_gat NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - scratchpad_size += SCRATCHPAD_ALIGN(len); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(len); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); bt_rpc_encode_gatt_attr(&ctx, attr); - ser_encode_uint(&ctx, len); - ser_encode_uint(&ctx, offset); + nrf_rpc_encode_uint(&ctx, len); + nrf_rpc_encode_uint(&ctx, offset); result.buf = read_buf; result.read_len = 0; @@ -316,18 +311,18 @@ static ssize_t bt_rpc_normal_attr_write(struct bt_conn *conn, const struct bt_ga NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - scratchpad_size += SCRATCHPAD_ALIGN(len); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(len); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); bt_rpc_encode_gatt_attr(&ctx, attr); - ser_encode_uint(&ctx, len); - ser_encode_uint(&ctx, offset); - ser_encode_uint(&ctx, flags); - ser_encode_buffer(&ctx, buf, len); + nrf_rpc_encode_uint(&ctx, len); + nrf_rpc_encode_uint(&ctx, offset); + nrf_rpc_encode_uint(&ctx, flags); + nrf_rpc_encode_buffer(&ctx, buf, len); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_ATTR_WRITE_RPC_CMD, &ctx, - ser_rsp_decode_i32, &result); + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -335,12 +330,11 @@ static ssize_t bt_rpc_normal_attr_write(struct bt_conn *conn, const struct bt_ga static void add_user_attr(struct bt_gatt_attr *attr, const struct bt_uuid *uuid, uint16_t data) { attr->uuid = uuid; - attr->read = (data & BT_RPC_GATT_ATTR_READ_PRESENT_FLAG) ? - bt_rpc_normal_attr_read : NULL; - attr->write = (data & BT_RPC_GATT_ATTR_WRITE_PRESENT_FLAG) ? - bt_rpc_normal_attr_write : NULL; - attr->user_data = (void *)((current_service.index << 16) | - current_service.service->attr_count); + attr->read = (data & BT_RPC_GATT_ATTR_READ_PRESENT_FLAG) ? bt_rpc_normal_attr_read : NULL; + attr->write = + (data & BT_RPC_GATT_ATTR_WRITE_PRESENT_FLAG) ? bt_rpc_normal_attr_write : NULL; + attr->user_data = + (void *)((current_service.index << 16) | current_service.service->attr_count); attr->handle = 0; attr->perm = (uint8_t)data; } @@ -351,7 +345,7 @@ static void add_srv_attr(struct bt_gatt_attr *attr, const struct bt_uuid *servic attr->uuid = attr_uuid; attr->read = bt_gatt_attr_read_service; attr->write = NULL; - attr->user_data = (void *) service_uuid; + attr->user_data = (void *)service_uuid; attr->handle = 0; attr->perm = BT_GATT_PERM_READ; } @@ -360,8 +354,7 @@ static int add_chrc_attr(struct bt_gatt_attr *attr, const struct bt_uuid *uuid, { struct bt_gatt_chrc *chrc; - chrc = (struct bt_gatt_chrc *)bt_rpc_gatt_add(&gatt_buffer, - sizeof(struct bt_gatt_chrc)); + chrc = (struct bt_gatt_chrc *)bt_rpc_gatt_add(&gatt_buffer, sizeof(struct bt_gatt_chrc)); if (!chrc) { return -ENOMEM; } @@ -432,29 +425,27 @@ static void bt_rpc_gatt_send_simple_attr_rpc_handler(const struct nrf_rpc_group uuid = bt_uuid_svc_dec(ctx); - special_attr = ser_decode_uint(ctx); - data = ser_decode_uint(ctx); + special_attr = nrf_rpc_decode_uint(ctx); + data = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_rpc_gatt_send_simple_attr(special_attr, uuid, data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_RPC_GATT_SEND_SIMPLE_ATTR_RPC_CMD, handler_data); - } static int add_cep_attr(struct bt_gatt_attr *attr, uint16_t properties) { struct bt_gatt_cep *cep; - cep = (struct bt_gatt_cep *)bt_rpc_gatt_add(&gatt_buffer, - sizeof(struct bt_gatt_cep)); + cep = (struct bt_gatt_cep *)bt_rpc_gatt_add(&gatt_buffer, sizeof(struct bt_gatt_cep)); if (!cep) { return -ENOMEM; } @@ -483,7 +474,7 @@ static int add_cud_attr(struct bt_gatt_attr *attr, uint8_t perm, char *text, siz memset(attr->user_data, 0, size); attr->uuid = uuid_cud; - attr->read = bt_gatt_attr_read_cud; + attr->read = bt_gatt_attr_read_cud; attr->write = NULL; attr->handle = 0; attr->perm = perm; @@ -530,15 +521,15 @@ static void bt_ccc_cfg_changed_call(const struct bt_gatt_attr *attr, uint16_t va NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, index); - ser_encode_uint(&ctx, value); + nrf_rpc_encode_uint(&ctx, index); + nrf_rpc_encode_uint(&ctx, value); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_CCC_CFG_CHANGED_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_CCC_CFG_CHANGED_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_void, NULL); } -static ssize_t bt_ccc_cfg_write_call(struct bt_conn *conn, - const struct bt_gatt_attr *attr, uint16_t value) +static ssize_t bt_ccc_cfg_write_call(struct bt_conn *conn, const struct bt_gatt_attr *attr, + uint16_t value) { struct nrf_rpc_cbor_ctx ctx; ssize_t result; @@ -555,11 +546,11 @@ static ssize_t bt_ccc_cfg_write_call(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, index); - ser_encode_uint(&ctx, value); + nrf_rpc_encode_uint(&ctx, index); + nrf_rpc_encode_uint(&ctx, value); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_CCC_CFG_WRITE_RPC_CMD, - &ctx, ser_rsp_decode_i32, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_CCC_CFG_WRITE_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_i32, &result); return result; } @@ -581,10 +572,10 @@ static bool bt_ccc_cfg_match_call(struct bt_conn *conn, const struct bt_gatt_att NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, index); + nrf_rpc_encode_uint(&ctx, index); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_CCC_CFG_MATCH_RPC_CMD, - &ctx, ser_rsp_decode_bool, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_RPC_GATT_CB_CCC_CFG_MATCH_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_bool, &result); return result; } @@ -600,12 +591,12 @@ static int add_ccc_attr(struct bt_gatt_attr *attr, uint16_t param) memset(ccc, 0, sizeof(struct _bt_gatt_ccc)); - ccc->cfg_changed = (param & BT_RPC_GATT_CCC_CFG_CHANGE_PRESENT_FLAG) ? - bt_ccc_cfg_changed_call : NULL; - ccc->cfg_write = (param & BT_RPC_GATT_CCC_CFG_WRITE_PRESENT_FLAG) ? - bt_ccc_cfg_write_call : NULL; - ccc->cfg_match = (param & BT_RPC_GATT_CCC_CFG_MATCH_PRESET_FLAG) ? - bt_ccc_cfg_match_call : NULL; + ccc->cfg_changed = + (param & BT_RPC_GATT_CCC_CFG_CHANGE_PRESENT_FLAG) ? bt_ccc_cfg_changed_call : NULL; + ccc->cfg_write = + (param & BT_RPC_GATT_CCC_CFG_WRITE_PRESENT_FLAG) ? bt_ccc_cfg_write_call : NULL; + ccc->cfg_match = + (param & BT_RPC_GATT_CCC_CFG_MATCH_PRESET_FLAG) ? bt_ccc_cfg_match_call : NULL; attr->uuid = uuid_ccc; attr->read = bt_gatt_attr_read_ccc; @@ -667,30 +658,29 @@ static void bt_rpc_gatt_send_desc_attr_rpc_handler(const struct nrf_rpc_group *g size_t size; uint8_t *buffer; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); - special_attr = ser_decode_uint(ctx); - param = ser_decode_uint(ctx); - size = ser_decode_uint(ctx); - buffer = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); + special_attr = nrf_rpc_decode_uint(ctx); + param = nrf_rpc_decode_uint(ctx); + size = nrf_rpc_decode_uint(ctx); + buffer = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_rpc_gatt_send_desc_attr(special_attr, param, buffer, size); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_RPC_GATT_SEND_DESC_ATTR_RPC_CMD, handler_data); } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_gatt_send_desc_attr, - BT_RPC_GATT_SEND_DESC_ATTR_RPC_CMD, +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_gatt_send_desc_attr, BT_RPC_GATT_SEND_DESC_ATTR_RPC_CMD, bt_rpc_gatt_send_desc_attr_rpc_handler, NULL); #if defined(CONFIG_BT_GATT_DYNAMIC_DB) @@ -716,12 +706,11 @@ static void bt_rpc_gatt_end_service_rpc_handler(const struct nrf_rpc_group *grou result = bt_rpc_gatt_end_service(); - ser_rsp_send_int(group, result); - + nrf_rpc_rsp_send_int(group, result); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_gatt_end_service, BT_RPC_GATT_END_SERVICE_RPC_CMD, - bt_rpc_gatt_end_service_rpc_handler, NULL); + bt_rpc_gatt_end_service_rpc_handler, NULL); static void bt_rpc_gatt_service_unregister_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, @@ -731,9 +720,9 @@ static void bt_rpc_gatt_service_unregister_rpc_handler(const struct nrf_rpc_grou uint16_t svc_index; const struct bt_gatt_service *svc; - svc_index = ser_decode_uint(ctx); + svc_index = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -750,7 +739,7 @@ static void bt_rpc_gatt_service_unregister_rpc_handler(const struct nrf_rpc_grou result = bt_rpc_gatt_remove_service(svc); } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_RPC_GATT_SERVICE_UNREGISTER_RPC_CMD, handler_data); @@ -770,30 +759,30 @@ static inline void bt_gatt_complete_func_t_callback(struct bt_conn *conn, void * NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, (uintptr_t)user_data); - ser_encode_callback_call(&ctx, callback_slot); + nrf_rpc_encode_uint(&ctx, (uintptr_t)user_data); + nrf_rpc_encode_callback_call(&ctx, callback_slot); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_COMPLETE_FUNC_T_CALLBACK_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_COMPLETE_FUNC_T_CALLBACK_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_gatt_complete_func_t_encoder, bt_gatt_complete_func_t_callback, - (struct bt_conn *conn, void *user_data), (conn, user_data)); +NRF_RPC_CBKPROXY_HANDLER(bt_gatt_complete_func_t_encoder, bt_gatt_complete_func_t_callback, + (struct bt_conn *conn, void *user_data), (conn, user_data)); -static void bt_gatt_notify_params_dec(struct ser_scratchpad *scratchpad, +static void bt_gatt_notify_params_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_gatt_notify_params *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; data->attr = bt_rpc_decode_gatt_attr(ctx); - data->len = ser_decode_uint(ctx); - data->data = ser_decode_buffer_into_scratchpad(scratchpad, NULL); - data->func = - (bt_gatt_complete_func_t)ser_decode_callback(ctx, bt_gatt_complete_func_t_encoder); - data->user_data = (void *)(uintptr_t)ser_decode_uint(ctx); + data->len = nrf_rpc_decode_uint(ctx); + data->data = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); + data->func = (bt_gatt_complete_func_t)nrf_rpc_decode_callbackd( + ctx, bt_gatt_complete_func_t_encoder); + data->user_data = (void *)(uintptr_t)nrf_rpc_decode_uint(ctx); - data->uuid = (struct bt_uuid *)ser_decode_buffer_into_scratchpad(scratchpad, NULL); + data->uuid = (struct bt_uuid *)nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); } static void bt_gatt_notify_cb_rpc_handler(const struct nrf_rpc_group *group, @@ -803,20 +792,20 @@ static void bt_gatt_notify_cb_rpc_handler(const struct nrf_rpc_group *group, struct bt_conn *conn; struct bt_gatt_notify_params params; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); bt_gatt_notify_params_dec(&scratchpad, ¶ms); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_notify_cb(conn, ¶ms); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -824,25 +813,24 @@ static void bt_gatt_notify_cb_rpc_handler(const struct nrf_rpc_group *group, } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_notify_cb, BT_GATT_NOTIFY_CB_RPC_CMD, - bt_gatt_notify_cb_rpc_handler, NULL); + bt_gatt_notify_cb_rpc_handler, NULL); -static void bt_gatt_indicate_params_dec(struct ser_scratchpad *scratchpad, +static void bt_gatt_indicate_params_dec(struct nrf_rpc_scratchpad *scratchpad, struct bt_gatt_indicate_params *data) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; data->attr = bt_rpc_decode_gatt_attr(ctx); - data->len = ser_decode_uint(ctx); - data->data = ser_decode_buffer_into_scratchpad(scratchpad, NULL); - data->_ref = ser_decode_uint(ctx); + data->len = nrf_rpc_decode_uint(ctx); + data->data = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); + data->_ref = nrf_rpc_decode_uint(ctx); - data->uuid = (struct bt_uuid *)ser_decode_buffer_into_scratchpad(scratchpad, NULL); + data->uuid = (struct bt_uuid *)nrf_rpc_decode_buffer_into_scratchpad(scratchpad, NULL); } static void bt_gatt_indicate_func_t_callback(struct bt_conn *conn, - struct bt_gatt_indicate_params *params, - uint8_t err) + struct bt_gatt_indicate_params *params, uint8_t err) { struct nrf_rpc_cbor_ctx ctx; size_t buffer_size_max = 10; @@ -853,11 +841,11 @@ static void bt_gatt_indicate_func_t_callback(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, err); - ser_encode_uint(&ctx, rpc_params->param_addr); + nrf_rpc_encode_uint(&ctx, err); + nrf_rpc_encode_uint(&ctx, rpc_params->param_addr); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_INDICATE_FUNC_T_CALLBACK_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_INDICATE_FUNC_T_CALLBACK_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_void, NULL); } static void bt_gatt_indicate_params_destroy_t_callback(struct bt_gatt_indicate_params *params) @@ -870,12 +858,12 @@ static void bt_gatt_indicate_params_destroy_t_callback(struct bt_gatt_indicate_p NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, rpc_params->param_addr); + nrf_rpc_encode_uint(&ctx, rpc_params->param_addr); k_free(rpc_params); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_INDICATE_PARAMS_DESTROY_T_CALLBACK_RPC_CMD, - &ctx, ser_rsp_decode_void, NULL); + &ctx, nrf_rpc_rsp_decode_void, NULL); } static void bt_gatt_indicate_rpc_handler(const struct nrf_rpc_group *group, @@ -885,17 +873,17 @@ static void bt_gatt_indicate_rpc_handler(const struct nrf_rpc_group *group, struct bt_conn *conn; struct bt_rpc_gatt_indication_params *params; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; params = (struct bt_rpc_gatt_indication_params *)k_malloc(sizeof(*params)); - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); bt_gatt_indicate_params_dec(&scratchpad, ¶ms->params); - params->param_addr = ser_decode_uint(ctx); + params->param_addr = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -904,7 +892,7 @@ static void bt_gatt_indicate_rpc_handler(const struct nrf_rpc_group *group, result = bt_gatt_indicate(conn, ¶ms->params); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: @@ -913,7 +901,7 @@ static void bt_gatt_indicate_rpc_handler(const struct nrf_rpc_group *group, } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_indicate, BT_GATT_INDICATE_RPC_CMD, - bt_gatt_indicate_rpc_handler, NULL); + bt_gatt_indicate_rpc_handler, NULL); static void bt_gatt_is_subscribed_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -925,20 +913,19 @@ static void bt_gatt_is_subscribed_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); attr = bt_rpc_decode_gatt_attr(ctx); - ccc_value = ser_decode_uint(ctx); + ccc_value = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_is_subscribed(conn, attr, ccc_value); - ser_rsp_send_bool(group, result); + nrf_rpc_rsp_send_bool(group, result); return; decoding_error: report_decoding_error(BT_GATT_IS_SUBSCRIBED_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_is_subscribed, BT_GATT_IS_SUBSCRIBED_RPC_CMD, @@ -953,13 +940,13 @@ static void bt_gatt_get_mtu_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_get_mtu(conn); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_error: @@ -987,11 +974,11 @@ static void bt_gatt_exchange_mtu_callback(struct bt_conn *conn, uint8_t err, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, 10); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, err); - ser_encode_uint(&ctx, container->remote_pointer); + nrf_rpc_encode_uint(&ctx, err); + nrf_rpc_encode_uint(&ctx, container->remote_pointer); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_EXCHANGE_MTU_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); k_free(container); } @@ -1007,13 +994,13 @@ static void bt_gatt_exchange_mtu_rpc_handler(const struct nrf_rpc_group *group, conn = bt_rpc_decode_bt_conn(ctx); container = k_malloc(sizeof(struct bt_gatt_exchange_mtu_container)); if (container == NULL) { - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); goto alloc_error; } - container->remote_pointer = ser_decode_uint(ctx); + container->remote_pointer = nrf_rpc_decode_uint(ctx); container->params.func = bt_gatt_exchange_mtu_callback; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1023,7 +1010,7 @@ static void bt_gatt_exchange_mtu_rpc_handler(const struct nrf_rpc_group *group, k_free(container); } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; @@ -1031,11 +1018,10 @@ static void bt_gatt_exchange_mtu_rpc_handler(const struct nrf_rpc_group *group, k_free(container); alloc_error: report_decoding_error(BT_GATT_EXCHANGE_MTU_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_exchange_mtu, BT_GATT_EXCHANGE_MTU_RPC_CMD, - bt_gatt_exchange_mtu_rpc_handler, NULL); + bt_gatt_exchange_mtu_rpc_handler, NULL); #endif /* CONFIG_BT_GATT_CLIENT */ @@ -1048,18 +1034,17 @@ static void bt_gatt_attr_get_handle_rpc_handler(const struct nrf_rpc_group *grou attr = bt_rpc_decode_gatt_attr(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_attr_get_handle(attr); - ser_rsp_send_uint(group, result); + nrf_rpc_rsp_send_uint(group, result); return; decoding_error: report_decoding_error(BT_GATT_ATTR_GET_HANDLE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_attr_get_handle, BT_GATT_ATTR_GET_HANDLE_RPC_CMD, @@ -1073,16 +1058,14 @@ static void bt_gatt_cb_att_mtu_update_call(struct bt_conn *conn, uint16_t tx, ui NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, tx); - ser_encode_uint(&ctx, rx); + nrf_rpc_encode_uint(&ctx, tx); + nrf_rpc_encode_uint(&ctx, rx); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_CB_ATT_MTU_UPDATE_CALL_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -static struct bt_gatt_cb bt_gatt_cb_data = { - .att_mtu_updated = bt_gatt_cb_att_mtu_update_call -}; +static struct bt_gatt_cb bt_gatt_cb_data = {.att_mtu_updated = bt_gatt_cb_att_mtu_update_call}; static void bt_gatt_cb_register_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -1091,7 +1074,7 @@ static void bt_gatt_cb_register_handler(const struct nrf_rpc_group *group, bt_gatt_cb_register(&bt_gatt_cb_data); - ser_rsp_send_void(group); + nrf_rpc_rsp_send_void(group); } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_cb_register, BT_LE_GATT_CB_REGISTER_ON_REMOTE_RPC_CMD, @@ -1099,9 +1082,8 @@ NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_cb_register, BT_LE_GATT_CB_REGISTER #if defined(CONFIG_BT_GATT_CLIENT) -static uint8_t bt_gatt_discover_callback(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - struct bt_gatt_discover_params *params) +static uint8_t bt_gatt_discover_callback(struct bt_conn *conn, const struct bt_gatt_attr *attr, + struct bt_gatt_discover_params *params) { uint8_t result; struct bt_gatt_discover_container *container; @@ -1112,17 +1094,17 @@ static uint8_t bt_gatt_discover_callback(struct bt_conn *conn, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, 53); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, container->remote_pointer); + nrf_rpc_encode_uint(&ctx, container->remote_pointer); if (attr == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else { struct bt_uuid_16 *attr_uuid_16 = (struct bt_uuid_16 *)attr->uuid; bt_uuid_enc(&ctx, attr->uuid); - ser_encode_uint(&ctx, attr->handle); + nrf_rpc_encode_uint(&ctx, attr->handle); if (attr->user_data == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else if (attr->uuid->type != BT_UUID_TYPE_16) { goto unsupported_exit; } else if (attr_uuid_16->val == BT_UUID_GATT_PRIMARY_VAL || @@ -1131,28 +1113,28 @@ static uint8_t bt_gatt_discover_callback(struct bt_conn *conn, service = (struct bt_gatt_service_val *)attr->user_data; bt_uuid_enc(&ctx, service->uuid); - ser_encode_uint(&ctx, service->end_handle); + nrf_rpc_encode_uint(&ctx, service->end_handle); } else if (attr_uuid_16->val == BT_UUID_GATT_INCLUDE_VAL) { struct bt_gatt_include *include; include = (struct bt_gatt_include *)attr->user_data; bt_uuid_enc(&ctx, include->uuid); - ser_encode_uint(&ctx, include->start_handle); - ser_encode_uint(&ctx, include->end_handle); + nrf_rpc_encode_uint(&ctx, include->start_handle); + nrf_rpc_encode_uint(&ctx, include->end_handle); } else if (attr_uuid_16->val == BT_UUID_GATT_CHRC_VAL) { struct bt_gatt_chrc *chrc; chrc = (struct bt_gatt_chrc *)attr->user_data; bt_uuid_enc(&ctx, chrc->uuid); - ser_encode_uint(&ctx, chrc->value_handle); - ser_encode_uint(&ctx, chrc->properties); + nrf_rpc_encode_uint(&ctx, chrc->value_handle); + nrf_rpc_encode_uint(&ctx, chrc->properties); } else { goto unsupported_exit; } } - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_DISCOVER_CALLBACK_RPC_CMD, - &ctx, ser_rsp_decode_u8, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_DISCOVER_CALLBACK_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_u8, &result); if (result == BT_GATT_ITER_STOP || attr == NULL) { k_free(container); @@ -1170,9 +1152,9 @@ static void bt_gatt_discover_params_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_gatt_discover_params *data) { data->uuid = bt_uuid_cli_dec(ctx, (struct bt_uuid *)data->uuid); - data->start_handle = ser_decode_uint(ctx); - data->end_handle = ser_decode_uint(ctx); - data->type = ser_decode_uint(ctx); + data->start_handle = nrf_rpc_decode_uint(ctx); + data->end_handle = nrf_rpc_decode_uint(ctx); + data->type = nrf_rpc_decode_uint(ctx); } static void bt_gatt_discover_rpc_handler(const struct nrf_rpc_group *group, @@ -1184,18 +1166,18 @@ static void bt_gatt_discover_rpc_handler(const struct nrf_rpc_group *group, container = k_malloc(sizeof(struct bt_gatt_discover_container)); if (container == NULL) { - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); goto alloc_error; } container->params.uuid = &container->uuid; conn = bt_rpc_decode_bt_conn(ctx); bt_gatt_discover_params_dec(ctx, &container->params); - container->remote_pointer = ser_decode_uint(ctx); + container->remote_pointer = nrf_rpc_decode_uint(ctx); container->params.func = bt_gatt_discover_callback; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1205,7 +1187,7 @@ static void bt_gatt_discover_rpc_handler(const struct nrf_rpc_group *group, k_free(container); } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; @@ -1216,7 +1198,7 @@ static void bt_gatt_discover_rpc_handler(const struct nrf_rpc_group *group, } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_discover, BT_GATT_DISCOVER_RPC_CMD, - bt_gatt_discover_rpc_handler, NULL); + bt_gatt_discover_rpc_handler, NULL); static uint8_t bt_gatt_read_callback(struct bt_conn *conn, uint8_t err, struct bt_gatt_read_params *params, const void *data, @@ -1230,14 +1212,14 @@ static uint8_t bt_gatt_read_callback(struct bt_conn *conn, uint8_t err, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, 20 + length); - ser_encode_uint(&ctx, SCRATCHPAD_ALIGN(length)); + nrf_rpc_encode_uint(&ctx, NRF_RPC_SCRATCHPAD_ALIGN(length)); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, err); - ser_encode_uint(&ctx, container->remote_pointer); - ser_encode_buffer(&ctx, data, length); + nrf_rpc_encode_uint(&ctx, err); + nrf_rpc_encode_uint(&ctx, container->remote_pointer); + nrf_rpc_encode_buffer(&ctx, data, length); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_READ_CALLBACK_RPC_CMD, &ctx, ser_rsp_decode_u8, - &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_READ_CALLBACK_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_u8, &result); if (result == BT_GATT_ITER_STOP || data == NULL || params->handle_count == 1) { k_free(container); @@ -1249,16 +1231,16 @@ static uint8_t bt_gatt_read_callback(struct bt_conn *conn, uint8_t err, static void bt_gatt_read_params_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_gatt_read_params *data) { if (data->handle_count == 0) { - data->by_uuid.start_handle = ser_decode_uint(ctx); - data->by_uuid.end_handle = ser_decode_uint(ctx); + data->by_uuid.start_handle = nrf_rpc_decode_uint(ctx); + data->by_uuid.end_handle = nrf_rpc_decode_uint(ctx); data->by_uuid.uuid = bt_uuid_cli_dec(ctx, (struct bt_uuid *)data->by_uuid.uuid); } else if (data->handle_count == 1) { - data->single.handle = ser_decode_uint(ctx); - data->single.offset = ser_decode_uint(ctx); + data->single.handle = nrf_rpc_decode_uint(ctx); + data->single.offset = nrf_rpc_decode_uint(ctx); } else { - ser_decode_buffer(ctx, data->multiple.handles, - sizeof(data->multiple.handles[0]) * data->handle_count); - data->multiple.variable = ser_decode_bool(ctx); + nrf_rpc_decode_buffer(ctx, data->multiple.handles, + sizeof(data->multiple.handles[0]) * data->handle_count); + data->multiple.variable = nrf_rpc_decode_bool(ctx); } } @@ -1271,11 +1253,11 @@ static void bt_gatt_read_rpc_handler(const struct nrf_rpc_group *group, size_t handle_count; conn = bt_rpc_decode_bt_conn(ctx); - handle_count = ser_decode_uint(ctx); + handle_count = nrf_rpc_decode_uint(ctx); container = k_malloc(sizeof(struct bt_gatt_read_container) + sizeof(container->params.multiple.handles[0]) * handle_count); if (container == NULL) { - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); goto alloc_error; } container->params.handle_count = handle_count; @@ -1283,10 +1265,10 @@ static void bt_gatt_read_rpc_handler(const struct nrf_rpc_group *group, container->params.multiple.handles = container->handles; bt_gatt_read_params_dec(ctx, &container->params); - container->remote_pointer = ser_decode_uint(ctx); + container->remote_pointer = nrf_rpc_decode_uint(ctx); container->params.func = bt_gatt_read_callback; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1296,7 +1278,7 @@ static void bt_gatt_read_rpc_handler(const struct nrf_rpc_group *group, k_free(container); } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; @@ -1304,11 +1286,10 @@ static void bt_gatt_read_rpc_handler(const struct nrf_rpc_group *group, k_free(container); alloc_error: report_decoding_error(BT_GATT_READ_RPC_CMD, handler_data); - } -NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_read, BT_GATT_READ_RPC_CMD, - bt_gatt_read_rpc_handler, NULL); +NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_read, BT_GATT_READ_RPC_CMD, bt_gatt_read_rpc_handler, + NULL); static void bt_gatt_write_callback(struct bt_conn *conn, uint8_t err, struct bt_gatt_write_params *params) @@ -1321,11 +1302,11 @@ static void bt_gatt_write_callback(struct bt_conn *conn, uint8_t err, NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, 10); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, err); - ser_encode_uint(&ctx, container->remote_pointer); + nrf_rpc_encode_uint(&ctx, err); + nrf_rpc_encode_uint(&ctx, container->remote_pointer); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_WRITE_CALLBACK_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); k_free(container); } @@ -1340,26 +1321,25 @@ static void bt_gatt_write_rpc_handler(const struct nrf_rpc_group *group, size_t buffer_length; const void *buffer_ptr; - conn = bt_rpc_decode_bt_conn(ctx); - buffer_ptr = ser_decode_buffer_ptr_and_size(ctx, &buffer_length); + buffer_ptr = nrf_rpc_decode_buffer_ptr_and_size(ctx, &buffer_length); if (buffer_ptr == NULL) { goto alloc_error; } container = k_malloc(sizeof(struct bt_gatt_write_container) + buffer_length); if (container == NULL) { - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); goto alloc_error; } container->params.data = container->data; container->params.length = buffer_length; memcpy(container->data, buffer_ptr, buffer_length); - container->params.handle = ser_decode_uint(ctx); - container->params.offset = ser_decode_uint(ctx); - container->remote_pointer = ser_decode_uint(ctx); + container->params.handle = nrf_rpc_decode_uint(ctx); + container->params.offset = nrf_rpc_decode_uint(ctx); + container->remote_pointer = nrf_rpc_decode_uint(ctx); container->params.func = bt_gatt_write_callback; - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1369,7 +1349,7 @@ static void bt_gatt_write_rpc_handler(const struct nrf_rpc_group *group, k_free(container); } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; @@ -1377,11 +1357,10 @@ static void bt_gatt_write_rpc_handler(const struct nrf_rpc_group *group, k_free(container); alloc_error: report_decoding_error(BT_GATT_WRITE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_write, BT_GATT_WRITE_RPC_CMD, - bt_gatt_write_rpc_handler, NULL); + bt_gatt_write_rpc_handler, NULL); static void bt_gatt_write_without_response_cb_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, @@ -1396,36 +1375,36 @@ static void bt_gatt_write_without_response_cb_rpc_handler(const struct nrf_rpc_g bt_gatt_complete_func_t func; void *user_data; int result; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); conn = bt_rpc_decode_bt_conn(ctx); - handle = ser_decode_uint(ctx); - length = ser_decode_uint(ctx); - data = ser_decode_buffer_into_scratchpad(&scratchpad, NULL); - sign = ser_decode_bool(ctx); - func = (bt_gatt_complete_func_t)ser_decode_callback(ctx, bt_gatt_complete_func_t_encoder); - user_data = (void *)ser_decode_uint(ctx); - - if (!ser_decoding_done_and_check(group, ctx)) { + handle = nrf_rpc_decode_uint(ctx); + length = nrf_rpc_decode_uint(ctx); + data = nrf_rpc_decode_buffer_into_scratchpad(&scratchpad, NULL); + sign = nrf_rpc_decode_bool(ctx); + func = (bt_gatt_complete_func_t)nrf_rpc_decode_callbackd(ctx, + bt_gatt_complete_func_t_encoder); + user_data = (void *)nrf_rpc_decode_uint(ctx); + + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_write_without_response_cb(conn, handle, data, length, sign, func, user_data); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_GATT_WRITE_WITHOUT_RESPONSE_CB_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_write_without_response_cb, - BT_GATT_WRITE_WITHOUT_RESPONSE_CB_RPC_CMD, bt_gatt_write_without_response_cb_rpc_handler, - NULL); + BT_GATT_WRITE_WITHOUT_RESPONSE_CB_RPC_CMD, + bt_gatt_write_without_response_cb_rpc_handler, NULL); static struct bt_gatt_subscribe_container *get_subscribe_container(uintptr_t remote_pointer, bool *create) @@ -1465,8 +1444,8 @@ static void free_subscribe_container(struct bt_gatt_subscribe_container *contain } static uint8_t bt_gatt_subscribe_params_notify(struct bt_conn *conn, - struct bt_gatt_subscribe_params *params, - const void *data, uint16_t length) + struct bt_gatt_subscribe_params *params, + const void *data, uint16_t length) { struct nrf_rpc_cbor_ctx ctx; size_t _data_size; @@ -1480,17 +1459,17 @@ static uint8_t bt_gatt_subscribe_params_notify(struct bt_conn *conn, _data_size = sizeof(uint8_t) * length; buffer_size_max += _data_size; - scratchpad_size += SCRATCHPAD_ALIGN(_data_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(_data_size); NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, container->remote_pointer); - ser_encode_buffer(&ctx, data, _data_size); + nrf_rpc_encode_uint(&ctx, container->remote_pointer); + nrf_rpc_encode_buffer(&ctx, data, _data_size); - nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_SUBSCRIBE_PARAMS_NOTIFY_RPC_CMD, - &ctx, ser_rsp_decode_u8, &result); + nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_SUBSCRIBE_PARAMS_NOTIFY_RPC_CMD, &ctx, + nrf_rpc_rsp_decode_u8, &result); return result; } @@ -1507,45 +1486,45 @@ static void bt_gatt_subscribe_params_write(struct bt_conn *conn, uint8_t err, if (params != NULL) { params_size = sizeof(uint8_t) * params->length; buffer_size_max += params_size; - scratchpad_size += SCRATCHPAD_ALIGN(params_size); + scratchpad_size += NRF_RPC_SCRATCHPAD_ALIGN(params_size); } NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max); - ser_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_uint(&ctx, scratchpad_size); bt_rpc_encode_bt_conn(&ctx, conn); - ser_encode_uint(&ctx, err); + nrf_rpc_encode_uint(&ctx, err); if (params != NULL) { - ser_encode_uint(&ctx, params->handle); - ser_encode_uint(&ctx, params->offset); - ser_encode_buffer(&ctx, params->data, params->length); + nrf_rpc_encode_uint(&ctx, params->handle); + nrf_rpc_encode_uint(&ctx, params->offset); + nrf_rpc_encode_buffer(&ctx, params->data, params->length); } else { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } - ser_encode_uint(&ctx, callback_slot); + nrf_rpc_encode_uint(&ctx, callback_slot); nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_GATT_SUBSCRIBE_PARAMS_WRITE_RPC_CMD, &ctx, - ser_rsp_decode_void, NULL); + nrf_rpc_rsp_decode_void, NULL); } -CBKPROXY_HANDLER(bt_gatt_subscribe_params_write_encoder, bt_gatt_subscribe_params_write, - (struct bt_conn *conn, uint8_t err, struct bt_gatt_write_params *params), - (conn, err, params)); +NRF_RPC_CBKPROXY_HANDLER(bt_gatt_subscribe_params_write_encoder, bt_gatt_subscribe_params_write, + (struct bt_conn *conn, uint8_t err, struct bt_gatt_write_params *params), + (conn, err, params)); static void bt_gatt_subscribe_params_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_gatt_subscribe_params *data) { - data->notify = ser_decode_bool(ctx) ? bt_gatt_subscribe_params_notify : NULL; - data->write = (bt_gatt_write_func_t)ser_decode_callback( + data->notify = nrf_rpc_decode_bool(ctx) ? bt_gatt_subscribe_params_notify : NULL; + data->write = (bt_gatt_write_func_t)nrf_rpc_decode_callbackd( ctx, bt_gatt_subscribe_params_write_encoder); - data->value_handle = ser_decode_uint(ctx); - data->ccc_handle = ser_decode_uint(ctx); - data->value = ser_decode_uint(ctx); + data->value_handle = nrf_rpc_decode_uint(ctx); + data->ccc_handle = nrf_rpc_decode_uint(ctx); + data->value = nrf_rpc_decode_uint(ctx); #if defined(CONFIG_BT_SMP) - data->min_security = ser_decode_uint(ctx); + data->min_security = nrf_rpc_decode_uint(ctx); #endif - atomic_set(data->flags, (atomic_val_t)ser_decode_uint(ctx)); + atomic_set(data->flags, (atomic_val_t)nrf_rpc_decode_uint(ctx)); } static void bt_gatt_subscribe_rpc_handler(const struct nrf_rpc_group *group, @@ -1559,21 +1538,21 @@ static void bt_gatt_subscribe_rpc_handler(const struct nrf_rpc_group *group, uintptr_t remote_pointer; conn = bt_rpc_decode_bt_conn(ctx); - remote_pointer = ser_decode_uint(ctx); + remote_pointer = nrf_rpc_decode_uint(ctx); container = get_subscribe_container(remote_pointer, &new_container); if (container == NULL) { - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); goto alloc_error; } bt_gatt_subscribe_params_dec(ctx, &container->params); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_subscribe(conn, &container->params); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); if (result < 0 && new_container) { free_subscribe_container(container); @@ -1586,11 +1565,10 @@ static void bt_gatt_subscribe_rpc_handler(const struct nrf_rpc_group *group, } alloc_error: report_decoding_error(BT_GATT_SUBSCRIBE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_subscribe, BT_GATT_SUBSCRIBE_RPC_CMD, - bt_gatt_subscribe_rpc_handler, NULL); + bt_gatt_subscribe_rpc_handler, NULL); static void bt_gatt_resubscribe_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -1604,23 +1582,23 @@ static void bt_gatt_resubscribe_rpc_handler(const struct nrf_rpc_group *group, struct bt_gatt_subscribe_container *container; bool new_container = true; - id = ser_decode_uint(ctx); - peer = ser_decode_buffer(ctx, &_peer_data, sizeof(bt_addr_le_t)); - remote_pointer = ser_decode_uint(ctx); + id = nrf_rpc_decode_uint(ctx); + peer = nrf_rpc_decode_buffer(ctx, &_peer_data, sizeof(bt_addr_le_t)); + remote_pointer = nrf_rpc_decode_uint(ctx); container = get_subscribe_container(remote_pointer, &new_container); if (container == NULL) { - ser_decoding_done_and_check(group, ctx); + nrf_rpc_decoding_done_and_check(group, ctx); goto alloc_error; } bt_gatt_subscribe_params_dec(ctx, &container->params); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_gatt_resubscribe(id, peer, &container->params); - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); if (result < 0 && new_container) { free_subscribe_container(container); @@ -1633,11 +1611,10 @@ static void bt_gatt_resubscribe_rpc_handler(const struct nrf_rpc_group *group, } alloc_error: report_decoding_error(BT_GATT_RESUBSCRIBE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_resubscribe, BT_GATT_RESUBSCRIBE_RPC_CMD, - bt_gatt_resubscribe_rpc_handler, NULL); + bt_gatt_resubscribe_rpc_handler, NULL); static void bt_gatt_unsubscribe_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, void *handler_data) @@ -1649,9 +1626,9 @@ static void bt_gatt_unsubscribe_rpc_handler(const struct nrf_rpc_group *group, bool new_container = false; conn = bt_rpc_decode_bt_conn(ctx); - remote_pointer = ser_decode_uint(ctx); + remote_pointer = nrf_rpc_decode_uint(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1664,16 +1641,15 @@ static void bt_gatt_unsubscribe_rpc_handler(const struct nrf_rpc_group *group, result = -EINVAL; } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_GATT_UNSUBSCRIBE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_gatt_unsubscribe, BT_GATT_UNSUBSCRIBE_RPC_CMD, - bt_gatt_unsubscribe_rpc_handler, NULL); + bt_gatt_unsubscribe_rpc_handler, NULL); static void bt_rpc_gatt_subscribe_flag_update_rpc_handler(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, @@ -1686,11 +1662,11 @@ static void bt_rpc_gatt_subscribe_flag_update_rpc_handler(const struct nrf_rpc_g bool new_container = false; int val; - remote_pointer = ser_decode_uint(ctx); - flags_bit = ser_decode_uint(ctx); - val = ser_decode_int(ctx); + remote_pointer = nrf_rpc_decode_uint(ctx); + flags_bit = nrf_rpc_decode_uint(ctx); + val = nrf_rpc_decode_int(ctx); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } @@ -1711,17 +1687,16 @@ static void bt_rpc_gatt_subscribe_flag_update_rpc_handler(const struct nrf_rpc_g } } - ser_rsp_send_int(group, result); + nrf_rpc_rsp_send_int(group, result); return; decoding_error: report_decoding_error(BT_RPC_GATT_SUBSCRIBE_FLAG_UPDATE_RPC_CMD, handler_data); - } NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_rpc_gatt_subscribe_flag_update, - BT_RPC_GATT_SUBSCRIBE_FLAG_UPDATE_RPC_CMD, bt_rpc_gatt_subscribe_flag_update_rpc_handler, - NULL); + BT_RPC_GATT_SUBSCRIBE_FLAG_UPDATE_RPC_CMD, + bt_rpc_gatt_subscribe_flag_update_rpc_handler, NULL); int bt_rpc_gatt_subscribe_flag_set(struct bt_gatt_subscribe_params *params, uint32_t flags_bit) { diff --git a/subsys/bluetooth/rpc/host/bt_rpc_internal_host.c b/subsys/bluetooth/rpc/host/bt_rpc_internal_host.c index 0da362801b8b..1b611dc2a964 100644 --- a/subsys/bluetooth/rpc/host/bt_rpc_internal_host.c +++ b/subsys/bluetooth/rpc/host/bt_rpc_internal_host.c @@ -13,8 +13,8 @@ #include #include "bt_rpc_common.h" -#include "serialize.h" -#include "cbkproxy.h" +#include +#include #include @@ -34,15 +34,15 @@ static void bt_addr_le_is_bonded_rpc_handler(const struct nrf_rpc_group *group, uint8_t id; bool result; - id = ser_decode_uint(ctx); - addr = ser_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); + id = nrf_rpc_decode_uint(ctx); + addr = nrf_rpc_decode_buffer(ctx, &addr_data, sizeof(bt_addr_le_t)); - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } result = bt_addr_le_is_bonded(id, addr); - ser_rsp_send_bool(group, result); + nrf_rpc_rsp_send_bool(group, result); return; @@ -53,12 +53,12 @@ static void bt_addr_le_is_bonded_rpc_handler(const struct nrf_rpc_group *group, NRF_RPC_CBOR_CMD_DECODER(bt_rpc_grp, bt_addr_le_is_bonded, BT_ADDR_LE_IS_BONDED_CMD, bt_addr_le_is_bonded_rpc_handler, NULL); -static void decode_net_buf(struct ser_scratchpad *scratchpad, struct net_buf *data) +static void decode_net_buf(struct nrf_rpc_scratchpad *scratchpad, struct net_buf *data) { size_t len; void *buf; - buf = ser_decode_buffer_into_scratchpad(scratchpad, &len); + buf = nrf_rpc_decode_buffer_into_scratchpad(scratchpad, &len); net_buf_add_mem(data, buf, len); } @@ -72,14 +72,14 @@ static void bt_hci_cmd_send_sync_rsp(const struct nrf_rpc_group *group, int resu buffer_size_max += (rsp == NULL) ? 1 : (3 + rsp->len); NRF_RPC_CBOR_ALLOC(group, ctx, buffer_size_max); - ser_encode_int(&ctx, result); + nrf_rpc_encode_int(&ctx, result); if (rsp == NULL) { - ser_encode_null(&ctx); + nrf_rpc_encode_null(&ctx); } else { - scratchpad_size = SCRATCHPAD_ALIGN(rsp->len); - ser_encode_uint(&ctx, scratchpad_size); - ser_encode_buffer(&ctx, rsp->data, rsp->len); + scratchpad_size = NRF_RPC_SCRATCHPAD_ALIGN(rsp->len); + nrf_rpc_encode_uint(&ctx, scratchpad_size); + nrf_rpc_encode_buffer(&ctx, rsp->data, rsp->len); } nrf_rpc_cbor_rsp_no_err(group, &ctx); @@ -93,17 +93,17 @@ static void bt_hci_cmd_send_sync_rpc_handler(const struct nrf_rpc_group *group, size_t len; struct net_buf *buf = NULL; struct net_buf *rsp = NULL; - struct ser_scratchpad scratchpad; + struct nrf_rpc_scratchpad scratchpad; bool response; - opcode = ser_decode_uint(ctx); + opcode = nrf_rpc_decode_uint(ctx); - if (ser_decode_is_null(ctx)) { - ser_decode_skip(ctx); + if (nrf_rpc_decode_is_null(ctx)) { + nrf_rpc_decode_skip(ctx); buf = NULL; } else { - SER_SCRATCHPAD_DECLARE(&scratchpad, ctx); - len = ser_decode_uint(ctx); + NRF_RPC_SCRATCHPAD_DECLARE(&scratchpad, ctx); + len = nrf_rpc_decode_uint(ctx); buf = bt_hci_cmd_create(opcode, len); if (!buf) { ret = -ENOBUFS; @@ -112,14 +112,14 @@ static void bt_hci_cmd_send_sync_rpc_handler(const struct nrf_rpc_group *group, } } - if (ser_decode_is_null(ctx)) { + if (nrf_rpc_decode_is_null(ctx)) { /* The caller is not interested in the response. */ response = false; } else { response = true; } - if (!ser_decoding_done_and_check(group, ctx)) { + if (!nrf_rpc_decoding_done_and_check(group, ctx)) { goto decoding_error; } diff --git a/subsys/nrf_rpc/CMakeLists.txt b/subsys/nrf_rpc/CMakeLists.txt index 494ccd4af60c..ad6bc2e98724 100644 --- a/subsys/nrf_rpc/CMakeLists.txt +++ b/subsys/nrf_rpc/CMakeLists.txt @@ -9,4 +9,9 @@ zephyr_include_directories(include) zephyr_library() zephyr_library_sources(nrf_rpc_os.c) + zephyr_library_sources_ifdef(CONFIG_NRF_RPC_IPC_SERVICE nrf_rpc_ipc.c) + +zephyr_library_sources_ifdef(CONFIG_NRF_RPC_SERIALIZE_API nrf_rpc_serialize.c) + +zephyr_library_sources_ifdef(CONFIG_NRF_RPC_CALLBACK_PROXY nrf_rpc_cbkproxy.c) diff --git a/subsys/nrf_rpc/Kconfig b/subsys/nrf_rpc/Kconfig index 942690799c9f..047df46b7a39 100644 --- a/subsys/nrf_rpc/Kconfig +++ b/subsys/nrf_rpc/Kconfig @@ -64,6 +64,45 @@ config NRF_RPC_THREAD_PRIORITY help Thread priority of each thread in local thread pool. +config NRF_RPC_SERIALIZE_API + bool "API for serialization" + default y + help + API for serialization and deserialization of several major CBOR types. + +config NRF_RPC_CALLBACK_PROXY + bool "Proxy functionality for remote callbacks" + default y + help + Proxy functionality that allows to register callbacks on the local side + and to match the invoked callbacks on the remote side to registered + callbacks on the local side. + +if NRF_RPC_CALLBACK_PROXY + +config NRF_RPC_CBKPROXY_OUT_SLOTS + int "Maximum number of RPC callback proxy output slots" + default 16 + range 0 16383 + help + Output slot is used to save context for one callback that is called + on local side, encoded, sent and finally executed on the remote side. + Each output slot takes 8 bytes of flash memory. Maximum number of + input slots on the remote side should be the same as this value. + + +config NRF_RPC_CBKPROXY_IN_SLOTS + int "Maximum number of RPC callback proxy input slots" + default 16 + range 0 16383 + help + Input slot is used to save context for one callback that is called + on remote side, encoded, sent and finally executed on the local side. + Each output slot takes 8 bytes of RAM memory. Maximum number of + output slots on the remote side should be the same as this value. + +endif # NRF_RPC_CALLBACK_PROXY + module = NRF_RPC module-str = NRF_RPC source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" diff --git a/subsys/bluetooth/rpc/common/cbkproxy.c b/subsys/nrf_rpc/nrf_rpc_cbkproxy.c similarity index 69% rename from subsys/bluetooth/rpc/common/cbkproxy.c rename to subsys/nrf_rpc/nrf_rpc_cbkproxy.c index 500fbd1fd450..6fd07f11b024 100644 --- a/subsys/bluetooth/rpc/common/cbkproxy.c +++ b/subsys/nrf_rpc/nrf_rpc_cbkproxy.c @@ -9,19 +9,19 @@ #include -#include "cbkproxy.h" +#include static K_MUTEX_DEFINE(mutex); -#if CONFIG_CBKPROXY_OUT_SLOTS > 0 +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS > 0 -#if CONFIG_CBKPROXY_OUT_SLOTS > 16383 +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS > 16383 #error "Too many callback proxy output slots" #endif #if __ARM_ARCH != 8 || __ARM_ARCH_ISA_THUMB != 2 || !defined(__GNUC__) #error Callback proxy output is implemented only for Cortex-M33 and GCC. \ - Set CONFIG_CBKPROXY_OUT_SLOTS to 0 to disable them. + Set CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS to 0 to disable them. #endif #define TABLE_ENTRY1 \ @@ -43,52 +43,52 @@ static K_MUTEX_DEFINE(mutex); #define TABLE_ENTRY4096 TABLE_ENTRY2048 TABLE_ENTRY2048 #define TABLE_ENTRY8192 TABLE_ENTRY4096 TABLE_ENTRY4096 -static void *out_callbacks[CONFIG_CBKPROXY_OUT_SLOTS]; +static void *out_callbacks[CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS]; __attribute__((naked)) static void callback_jump_table_start(void) { __asm volatile ( -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(0) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(0) TABLE_ENTRY1 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(1) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(1) TABLE_ENTRY2 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(2) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(2) TABLE_ENTRY4 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(3) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(3) TABLE_ENTRY8 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(4) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(4) TABLE_ENTRY16 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(5) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(5) TABLE_ENTRY32 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(6) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(6) TABLE_ENTRY64 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(7) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(7) TABLE_ENTRY128 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(8) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(8) TABLE_ENTRY256 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(9) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(9) TABLE_ENTRY512 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(10) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(10) TABLE_ENTRY1024 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(11) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(11) TABLE_ENTRY2048 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(12) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(12) TABLE_ENTRY4096 #endif -#if CONFIG_CBKPROXY_OUT_SLOTS & BIT(13) +#if CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS & BIT(13) TABLE_ENTRY8192 #endif ".L%=callback_jump_table_end:\n" @@ -111,11 +111,11 @@ static void callback_jump_table_start(void) ); } -void *cbkproxy_out_get(int index, void *handler) +void *nrf_rpc_cbkproxy_out_get(int index, void *handler) { uint32_t addr; - if (index >= CONFIG_CBKPROXY_OUT_SLOTS || index < 0) { + if (index >= CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS || index < 0) { return NULL; } else if (!out_callbacks[index]) { out_callbacks[index] = handler; @@ -130,23 +130,23 @@ void *cbkproxy_out_get(int index, void *handler) } #else -void *cbkproxy_out_get(int index, void *handler) +void *nrf_rpc_cbkproxy_out_get(int index, void *handler) { return NULL; } -#endif /* CONFIG_CBKPROXY_OUT_SLOTS > 0 */ +#endif /* CONFIG_NRF_RPC_CBKPROXY_OUT_SLOTS > 0 */ -#if CONFIG_CBKPROXY_IN_SLOTS > 0 +#if CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS > 0 static struct { intptr_t callback; uint16_t gt; uint16_t lt; -} in_slots[CONFIG_CBKPROXY_IN_SLOTS]; +} in_slots[CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS]; static uint32_t next_free_in_slot; -int cbkproxy_in_set(void *callback) +int nrf_rpc_cbkproxy_in_set(void *callback) { int index = 0; uint16_t *attach_to = NULL; @@ -171,7 +171,7 @@ int cbkproxy_in_set(void *callback) } if (attach_to) { - if (next_free_in_slot >= CONFIG_CBKPROXY_IN_SLOTS) { + if (next_free_in_slot >= CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS) { index = -1; } else { index = next_free_in_slot; @@ -188,7 +188,7 @@ int cbkproxy_in_set(void *callback) return index; } -void *cbkproxy_in_get(int index) +void *nrf_rpc_cbkproxy_in_get(int index) { if ((index >= next_free_in_slot) || (index < 0)) { return NULL; @@ -198,13 +198,13 @@ void *cbkproxy_in_get(int index) } #else -int cbkproxy_in_set(void *callback) +int nrf_rpc_cbkproxy_in_set(void *callback) { return -1; } -void *cbkproxy_in_get(int index) +void *nrf_rpc_cbkproxy_in_get(int index) { return NULL; } -#endif /* CONFIG_CBKPROXY_IN_SLOTS > 0 */ +#endif /* CONFIG_NRF_RPC_CBKPROXY_IN_SLOTS > 0 */ diff --git a/subsys/bluetooth/rpc/common/serialize.c b/subsys/nrf_rpc/nrf_rpc_serialize.c similarity index 62% rename from subsys/bluetooth/rpc/common/serialize.c rename to subsys/nrf_rpc/nrf_rpc_serialize.c index bad512b2fea9..f44b2ea807ce 100644 --- a/subsys/bluetooth/rpc/common/serialize.c +++ b/subsys/nrf_rpc/nrf_rpc_serialize.c @@ -5,8 +5,8 @@ */ #include -#include "cbkproxy.h" -#include "serialize.h" +#include +#include static inline bool is_decoder_invalid(const struct nrf_rpc_cbor_ctx *ctx) { @@ -14,7 +14,7 @@ static inline bool is_decoder_invalid(const struct nrf_rpc_cbor_ctx *ctx) return !zcbor_check_error(ctx->zs); } -void ser_decoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err) +void nrf_rpc_decoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err) { zcbor_error(ctx->zs, err); } @@ -29,12 +29,12 @@ static void set_encoder_invalid(struct nrf_rpc_cbor_ctx *ctx, int err) zcbor_error(ctx->zs, err); } -void ser_encoder_invalid(struct nrf_rpc_cbor_ctx *ctx) +void nrf_rpc_encoder_invalid(struct nrf_rpc_cbor_ctx *ctx) { zcbor_error(ctx->zs, ZCBOR_ERR_UNKNOWN); } -bool ser_decode_valid(const struct nrf_rpc_cbor_ctx *ctx) +bool nrf_rpc_decode_valid(const struct nrf_rpc_cbor_ctx *ctx) { return !is_decoder_invalid(ctx); } @@ -43,37 +43,37 @@ static void check_final_decode_valid(const struct nrf_rpc_group *group, const struct nrf_rpc_cbor_ctx *ctx) { if (is_decoder_invalid(ctx)) { - nrf_rpc_err(-EBADMSG, NRF_RPC_ERR_SRC_RECV, group, - NRF_RPC_ID_UNKNOWN, NRF_RPC_PACKET_TYPE_RSP); + nrf_rpc_err(-EBADMSG, NRF_RPC_ERR_SRC_RECV, group, NRF_RPC_ID_UNKNOWN, + NRF_RPC_PACKET_TYPE_RSP); } } -void ser_encode_null(struct nrf_rpc_cbor_ctx *ctx) +void nrf_rpc_encode_null(struct nrf_rpc_cbor_ctx *ctx) { zcbor_nil_put(ctx->zs, NULL); } -void ser_encode_undefined(struct nrf_rpc_cbor_ctx *ctx) +void nrf_rpc_encode_undefined(struct nrf_rpc_cbor_ctx *ctx) { zcbor_undefined_put(ctx->zs, NULL); } -void ser_encode_bool(struct nrf_rpc_cbor_ctx *ctx, bool value) +void nrf_rpc_encode_bool(struct nrf_rpc_cbor_ctx *ctx, bool value) { zcbor_bool_put(ctx->zs, value); } -void ser_encode_uint(struct nrf_rpc_cbor_ctx *ctx, uint32_t value) +void nrf_rpc_encode_uint(struct nrf_rpc_cbor_ctx *ctx, uint32_t value) { zcbor_uint32_put(ctx->zs, value); } -void ser_encode_int(struct nrf_rpc_cbor_ctx *ctx, int32_t value) +void nrf_rpc_encode_int(struct nrf_rpc_cbor_ctx *ctx, int32_t value) { zcbor_int32_put(ctx->zs, value); } -void ser_encode_str(struct nrf_rpc_cbor_ctx *ctx, const char *value, int len) +void nrf_rpc_encode_str(struct nrf_rpc_cbor_ctx *ctx, const char *value, int len) { if (!value) { zcbor_nil_put(ctx->zs, NULL); @@ -85,7 +85,7 @@ void ser_encode_str(struct nrf_rpc_cbor_ctx *ctx, const char *value, int len) } } -void ser_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t size) +void nrf_rpc_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t size) { if (!data) { zcbor_nil_put(ctx->zs, NULL); @@ -94,7 +94,7 @@ void ser_encode_buffer(struct nrf_rpc_cbor_ctx *ctx, const void *data, size_t si } } -void ser_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback) +void nrf_rpc_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback) { int slot; @@ -105,7 +105,7 @@ void ser_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback) if (!callback) { zcbor_nil_put(ctx->zs, NULL); } else { - slot = cbkproxy_in_set(callback); + slot = nrf_rpc_cbkproxy_in_set(callback); if (slot < 0) { set_encoder_invalid(ctx, ZCBOR_ERR_UNKNOWN); } else { @@ -114,12 +114,12 @@ void ser_encode_callback(struct nrf_rpc_cbor_ctx *ctx, void *callback) } } -void ser_decode_skip(struct nrf_rpc_cbor_ctx *ctx) +void nrf_rpc_decode_skip(struct nrf_rpc_cbor_ctx *ctx) { zcbor_any_skip(ctx->zs, NULL); } -bool ser_decode_is_null(struct nrf_rpc_cbor_ctx *ctx) +bool nrf_rpc_decode_is_null(struct nrf_rpc_cbor_ctx *ctx) { if (is_encoder_invalid(ctx)) { return false; @@ -136,7 +136,7 @@ bool ser_decode_is_null(struct nrf_rpc_cbor_ctx *ctx) return false; } -bool ser_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx) +bool nrf_rpc_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx) { if (is_encoder_invalid(ctx)) { return false; @@ -153,7 +153,7 @@ bool ser_decode_is_undefined(struct nrf_rpc_cbor_ctx *ctx) return false; } -bool ser_decode_bool(struct nrf_rpc_cbor_ctx *ctx) +bool nrf_rpc_decode_bool(struct nrf_rpc_cbor_ctx *ctx) { bool result; @@ -164,7 +164,7 @@ bool ser_decode_bool(struct nrf_rpc_cbor_ctx *ctx) return false; } -uint32_t ser_decode_uint(struct nrf_rpc_cbor_ctx *ctx) +uint32_t nrf_rpc_decode_uint(struct nrf_rpc_cbor_ctx *ctx) { uint32_t result; @@ -175,7 +175,7 @@ uint32_t ser_decode_uint(struct nrf_rpc_cbor_ctx *ctx) return 0; } -int32_t ser_decode_int(struct nrf_rpc_cbor_ctx *ctx) +int32_t nrf_rpc_decode_int(struct nrf_rpc_cbor_ctx *ctx) { int32_t result; @@ -186,9 +186,9 @@ int32_t ser_decode_int(struct nrf_rpc_cbor_ctx *ctx) return 0; } -void *ser_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffer_size) +void *nrf_rpc_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffer_size) { - struct zcbor_string zst = { 0 }; + struct zcbor_string zst = {0}; if (is_decoder_invalid(ctx)) { return NULL; @@ -217,9 +217,9 @@ void *ser_decode_buffer(struct nrf_rpc_cbor_ctx *ctx, void *buffer, size_t buffe return buffer; } -const void *ser_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t *size) +const void *nrf_rpc_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t *size) { - struct zcbor_string zst = { 0 }; + struct zcbor_string zst = {0}; if (is_decoder_invalid(ctx)) { return NULL; @@ -243,7 +243,7 @@ const void *ser_decode_buffer_ptr_and_size(struct nrf_rpc_cbor_ctx *ctx, size_t return zst.value; } -char *ser_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_size) +char *nrf_rpc_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_size) { struct zcbor_string zst; @@ -279,7 +279,7 @@ char *ser_decode_str(struct nrf_rpc_cbor_ctx *ctx, char *buffer, size_t buffer_s return buffer; } -char *ser_decode_str_into_scratchpad(struct ser_scratchpad *scratchpad, size_t *len) +char *nrf_rpc_decode_str_into_scratchpad(struct nrf_rpc_scratchpad *scratchpad, size_t *len) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; struct zcbor_string zst; @@ -305,7 +305,7 @@ char *ser_decode_str_into_scratchpad(struct ser_scratchpad *scratchpad, size_t * } /* Reserve place for string and a string NULL terminator. */ - result = (char *)ser_scratchpad_add(scratchpad, (zst.len + 1)); + result = (char *)nrf_rpc_scratchpad_add(scratchpad, (zst.len + 1)); if (!result) { err = ZCBOR_ERR_UNKNOWN; goto error_exit; @@ -322,11 +322,11 @@ char *ser_decode_str_into_scratchpad(struct ser_scratchpad *scratchpad, size_t * return result; error_exit: - ser_decoder_invalid(ctx, err); + nrf_rpc_decoder_invalid(ctx, err); return NULL; } -void *ser_decode_buffer_into_scratchpad(struct ser_scratchpad *scratchpad, size_t *len) +void *nrf_rpc_decode_buffer_into_scratchpad(struct nrf_rpc_scratchpad *scratchpad, size_t *len) { struct nrf_rpc_cbor_ctx *ctx = scratchpad->ctx; struct zcbor_string zst; @@ -351,7 +351,7 @@ void *ser_decode_buffer_into_scratchpad(struct ser_scratchpad *scratchpad, size_ return NULL; } - result = (char *)ser_scratchpad_add(scratchpad, zst.len); + result = (char *)nrf_rpc_scratchpad_add(scratchpad, zst.len); if (!result) { err = ZCBOR_ERR_UNKNOWN; goto error_exit; @@ -366,23 +366,23 @@ void *ser_decode_buffer_into_scratchpad(struct ser_scratchpad *scratchpad, size_ return result; error_exit: - ser_decoder_invalid(ctx, err); + nrf_rpc_decoder_invalid(ctx, err); return NULL; } -void *ser_decode_callback_call(struct nrf_rpc_cbor_ctx *ctx) +void *nrf_rpc_decode_callback_call(struct nrf_rpc_cbor_ctx *ctx) { - int slot = ser_decode_uint(ctx); - void *result = cbkproxy_in_get(slot); + int slot = nrf_rpc_decode_uint(ctx); + void *result = nrf_rpc_cbkproxy_in_get(slot); if (!result) { - ser_decoder_invalid(ctx, ZCBOR_ERR_WRONG_TYPE); + nrf_rpc_decoder_invalid(ctx, ZCBOR_ERR_WRONG_TYPE); } return result; } -void *ser_decode_callback(struct nrf_rpc_cbor_ctx *ctx, void *handler) +void *nrf_rpc_decode_callbackd(struct nrf_rpc_cbor_ctx *ctx, void *handler) { int err = ZCBOR_ERR_WRONG_TYPE; int slot; @@ -406,7 +406,7 @@ void *ser_decode_callback(struct nrf_rpc_cbor_ctx *ctx, void *handler) return NULL; } - result = cbkproxy_out_get(slot, handler); + result = nrf_rpc_cbkproxy_out_get(slot, handler); if (!result) { err = ZCBOR_ERR_UNKNOWN; goto error_exit; @@ -415,82 +415,83 @@ void *ser_decode_callback(struct nrf_rpc_cbor_ctx *ctx, void *handler) return result; error_exit: - ser_decoder_invalid(ctx, err); + nrf_rpc_decoder_invalid(ctx, err); return NULL; } -bool ser_decoding_done_and_check(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx) +bool nrf_rpc_decoding_done_and_check(const struct nrf_rpc_group *group, + struct nrf_rpc_cbor_ctx *ctx) { nrf_rpc_cbor_decoding_done(group, ctx); return !is_decoder_invalid(ctx); } -void ser_rsp_decode_i32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) +void nrf_rpc_rsp_decode_i32(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data) { - *(int32_t *)handler_data = ser_decode_int(ctx); + *(int32_t *)handler_data = nrf_rpc_decode_int(ctx); check_final_decode_valid(group, ctx); } -void ser_rsp_decode_bool(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) +void nrf_rpc_rsp_decode_bool(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data) { - *(bool *)handler_data = ser_decode_bool(ctx); + *(bool *)handler_data = nrf_rpc_decode_bool(ctx); check_final_decode_valid(group, ctx); } -void ser_rsp_decode_u8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) +void nrf_rpc_rsp_decode_u8(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data) { - *(uint8_t *)handler_data = ser_decode_int(ctx); + *(uint8_t *)handler_data = nrf_rpc_decode_int(ctx); check_final_decode_valid(group, ctx); } -void ser_rsp_decode_u16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) +void nrf_rpc_rsp_decode_u16(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data) { - *(uint16_t *)handler_data = ser_decode_int(ctx); + *(uint16_t *)handler_data = nrf_rpc_decode_int(ctx); check_final_decode_valid(group, ctx); } -void ser_rsp_decode_void(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, - void *handler_data) +void nrf_rpc_rsp_decode_void(const struct nrf_rpc_group *group, struct nrf_rpc_cbor_ctx *ctx, + void *handler_data) { ARG_UNUSED(ctx); ARG_UNUSED(handler_data); } -void ser_rsp_send_int(const struct nrf_rpc_group *group, int32_t response) +void nrf_rpc_rsp_send_int(const struct nrf_rpc_group *group, int32_t response) { struct nrf_rpc_cbor_ctx ctx; NRF_RPC_CBOR_ALLOC(group, ctx, 1 + sizeof(int32_t)); - ser_encode_int(&ctx, response); + nrf_rpc_encode_int(&ctx, response); nrf_rpc_cbor_rsp_no_err(group, &ctx); } -void ser_rsp_send_uint(const struct nrf_rpc_group *group, uint32_t response) +void nrf_rpc_rsp_send_uint(const struct nrf_rpc_group *group, uint32_t response) { struct nrf_rpc_cbor_ctx ctx; NRF_RPC_CBOR_ALLOC(group, ctx, 1 + sizeof(uint32_t)); - ser_encode_uint(&ctx, response); + nrf_rpc_encode_uint(&ctx, response); nrf_rpc_cbor_rsp_no_err(group, &ctx); } -void ser_rsp_send_bool(const struct nrf_rpc_group *group, bool response) +void nrf_rpc_rsp_send_bool(const struct nrf_rpc_group *group, bool response) { struct nrf_rpc_cbor_ctx ctx; NRF_RPC_CBOR_ALLOC(group, ctx, 1); - ser_encode_bool(&ctx, response); + nrf_rpc_encode_bool(&ctx, response); nrf_rpc_cbor_rsp_no_err(group, &ctx); } -void ser_rsp_send_void(const struct nrf_rpc_group *group) +void nrf_rpc_rsp_send_void(const struct nrf_rpc_group *group) { struct nrf_rpc_cbor_ctx ctx;