ble_mesh: fix provisioner not init mutex
This commit is contained in:
@@ -258,9 +258,9 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
err = provisioner_upper_init();
|
||||
err = bt_mesh_provisioner_net_create();
|
||||
if (err) {
|
||||
BT_ERR("%s, provisioner_upper_init fail", __func__);
|
||||
BT_ERR("%s, bt_mesh_provisioner_net_create fail", __func__);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -476,18 +476,13 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER)) {
|
||||
bt_mesh_provisioner_init();
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
bt_mesh_settings_init();
|
||||
}
|
||||
|
||||
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
|
||||
/* If node & provisioner are both enabled and the
|
||||
* device starts as a node, it must finish provisioning */
|
||||
err = provisioner_upper_init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ static osi_mutex_t provisioner_mutex;
|
||||
static u16_t all_node_count;
|
||||
static u16_t prov_node_count;
|
||||
|
||||
static bool prov_upper_init = false;
|
||||
static bool prov_net_create = false;
|
||||
|
||||
void bt_mesh_provisioner_mutex_new(void)
|
||||
static void bt_mesh_provisioner_mutex_new(void)
|
||||
{
|
||||
if (!provisioner_mutex) {
|
||||
osi_mutex_new(&provisioner_mutex);
|
||||
@@ -303,7 +303,14 @@ int provisioner_reset_all_nodes(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int provisioner_upper_init(void)
|
||||
int bt_mesh_provisioner_init(void)
|
||||
{
|
||||
bt_mesh_provisioner_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_provisioner_net_create(void)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u8_t p_key[16] = {0};
|
||||
@@ -311,7 +318,7 @@ int provisioner_upper_init(void)
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (prov_upper_init) {
|
||||
if (prov_net_create) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -393,13 +400,11 @@ int provisioner_upper_init(void)
|
||||
}
|
||||
|
||||
end:
|
||||
prov_upper_init = true;
|
||||
prov_net_create = true;
|
||||
|
||||
BT_DBG("net_idx 0x%03x, netkey %s, nid 0x%02x",
|
||||
sub->net_idx, bt_hex(sub->keys[0].net, 16), sub->keys[0].nid);
|
||||
|
||||
bt_mesh_provisioner_mutex_new();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@ struct bt_mesh_node_t {
|
||||
|
||||
/* The following APIs are for key init, node provision & node reset. */
|
||||
|
||||
void bt_mesh_provisioner_mutex_new(void);
|
||||
|
||||
u16_t provisioner_get_prov_node_count(void);
|
||||
|
||||
u16_t provisioner_get_node_count(void);
|
||||
@@ -54,7 +52,9 @@ bool provisioner_find_reset_node_with_addr(const bt_mesh_addr_t *addr, bool rese
|
||||
|
||||
int provisioner_reset_all_nodes(void);
|
||||
|
||||
int provisioner_upper_init(void);
|
||||
int bt_mesh_provisioner_init(void);
|
||||
|
||||
int bt_mesh_provisioner_net_create(void);
|
||||
|
||||
/* The following APIs are for provisioner upper layers internal usage. */
|
||||
|
||||
|
||||
@@ -1115,10 +1115,6 @@ int settings_core_load(void)
|
||||
BT_DBG("Device just starts up");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && dev_role == PROVISIONER) {
|
||||
bt_mesh_provisioner_mutex_new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user