ble_mesh: Update next alloc address when node info is added
This commit is contained in:
parent
388043c203
commit
f137546a4b
3 changed files with 47 additions and 1 deletions
|
@ -1512,6 +1512,8 @@ int bt_mesh_print_local_composition_data(void)
|
||||||
#if CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK
|
#if CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK
|
||||||
int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node)
|
int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node)
|
||||||
{
|
{
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
BT_ERR("%s, Invalid parameter", __func__);
|
BT_ERR("%s, Invalid parameter", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1532,12 +1534,24 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node->unicast_addr + node->element_num - 1 > 0x7FFF) {
|
||||||
|
BT_ERR("%s, Not enough unicast address for the node", __func__);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
if (bt_mesh_provisioner_net_key_get(node->net_idx) == NULL) {
|
if (bt_mesh_provisioner_net_key_get(node->net_idx) == NULL) {
|
||||||
BT_ERR("%s, Invalid NetKey Index 0x%03x", __func__, node->net_idx);
|
BT_ERR("%s, Invalid NetKey Index 0x%03x", __func__, node->net_idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return provisioner_store_node(node, false, true, NULL);
|
err = provisioner_store_node(node, true, NULL);
|
||||||
|
if (err) {
|
||||||
|
BT_ERR("%s, Failed to store node info", __func__);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
bt_mesh_test_provisioner_update_alloc_addr(node->unicast_addr, node->element_num);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK */
|
#endif /* CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK */
|
||||||
|
|
||||||
|
|
|
@ -1245,6 +1245,26 @@ int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK
|
||||||
|
int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element_num)
|
||||||
|
{
|
||||||
|
u16_t max_addr = FAST_PROV_ENABLE() ? prov_ctx.fast_prov.unicast_addr_max : PROV_MAX_ADDR_TO_ASSIGN;
|
||||||
|
|
||||||
|
if (unicast_addr + element_num > max_addr) {
|
||||||
|
BT_WARN("%s, Not enough unicast address to allocate", __func__);
|
||||||
|
prov_ctx.curr_alloc_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||||
|
} else {
|
||||||
|
prov_ctx.curr_alloc_addr = unicast_addr + element_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
|
bt_mesh_store_prov_info(prov_ctx.primary_addr, prov_ctx.curr_alloc_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK */
|
||||||
|
|
||||||
/* The following APIs are for fast provisioning */
|
/* The following APIs are for fast provisioning */
|
||||||
|
|
||||||
void bt_mesh_provisioner_fast_prov_enable(bool enable)
|
void bt_mesh_provisioner_fast_prov_enable(bool enable)
|
||||||
|
|
|
@ -331,6 +331,18 @@ u16_t bt_mesh_provisioner_get_primary_elem_addr(void);
|
||||||
*/
|
*/
|
||||||
int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr);
|
int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is used to update next allocated address by Provisioner.
|
||||||
|
*
|
||||||
|
* @note This function is used for mesh internal test.
|
||||||
|
*
|
||||||
|
* @param[in] unicast_addr: unicast address of the node
|
||||||
|
* @param[in] element_num: element count of the node
|
||||||
|
*
|
||||||
|
* @return Zero - success, otherwise - fail
|
||||||
|
*/
|
||||||
|
int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is called to input number/string out-put by unprovisioned device.
|
* @brief This function is called to input number/string out-put by unprovisioned device.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue