Skip to content

Commit

Permalink
nrf: rpc: move serializer and callback proxy to nrf rpc
Browse files Browse the repository at this point in the history
Commit moves serialize and callback proxy functionality
from bluetooth rpc to nrf rpc to make it available for
the other.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
  • Loading branch information
alxelax authored and nordicjm committed Jul 16, 2024
1 parent 257c99a commit 3913864
Show file tree
Hide file tree
Showing 22 changed files with 1,918 additions and 1,969 deletions.
6 changes: 3 additions & 3 deletions doc/nrf/libraries/bluetooth_services/rpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h>

#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(...) \
Expand Down Expand Up @@ -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)
Expand All @@ -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.
*
Expand All @@ -139,14 +146,20 @@ 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.
*
* @param index Slot index.
*
* @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 */
Loading

0 comments on commit 3913864

Please sign in to comment.