ble_mesh: fix not callback net_key when device is provisioned

This commit is contained in:
lly 2019-10-11 09:51:02 +08:00
parent 66a46de2a7
commit 7d267a340f
6 changed files with 10 additions and 6 deletions

View File

@ -1287,6 +1287,7 @@ typedef union {
*/
struct ble_mesh_provision_complete_evt_param {
uint16_t net_idx; /*!< NetKey Index */
uint8_t net_key[16]; /*!< NetKey */
uint16_t addr; /*!< Primary address */
uint8_t flags; /*!< Flags */
uint32_t iv_index; /*!< IV Index */

View File

@ -522,7 +522,7 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer)
return;
}
static void btc_ble_mesh_complete_cb(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_index)
static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index)
{
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
btc_msg_t msg = {0};
@ -531,6 +531,7 @@ static void btc_ble_mesh_complete_cb(u16_t net_idx, u16_t addr, u8_t flags, u32_
LOG_DEBUG("%s", __func__);
mesh_param.node_prov_complete.net_idx = net_idx;
memcpy(mesh_param.node_prov_complete.net_key, net_key, 16);
mesh_param.node_prov_complete.addr = addr;
mesh_param.node_prov_complete.flags = flags;
mesh_param.node_prov_complete.iv_index = iv_index;

View File

@ -164,11 +164,12 @@ struct bt_mesh_prov {
* assigned the specified NetKeyIndex and primary element address.
*
* @param net_idx NetKeyIndex given during provisioning.
* @param net_key NetKey given during provisioning.
* @param addr Primary element address.
* @param flags Key Refresh & IV Update flags
* @param iv_index IV Index.
*/
void (*complete)(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_index);
void (*complete)(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index);
/** @brief Node has been reset.
*

View File

@ -1476,11 +1476,12 @@ void bt_mesh_net_start(void)
u16_t addr = bt_mesh_primary_addr();
u32_t iv_index = bt_mesh.iv_index;
u8_t flags = (u8_t)bt_mesh.sub[0].kr_flag;
const u8_t *net_key = bt_mesh.sub[0].keys[flags].net;
if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS)) {
flags |= BLE_MESH_NET_FLAG_IVU;
}
bt_mesh_prov_complete(net_idx, addr, flags, iv_index);
bt_mesh_prov_complete(net_idx, net_key, addr, flags, iv_index);
}
}
#endif

View File

@ -1744,10 +1744,10 @@ 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, u8_t flags, u32_t iv_index)
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index)
{
if (prov->complete) {
prov->complete(net_idx, addr, flags, iv_index);
prov->complete(net_idx, net_key, addr, flags, iv_index);
}
}

View File

@ -28,7 +28,7 @@ const struct bt_mesh_prov *bt_mesh_prov_get(void);
int bt_mesh_prov_init(const struct bt_mesh_prov *prov);
void bt_mesh_prov_complete(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_index);
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index);
void bt_mesh_prov_reset(void);
#endif /* _PROV_H_ */