Bluetooth: Mesh: Fix calling complete callback for bt_mesh_provision()

If the app does direct provisioning, it may still want to do common
handling through its provisioning complete callback (if it has one
registered). This also means that we always require a non-NULL
provisioning context provided to bt_enable(), and that it needs to
fail if NULL was given.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-11-14 18:45:32 +02:00 committed by Johan Hedberg
commit 2d40c1673c
3 changed files with 18 additions and 6 deletions

View file

@ -89,6 +89,10 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
bt_mesh_friend_init();
}
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
bt_mesh_prov_complete(net_idx, addr);
}
return 0;
}

View file

@ -1049,10 +1049,6 @@ static void prov_data(const u8_t *data)
link.expect = 0;
bt_mesh_provision(pdu, net_idx, flags, iv_index, 0, addr, dev_key);
if (prov->complete) {
prov->complete(net_idx, addr);
}
}
static void prov_complete(const u8_t *data)
@ -1523,11 +1519,15 @@ bool bt_prov_active(void)
int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
{
int err;
static struct bt_pub_key_cb pub_key_cb = {
.func = pub_key_ready,
};
int err;
if (!prov_info) {
BT_ERR("No provisioning context provided");
return -EINVAL;
}
err = bt_pub_key_gen(&pub_key_cb);
if (err) {
@ -1559,6 +1559,13 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
return 0;
}
void bt_mesh_prov_complete(u16_t net_idx, u16_t addr)
{
if (prov->complete) {
prov->complete(net_idx, addr);
}
}
void bt_mesh_prov_reset(void)
{
if (prov->reset) {

View file

@ -18,4 +18,5 @@ const u8_t *bt_mesh_prov_get_uuid(void);
int bt_mesh_prov_init(const struct bt_mesh_prov *prov);
void bt_mesh_prov_complete(u16_t net_idx, u16_t addr);
void bt_mesh_prov_reset(void);