Skip to content

Commit

Permalink
Bluetooth: rpc: Change handling of remote settings initialization
Browse files Browse the repository at this point in the history
The former implementation of settings initialization was based on
a command send by client by rpc_settings_set() function. That function
was called by stetings subsustem during settings_load() execution.
That together created deep execution call stack that required extended
main thread stack size.

To avoid the change to stack size, the implementation is changed,
to send the settings load command to host if CONFIG_SETTINGS is
eanbled. The command is send directly from bt_enable() function
in bt_rpc_gap_client.c.

Signed-off-by: Piotr Pryga <[email protected]>
  • Loading branch information
ppryga-nordic committed Jun 4, 2024
1 parent 07e6f20 commit 009755a
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions subsys/bluetooth/rpc/client/bt_rpc_gap_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,11 @@ int bt_enable(bt_ready_cb_t cb)


if (IS_ENABLED(CONFIG_SETTINGS)) {
int network_load = 1;

result = settings_subsys_init();
if (result) {
return result;
}
buffer_size_max = 0;
NRF_RPC_CBOR_ALLOC(&bt_rpc_grp, ctx, buffer_size_max);

result = settings_save_one("bt_rpc/network",
&network_load, sizeof(network_load));
nrf_rpc_cbor_cmd_no_err(&bt_rpc_grp, BT_SETTINGS_LOAD_RPC_CMD,
&ctx, ser_rsp_decode_void, NULL);
}

return result;
Expand Down Expand Up @@ -2038,32 +2034,3 @@ void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info,
&ctx, ser_rsp_decode_void, NULL);
}
#endif /* (defined(CONFIG_BT_CONN) && defined(CONFIG_BT_SMP)) */

static int rpc_settings_set(const char *key, size_t len_rd, settings_read_cb read_cb,
void *cb_arg)
{
struct nrf_rpc_cbor_ctx ctx;
size_t buffer_size_max = 0;
ssize_t len;
const char *next;

if (!key) {
LOG_ERR("Insufficient number of arguments");
return -ENOENT;
}

len = settings_name_next(key, &next);

if (!strncmp(key, "network", len)) {
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);

}

return 0;
}

SETTINGS_STATIC_HANDLER_DEFINE(bt_gatt_rpc, "bt_rpc", NULL, rpc_settings_set,
NULL, NULL);

0 comments on commit 009755a

Please sign in to comment.