/
esp_ble_mesh_brc_model_api.h
322 lines (281 loc) · 16.6 KB
/
esp_ble_mesh_brc_model_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ESP_BLE_MESH_BRC_MODEL_API_H_
#define _ESP_BLE_MESH_BRC_MODEL_API_H_
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB1)
#define ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB2)
#define ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB3)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB4)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB5)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB6)
#define ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB7)
#define ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB8)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xB9)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0xBA)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0xBB)
#define ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0xBC)
/** @def ESP_BLE_MESH_MODEL_BRC_SRV
*
* @brief Define a new Bridge Configuration Server model.
*
* @note If supported, the model shall be supported by a primary element
* and shall not be supported by any secondary elements.
*
* @param srv_data Pointer to a unique Bridge Configuration Server
* model user_data.
*
* @return New Bridge Configuration Server model instance.
*/
#define ESP_BLE_MESH_MODEL_BRC_SRV(srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_BRC_SRV, \
NULL, NULL, srv_data)
/** @def ESP_BLE_MESH_MODEL_BRC_CLI
*
* @brief Define a new Bridge Configuration Client model.
*
* @note If supported, the model shall be supported by a primary element
* and shall not be supported by any secondary elements.
*
* @param cli_data Pointer to a unique Bridge Configuration Client
* model user_data.
*
* @return New Bridge Configuration Client model instance.
*/
#define ESP_BLE_MESH_MODEL_BRC_CLI(cli_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_BRC_CLI, \
NULL, NULL, cli_data)
/** Parameters of subnet bridge table */
typedef struct {
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
uint8_t bridge_net_idx[3]; /*!< Two NetKey Indexes are packed into three octets */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
} esp_ble_mesh_subnet_bridge_table_t; /*!< Entries of subnet bridge table */
#if CONFIG_BLE_MESH_BRC_SRV
/** Bridge Configuration Server model context */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Bridge Configuration Server model */
uint8_t subnet_bridge; /*!< Subnet Bridge state */
uint16_t bridging_table_size; /*!< Bridging Table Size */
esp_ble_mesh_subnet_bridge_table_t bridge_table[CONFIG_BLE_MESH_MAX_BRIDGING_TABLE_ENTRY_COUNT]; /*!< Subnet Bridge table, used to storage bridging table entries */
} esp_ble_mesh_brc_srv_t; /*!< Bridge Configuration Server model context */
#endif
/** Parameters of Subnet Bridge Set */
typedef struct {
uint8_t subnet_bridge; /*!< New Subnet Bridge state */
} esp_ble_mesh_subnet_bridge_set_t; /*!< Parameters of Subnet Bridge Set */
/** Parameters of Bridging Table Add */
typedef struct {
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
} esp_ble_mesh_bridging_table_add_t; /*!< Parameters of Bridging Table Add */
/** Parameters of Bridging Table Remove */
typedef struct {
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
} esp_ble_mesh_bridging_table_remove_t; /*!< Parameters of Bridging Table Remove */
/** Parameters of Bridged Subnets Get */
typedef struct {
uint16_t bridge_filter:2, /*!< Filter to be applied when reporting the set of pairs of NetKey Indexes */
bridge_net_idx:12; /*!< NetKey Index of any of the subnets */
uint8_t bridge_start_idx; /*!< Start offset in units of Bridging Table state entries */
} esp_ble_mesh_bridged_subnets_get_t; /*!< Parameters of Bridged Subnets Get */
/** Parameters of Bridging Table Get */
typedef struct {
uint16_t bridge_net_idx_1; /*!< NetKey Index of first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_start_idx; /*!< Start offset in units of Bridging Table state entries */
} esp_ble_mesh_bridging_table_get_t; /*!< Parameters of Bridging Table Get */
/**
* @brief Bridge Configuration Client model message union
*/
typedef union {
esp_ble_mesh_bridged_subnets_get_t bridged_subnets_get; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_GET */
esp_ble_mesh_bridging_table_get_t bridging_table_get; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_GET */
esp_ble_mesh_subnet_bridge_set_t subnet_bridge_set; /*!< For ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_SET */
esp_ble_mesh_bridging_table_add_t bridging_table_add; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_ADD */
esp_ble_mesh_bridging_table_remove_t bridging_table_remove; /*!< For ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_REMOVE */
} esp_ble_mesh_brc_client_msg_t; /*!< Bridge Configuration Client model message union */
/** Parameters of Subnet Bridge Status */
typedef struct {
uint8_t subnet_bridge; /*!< Current Subnet Bridge state */
} esp_ble_mesh_subnet_bridge_status_t; /*!< Parameters of Subnet Bridge Status */
/** Parameters of Bridging Table Status */
typedef struct {
uint8_t status; /*!< Status Code for the requesting message */
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
} esp_ble_mesh_bridging_table_status_t; /*!< Parameters of Bridging Table Status */
/** Bridged_Subnets_List entry format */
typedef struct {
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
} esp_ble_mesh_bridge_net_idx_pair_entry_t; /*!< Bridged_Subnets_List entry format */
/** Parameters of Bridged Subnets List */
typedef struct {
uint16_t bridge_filter:2, /*!< Filter applied to the set of pairs of NetKey Indexes */
bridge_net_idx:12; /*!< NetKey Index used for filtering or ignored */
uint8_t bridge_start_idx; /*!< Start offset in units of bridges */
uint8_t bridged_entry_list_size; /*!< Num of pairs of NetKey Indexes */
esp_ble_mesh_bridge_net_idx_pair_entry_t *net_idx_pair; /*!< Filtered set of N pairs of NetKey Indexes */
} esp_ble_mesh_bridged_subnets_list_t; /*!< Parameters of Bridged Subnets List */
/** Bridged_Addresses_List entry format */
typedef struct {
uint8_t bridge_direction; /*!< Allowed directions for bridged traffic */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
}esp_ble_mesh_bridged_addr_list_entry_t; /*!< Bridged_Addresses_List entry format */
/** Parameters of Bridging Table List */
typedef struct {
uint8_t status; /*!< Status Code for the requesting message */
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_start_idx; /*!< Start offset in units of Bridging Table state entries */
uint16_t bridged_addr_list_size; /*!< Num of pairs of entry */
esp_ble_mesh_bridged_addr_list_entry_t *bridged_addr_list; /*!< List of bridged addresses and allowed traffic directions */
} esp_ble_mesh_bridging_table_list_t; /*!< Parameters of Bridging Table List */
/** Parameters of Bridging Table Size Status */
typedef struct {
uint16_t bridging_table_size; /*!< Bridging Table Size state */
} esp_ble_mesh_bridging_table_size_status_t; /*!< Parameters of Bridging Table Size Status */
/**
* @brief Bridge Configuration Client model received message union
*/
typedef union {
esp_ble_mesh_subnet_bridge_status_t subnet_bridge_status; /*!< ESP_BLE_MESH_MODEL_OP_SUBNET_BRIDGE_STATUS */
esp_ble_mesh_bridging_table_status_t bridging_table_status; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_STATUS */
esp_ble_mesh_bridged_subnets_list_t bridged_subnets_list; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGED_SUBNETS_LIST */
esp_ble_mesh_bridging_table_list_t bridging_table_list; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_LIST */
esp_ble_mesh_bridging_table_size_status_t bridging_table_size_status; /*!< ESP_BLE_MESH_MODEL_OP_BRIDGING_TABLE_SIZE_STATUS */
} esp_ble_mesh_brc_client_recv_cb_t;/*!< */
/** Result of sending Bridge Configuration Client messages */
typedef struct {
int err_code; /*!< Result of sending a message */
} esp_ble_mesh_brc_client_send_cb_t; /*!< Result of sending Bridge Configuration Client messages */
/** Bridge Configuration Client model callback parameters */
typedef struct {
esp_ble_mesh_client_common_param_t *params; /*!< Client common parameters, used by all events. */
/** Union of Bridge Configuration Client callback */
union {
esp_ble_mesh_brc_client_send_cb_t send; /*!< Result of sending a message */
esp_ble_mesh_brc_client_recv_cb_t recv; /*!< Parameters of received status message */
};
} esp_ble_mesh_brc_client_cb_param_t; /*!< Bridge Configuration Client model callback parameters */
/** This enum value is the event of Bridge Configuration Client model */
typedef enum {
ESP_BLE_MESH_BRC_CLIENT_SEND_COMP_EVT,
ESP_BLE_MESH_BRC_CLIENT_SEND_TIMEOUT_EVT,
ESP_BLE_MESH_BRC_CLIENT_RECV_RSP_EVT,
ESP_BLE_MESH_BRC_CLIENT_RECV_PUB_EVT,
ESP_BLE_MESH_BRC_CLIENT_EVT_MAX,
} esp_ble_mesh_brc_client_cb_event_t;
/**
* @brief Bridge Configuration Server model related context.
*/
/** Parameters of Bridging Table Add */
typedef struct {
uint8_t bridge_direction; /*!< Allowed directions for the bridged traffic */
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
} esp_ble_mesh_state_change_bridging_table_add_t; /*!< Parameters of Bridging Table Add */
/** Parameters of Bridging Table Remove */
typedef struct {
uint16_t bridge_net_idx_1; /*!< NetKey Index of the first subnet */
uint16_t bridge_net_idx_2; /*!< NetKey Index of the second subnet */
uint16_t bridge_addr_1; /*!< Address of the node in the first subnet */
uint16_t bridge_addr_2; /*!< Address of the node in the second subnet */
} esp_ble_mesh_state_change_bridging_table_remove_t; /*!< Parameters of Bridging Table Remove */
/**
* @brief Bridge Configuration Server model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_bridging_table_add_t bridging_table_add; /*!< Bridging Table Add */
esp_ble_mesh_state_change_bridging_table_remove_t bridging_table_remove; /*!< Bridging Table Remove*/
} esp_ble_mesh_brc_server_state_change_t; /*!< Bridge Configuration Server model state change value union */
/**
* @brief Bridge Configuration Server model callback value union
*/
typedef union {
esp_ble_mesh_brc_server_state_change_t state_change; /*!< For ESP_BLE_MESH_BRC_SERVER_STATE_CHANGE_EVT */
} esp_ble_mesh_brc_server_cb_value_t; /*!< Bridge Configuration Server model callback value union */
/** Bridge Configuration Server model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
esp_ble_mesh_brc_server_cb_value_t value; /*!< Value of the received configuration messages */
} esp_ble_mesh_brc_server_cb_param_t; /*!< Bridge Configuration Server model callback parameters */
/** This enum value is the event of Bridge Configuration Server model */
typedef enum {
ESP_BLE_MESH_BRC_SERVER_STATE_CHANGE_EVT,
ESP_BLE_MESH_BRC_SERVER_EVT_MAX,
} esp_ble_mesh_brc_server_cb_event_t;
/**
* @brief Bluetooth Mesh Bridge Configuration client and server model functions.
*/
/**
* @brief Bridge Configuration Client model callback function type
* @param event: Event type
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_brc_client_cb_t)(esp_ble_mesh_brc_client_cb_event_t event,
esp_ble_mesh_brc_client_cb_param_t *param);
/**
* @brief Bridge Configuration Server model callback function type
* @param event: Event type
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_brc_server_cb_t)(esp_ble_mesh_brc_server_cb_event_t event,
esp_ble_mesh_brc_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Bridge Configuration Client model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_register_brc_client_callback(esp_ble_mesh_brc_client_cb_t callback);
/**
* @brief Register BLE Mesh Bridge Configuration Server model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_register_brc_server_callback(esp_ble_mesh_brc_server_cb_t callback);
/**
* @brief Get/Set the value of Bridge Configuration Server model state with the corresponding message.
*
* @param[in] params: Pointer to BLE Mesh common client parameters.
* @param[in] msg: Pointer to Bridge Configuration Client message.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_brc_client_send(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_brc_client_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_BRC_MODEL_API_H_ */