mesh: Remove redundant 'provisioned' variable
This variable is both redundant as well as problematic when it comes
to adding persistent-storage-based provisioning information, which
will not come through main.c or the bt_mesh_provision() API. Just
remove it and use bt_mesh.valid which serves the same purpose in
practice.
#include "settings.h"
u8_t g_mesh_addr_type;
-static bool provisioned;
int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
u8_t flags, u32_t iv_index, u32_t seq,
@@ -62,8 +61,6 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
memcpy(bt_mesh.dev_key, dev_key, 16);
- provisioned = true;
-
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
BT_DBG("Storing network information persistently");
bt_mesh_store_net(addr, dev_key);
@@ -102,7 +99,7 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
void bt_mesh_reset(void)
{
- if (!provisioned) {
+ if (!bt_mesh.valid) {
return;
}
@@ -143,8 +140,6 @@ void bt_mesh_reset(void)
memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
- provisioned = false;
-
bt_mesh_scan_disable();
bt_mesh_beacon_disable();
@@ -155,7 +150,7 @@ void bt_mesh_reset(void)
bool bt_mesh_is_provisioned(void)
{
- return provisioned;
+ return bt_mesh.valid;
}
int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers)
