Bluetooth: Mesh: Add support for clearing persistent network storage
Add support for clearing all data that's currently supported to be persistently stored. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
cc3830f8ed
commit
31afd18977
5 changed files with 68 additions and 0 deletions
|
@ -521,6 +521,10 @@ void bt_mesh_app_key_del(struct bt_mesh_app_key *key)
|
||||||
{
|
{
|
||||||
bt_mesh_model_foreach(_mod_unbind, &key->app_idx);
|
bt_mesh_model_foreach(_mod_unbind, &key->app_idx);
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
|
bt_mesh_clear_app_key(key);
|
||||||
|
}
|
||||||
|
|
||||||
key->net_idx = BT_MESH_KEY_UNUSED;
|
key->net_idx = BT_MESH_KEY_UNUSED;
|
||||||
memset(key->keys, 0, sizeof(key->keys));
|
memset(key->keys, 0, sizeof(key->keys));
|
||||||
}
|
}
|
||||||
|
@ -3291,6 +3295,10 @@ void bt_mesh_subnet_del(struct bt_mesh_subnet *sub)
|
||||||
bt_mesh_friend_clear_net_idx(sub->net_idx);
|
bt_mesh_friend_clear_net_idx(sub->net_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
|
bt_mesh_clear_subnet(sub);
|
||||||
|
}
|
||||||
|
|
||||||
memset(sub, 0, sizeof(*sub));
|
memset(sub, 0, sizeof(*sub));
|
||||||
sub->net_idx = BT_MESH_KEY_UNUSED;
|
sub->net_idx = BT_MESH_KEY_UNUSED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,10 @@ void bt_mesh_reset(void)
|
||||||
bt_mesh_proxy_gatt_disable();
|
bt_mesh_proxy_gatt_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
|
bt_mesh_clear_net();
|
||||||
|
}
|
||||||
|
|
||||||
memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key));
|
memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key));
|
||||||
|
|
||||||
memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
|
memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
|
||||||
|
|
|
@ -683,6 +683,53 @@ void bt_mesh_store_app_key(struct bt_mesh_app_key *app)
|
||||||
settings_save_one(path, str);
|
settings_save_one(path, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bt_mesh_clear_net(void)
|
||||||
|
{
|
||||||
|
BT_DBG("");
|
||||||
|
|
||||||
|
settings_save_one("bt/mesh/IV", NULL);
|
||||||
|
settings_save_one("bt/mesh/Net", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bt_mesh_clear_subnet(struct bt_mesh_subnet *sub)
|
||||||
|
{
|
||||||
|
char path[20];
|
||||||
|
|
||||||
|
BT_DBG("NetKeyIndex 0x%03x", sub->net_idx);
|
||||||
|
|
||||||
|
snprintk(path, sizeof(path), "bt/mesh/NetKey/%x", sub->net_idx);
|
||||||
|
settings_save_one(path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bt_mesh_clear_app_key(struct bt_mesh_app_key *key)
|
||||||
|
{
|
||||||
|
char path[20];
|
||||||
|
|
||||||
|
BT_DBG("AppKeyIndex 0x%03x", key->app_idx);
|
||||||
|
|
||||||
|
snprintk(path, sizeof(path), "bt/mesh/AppKey/%x", key->app_idx);
|
||||||
|
settings_save_one(path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bt_mesh_clear_rpl(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
BT_DBG("");
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) {
|
||||||
|
struct bt_mesh_rpl *rpl = &bt_mesh.rpl[i];
|
||||||
|
char path[18];
|
||||||
|
|
||||||
|
if (!rpl->src) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintk(path, sizeof(path), "bt/mesh/RPL/%x", rpl->src);
|
||||||
|
settings_save_one(path, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void bt_mesh_settings_init(void)
|
void bt_mesh_settings_init(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_BT_MESH_RPL_STORE_TIMEOUT > 0
|
#if CONFIG_BT_MESH_RPL_STORE_TIMEOUT > 0
|
||||||
|
|
|
@ -11,4 +11,9 @@ void bt_mesh_store_rpl(struct bt_mesh_rpl *rpl);
|
||||||
void bt_mesh_store_subnet(struct bt_mesh_subnet *sub);
|
void bt_mesh_store_subnet(struct bt_mesh_subnet *sub);
|
||||||
void bt_mesh_store_app_key(struct bt_mesh_app_key *key);
|
void bt_mesh_store_app_key(struct bt_mesh_app_key *key);
|
||||||
|
|
||||||
|
void bt_mesh_clear_net(void);
|
||||||
|
void bt_mesh_clear_subnet(struct bt_mesh_subnet *sub);
|
||||||
|
void bt_mesh_clear_app_key(struct bt_mesh_app_key *key);
|
||||||
|
void bt_mesh_clear_rpl(void);
|
||||||
|
|
||||||
void bt_mesh_settings_init(void);
|
void bt_mesh_settings_init(void);
|
||||||
|
|
|
@ -1411,6 +1411,10 @@ void bt_mesh_rx_reset(void)
|
||||||
for (i = 0; i < ARRAY_SIZE(seg_rx); i++) {
|
for (i = 0; i < ARRAY_SIZE(seg_rx); i++) {
|
||||||
seg_rx_reset(&seg_rx[i], true);
|
seg_rx_reset(&seg_rx[i], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
|
bt_mesh_clear_rpl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_mesh_tx_reset(void)
|
void bt_mesh_tx_reset(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue