ble_mesh: fix not callback net_key when device is provisioned
This commit is contained in:
parent
673f58fe03
commit
35353de137
6 changed files with 10 additions and 6 deletions
|
@ -1287,6 +1287,7 @@ typedef union {
|
||||||
*/
|
*/
|
||||||
struct ble_mesh_provision_complete_evt_param {
|
struct ble_mesh_provision_complete_evt_param {
|
||||||
uint16_t net_idx; /*!< NetKey Index */
|
uint16_t net_idx; /*!< NetKey Index */
|
||||||
|
uint8_t net_key[16]; /*!< NetKey */
|
||||||
uint16_t addr; /*!< Primary address */
|
uint16_t addr; /*!< Primary address */
|
||||||
uint8_t flags; /*!< Flags */
|
uint8_t flags; /*!< Flags */
|
||||||
uint32_t iv_index; /*!< IV Index */
|
uint32_t iv_index; /*!< IV Index */
|
||||||
|
|
|
@ -522,7 +522,7 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer)
|
||||||
return;
|
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};
|
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||||
btc_msg_t msg = {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__);
|
LOG_DEBUG("%s", __func__);
|
||||||
|
|
||||||
mesh_param.node_prov_complete.net_idx = net_idx;
|
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.addr = addr;
|
||||||
mesh_param.node_prov_complete.flags = flags;
|
mesh_param.node_prov_complete.flags = flags;
|
||||||
mesh_param.node_prov_complete.iv_index = iv_index;
|
mesh_param.node_prov_complete.iv_index = iv_index;
|
||||||
|
|
|
@ -164,11 +164,12 @@ struct bt_mesh_prov {
|
||||||
* assigned the specified NetKeyIndex and primary element address.
|
* assigned the specified NetKeyIndex and primary element address.
|
||||||
*
|
*
|
||||||
* @param net_idx NetKeyIndex given during provisioning.
|
* @param net_idx NetKeyIndex given during provisioning.
|
||||||
|
* @param net_key NetKey given during provisioning.
|
||||||
* @param addr Primary element address.
|
* @param addr Primary element address.
|
||||||
* @param flags Key Refresh & IV Update flags
|
* @param flags Key Refresh & IV Update flags
|
||||||
* @param iv_index IV Index.
|
* @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.
|
/** @brief Node has been reset.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1476,11 +1476,12 @@ void bt_mesh_net_start(void)
|
||||||
u16_t addr = bt_mesh_primary_addr();
|
u16_t addr = bt_mesh_primary_addr();
|
||||||
u32_t iv_index = bt_mesh.iv_index;
|
u32_t iv_index = bt_mesh.iv_index;
|
||||||
u8_t flags = (u8_t)bt_mesh.sub[0].kr_flag;
|
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)) {
|
if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS)) {
|
||||||
flags |= BLE_MESH_NET_FLAG_IVU;
|
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
|
#endif
|
||||||
|
|
|
@ -1744,10 +1744,10 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
|
||||||
return 0;
|
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) {
|
if (prov->complete) {
|
||||||
prov->complete(net_idx, addr, flags, iv_index);
|
prov->complete(net_idx, net_key, addr, flags, iv_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
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);
|
void bt_mesh_prov_reset(void);
|
||||||
|
|
||||||
#endif /* _PROV_H_ */
|
#endif /* _PROV_H_ */
|
||||||
|
|
Loading…
Reference in a new issue