| /* |
| * Copyright (c) 2023 Nordic Semiconductor ASA |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| /** Virtual address entry. */ |
| struct bt_mesh_va { |
| uint16_t ref:15, |
| changed:1; |
| uint16_t addr; |
| uint8_t uuid[16]; |
| }; |
| |
| /** @brief Store Label UUID. |
| * |
| * @param uuid Label UUID to be stored. |
| * @param entry Pointer to a memory where a new or updated entry will be stored, or NULL. |
| * |
| * @return STATUS_SUCCESS if entry is stored or updated, error code otherwise. |
| */ |
| uint8_t bt_mesh_va_add(const uint8_t uuid[16], const struct bt_mesh_va **entry); |
| |
| /** @brief Delete Label UUID. |
| * |
| * @c uuid must be a pointer to @ref bt_mesh_va.uuid. Use @ref bt_mesh_va_uuid_get to get valid |
| * pointer. |
| * |
| * @param uuid Label UUID to delete. |
| * |
| * @return STATUS_SUCCESS if entry is deleted, error code otherwise. |
| */ |
| uint8_t bt_mesh_va_del(const uint8_t *uuid); |
| |
| /** @brief Find virtual address entry by Label UUID. |
| * |
| * @c uuid can be a user data. |
| * |
| * @param uuid pointer to memory with Label UUID to be found. |
| * |
| * @return Pointer to a valid entry, NULL otherwise. |
| */ |
| const struct bt_mesh_va *bt_mesh_va_find(const uint8_t *uuid); |
| |
| /** @brief Check if there are more than one Label UUID which hash has the specified virtual |
| * address. |
| * |
| * @param addr Virtual address to check |
| * |
| * @return True if there is collision, false otherwise. |
| */ |
| bool bt_mesh_va_collision_check(uint16_t addr); |
| |
| /* Needed for storing va as indexes in persistent storage. */ |
| /** @brief Get Label UUID by index. |
| * |
| * @param idx Index of virtual address entry. |
| * |
| * @return Pointer to a valid Label UUID, or NULL if entry is not found. |
| */ |
| const uint8_t *bt_mesh_va_get_uuid_by_idx(uint16_t idx); |
| |
| /** @brief Get virtual address entry index by Label UUID. |
| * |
| * @c uuid must be a pointer to @ref bt_mesh_va.uuid. Use @ref bt_mesh_va_uuid_get to get valid |
| * pointer. |
| * |
| * @param uuid Label UUID which index to find |
| * @param uuidx Pointer to a memory where to store index. |
| * |
| * @return 0 if entry is found, error code otherwise. |
| */ |
| int bt_mesh_va_get_idx_by_uuid(const uint8_t *uuid, uint16_t *uuidx); |
| |
| /** @brief Store pending virtual address entries in the persistent storage.*/ |
| void bt_mesh_va_pending_store(void); |
| |
| /** @brief Remove all stored virtual addresses and remove them from the persistent storage. */ |
| void bt_mesh_va_clear(void); |