Upon bt_mesh_reset call, all mesh modules has to clear the privisioning and configuration data. None of the modules store or erase in settings subsystem immediately, but put this on the mesh settings work. After the settings work is scheduled, all stored data will be removed and the device will eventually be unprovisioned. Until then, the device is not completely unprovisioned, thus calling bt_mesh_prov_enable, bt_mesh_provision (and bt_mesh_cdb_create) should not be allowed. Struct bt_mesh_prov has a reset callback stating that after this callback is called, the device has been reset and can be re-provisioned again. Also, bt_mesh_reset API description states that after calling bt_mesh_reset API, the device needs to reenable the provisioning layer to be provisioned again. But this is not correct since the settings has to be cleared before the device can be reprovisionined. This commit makes bt_mesh_reset flush pending settings so that the device can be reprovisioned immediately and the API will behave as written in the description. The same applies to bt_mesh_cdb_clear. Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
45 lines
1.4 KiB
C
45 lines
1.4 KiB
C
/*
|
|
* Copyright (c) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/* Pending storage actions. */
|
|
enum bt_mesh_settings_flag {
|
|
BT_MESH_SETTINGS_RPL_PENDING,
|
|
BT_MESH_SETTINGS_NET_KEYS_PENDING,
|
|
BT_MESH_SETTINGS_APP_KEYS_PENDING,
|
|
BT_MESH_SETTINGS_NET_PENDING,
|
|
BT_MESH_SETTINGS_IV_PENDING,
|
|
BT_MESH_SETTINGS_SEQ_PENDING,
|
|
BT_MESH_SETTINGS_HB_PUB_PENDING,
|
|
BT_MESH_SETTINGS_CFG_PENDING,
|
|
BT_MESH_SETTINGS_MOD_PENDING,
|
|
BT_MESH_SETTINGS_VA_PENDING,
|
|
BT_MESH_SETTINGS_CDB_PENDING,
|
|
|
|
BT_MESH_SETTINGS_FLAG_COUNT,
|
|
};
|
|
|
|
#ifdef CONFIG_BT_SETTINGS
|
|
#define BT_MESH_SETTINGS_DEFINE(_hname, _subtree, _set) \
|
|
SETTINGS_STATIC_HANDLER_DEFINE(bt_mesh_##_hname, "bt/mesh/" _subtree, \
|
|
NULL, _set, NULL, NULL)
|
|
#else
|
|
/* Declaring non static settings handler helps avoid unnecessary ifdefs
|
|
* as well as unused function warning. Since the declared handler structure is
|
|
* unused, linker will discard it.
|
|
*/
|
|
#define BT_MESH_SETTINGS_DEFINE(_hname, _subtree, _set)\
|
|
const struct settings_handler settings_handler_bt_mesh_ ## _hname = {\
|
|
.h_set = _set, \
|
|
}
|
|
#endif
|
|
|
|
void bt_mesh_settings_init(void);
|
|
void bt_mesh_settings_store_schedule(enum bt_mesh_settings_flag flag);
|
|
void bt_mesh_settings_store_cancel(enum bt_mesh_settings_flag flag);
|
|
void bt_mesh_settings_store_pending(void);
|
|
int bt_mesh_settings_set(settings_read_cb read_cb, void *cb_arg,
|
|
void *out, size_t read_len);
|