1 /* 2 * Copyright (c) 2020 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_BT_MESH_RPR_H__ 8 #define ZEPHYR_INCLUDE_BT_MESH_RPR_H__ 9 10 #include <zephyr/kernel.h> 11 #include <zephyr/bluetooth/mesh/main.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * @defgroup bt_mesh_rpr Remote Provisioning models 19 * @ingroup bt_mesh 20 * @{ 21 */ 22 23 /** Unprovisioned device has URI hash value */ 24 #define BT_MESH_RPR_UNPROV_HASH BIT(0) 25 #define BT_MESH_RPR_UNPROV_ACTIVE BIT(1) /**< Internal */ 26 #define BT_MESH_RPR_UNPROV_FOUND BIT(2) /**< Internal */ 27 #define BT_MESH_RPR_UNPROV_REPORTED BIT(3) /**< Internal */ 28 #define BT_MESH_RPR_UNPROV_EXT BIT(4) /**< Internal */ 29 #define BT_MESH_RPR_UNPROV_HAS_LINK BIT(5) /**< Internal */ 30 #define BT_MESH_RPR_UNPROV_EXT_ADV_RXD BIT(6) /**< Internal */ 31 32 /** Minimum extended scan duration in seconds */ 33 #define BT_MESH_RPR_EXT_SCAN_TIME_MIN 1 34 /** Maximum extended scan duration in seconds */ 35 #define BT_MESH_RPR_EXT_SCAN_TIME_MAX 21 36 37 enum bt_mesh_rpr_status { 38 BT_MESH_RPR_SUCCESS, 39 BT_MESH_RPR_ERR_SCANNING_CANNOT_START, 40 BT_MESH_RPR_ERR_INVALID_STATE, 41 BT_MESH_RPR_ERR_LIMITED_RESOURCES, 42 BT_MESH_RPR_ERR_LINK_CANNOT_OPEN, 43 BT_MESH_RPR_ERR_LINK_OPEN_FAILED, 44 BT_MESH_RPR_ERR_LINK_CLOSED_BY_DEVICE, 45 BT_MESH_RPR_ERR_LINK_CLOSED_BY_SERVER, 46 BT_MESH_RPR_ERR_LINK_CLOSED_BY_CLIENT, 47 BT_MESH_RPR_ERR_LINK_CLOSED_AS_CANNOT_RECEIVE_PDU, 48 BT_MESH_RPR_ERR_LINK_CLOSED_AS_CANNOT_SEND_PDU, 49 BT_MESH_RPR_ERR_LINK_CLOSED_AS_CANNOT_DELIVER_PDU_REPORT, 50 }; 51 52 enum bt_mesh_rpr_scan { 53 BT_MESH_RPR_SCAN_IDLE, 54 BT_MESH_RPR_SCAN_MULTI, 55 BT_MESH_RPR_SCAN_SINGLE, 56 }; 57 58 enum bt_mesh_rpr_node_refresh { 59 /** Change the Device key. */ 60 BT_MESH_RPR_NODE_REFRESH_DEVKEY, 61 /** Change the Device key and address. Device composition may change. */ 62 BT_MESH_RPR_NODE_REFRESH_ADDR, 63 /** Change the Device key and composition. */ 64 BT_MESH_RPR_NODE_REFRESH_COMPOSITION, 65 }; 66 67 enum bt_mesh_rpr_link_state { 68 BT_MESH_RPR_LINK_IDLE, 69 BT_MESH_RPR_LINK_OPENING, 70 BT_MESH_RPR_LINK_ACTIVE, 71 BT_MESH_RPR_LINK_SENDING, 72 BT_MESH_RPR_LINK_CLOSING, 73 }; 74 75 /** Remote provisioning actor, as seen across the mesh. */ 76 struct bt_mesh_rpr_node { 77 /** Unicast address of the node. */ 78 uint16_t addr; 79 /** Network index used when communicating with the node. */ 80 uint16_t net_idx; 81 /** Time To Live value used when communicating with the node. */ 82 uint8_t ttl; 83 }; 84 85 /** Unprovisioned device. */ 86 struct bt_mesh_rpr_unprov { 87 /** Unprovisioned device UUID. */ 88 uint8_t uuid[16]; 89 /** Flags, see @p BT_MESH_RPR_UNPROV_* flags. */ 90 uint8_t flags; 91 /** RSSI of unprovisioned device, as received by server. */ 92 int8_t rssi; 93 /** Out of band information. */ 94 bt_mesh_prov_oob_info_t oob; 95 /** URI hash in unprovisioned beacon. 96 * 97 * Only valid if @c flags has @ref BT_MESH_RPR_UNPROV_HASH set. 98 */ 99 uint32_t hash; 100 }; 101 102 /** Remote Provisioning Link status */ 103 struct bt_mesh_rpr_link { 104 /** Link status */ 105 enum bt_mesh_rpr_status status; 106 /** Link state */ 107 enum bt_mesh_rpr_link_state state; 108 }; 109 110 /** @} */ 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* ZEPHYR_INCLUDE_BT_MESH_RPR_H__ */ 117