1 /*
2  * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /** @file
8  *  @brief Bluetooth Mesh Generic Client Model APIs.
9  */
10 
11 #ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_
12 #define _ESP_BLE_MESH_GENERIC_MODEL_API_H_
13 
14 #include "esp_ble_mesh_defs.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /** @def    ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI
21  *
22  *  @brief  Define a new Generic OnOff Client Model.
23  *
24  *  @note   This API needs to be called for each element on which
25  *          the application needs to have a Generic OnOff Client Model.
26  *
27  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
28  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
29  *
30  *  @return New Generic OnOff Client Model instance.
31  */
32 #define ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data)         \
33         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \
34                     NULL, cli_pub, cli_data)
35 
36 /** @def    ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI
37  *
38  *  @brief  Define a new Generic Level Client Model.
39  *
40  *  @note   This API needs to be called for each element on which
41  *          the application needs to have a Generic Level Client Model.
42  *
43  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
44  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
45  *
46  *  @return New Generic Level Client Model instance.
47  */
48 
49 #define ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data)         \
50         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \
51                     NULL, cli_pub, cli_data)
52 
53 /** @def    ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI
54  *
55  *  @brief  Define a new Generic Default Transition Time Client Model.
56  *
57  *  @note   This API needs to be called for each element on which
58  *          the application needs to have a Generic Default Transition
59  *          Time Client Model.
60  *
61  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
62  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
63  *
64  *  @return New Generic Default Transition Time Client Model instance.
65  */
66 #define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data)            \
67         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI,    \
68                     NULL, cli_pub, cli_data)
69 
70 /** @def    ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI
71  *
72  *  @brief  Define a new Generic Power OnOff Client Model.
73  *
74  *  @note   This API needs to be called for each element on which
75  *          the application needs to have a Generic Power OnOff Client Model.
76  *
77  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
78  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
79  *
80  *  @return New Generic Power OnOff Client Model instance.
81  */
82 #define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data)           \
83         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI,   \
84                     NULL, cli_pub, cli_data)
85 
86 /** @def    ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI
87  *
88  *  @brief  Define a new Generic Power Level Client Model.
89  *
90  *  @note   This API needs to be called for each element on which
91  *          the application needs to have a Generic Power Level Client Model.
92  *
93  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
94  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
95  *
96  *  @return New Generic Power Level Client Model instance.
97  */
98 #define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data)           \
99         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI,   \
100                     NULL, cli_pub, cli_data)
101 
102 /** @def    ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI
103  *
104  *  @brief  Define a new Generic Battery Client Model.
105  *
106  *  @note   This API needs to be called for each element on which
107  *          the application needs to have a Generic Battery Client Model.
108  *
109  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
110  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
111  *
112  *  @return New Generic Battery Client Model instance.
113  */
114 #define ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data)           \
115         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI,   \
116                     NULL, cli_pub, cli_data)
117 
118 /** @def    ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI
119  *
120  *  @brief  Define a new Generic Location Client Model.
121  *
122  *  @note   This API needs to be called for each element on which
123  *          the application needs to have a Generic Location Client Model.
124  *
125  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
126  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
127  *
128  *  @return New Generic Location Client Model instance.
129  */
130 #define ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data)          \
131         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI,  \
132                     NULL, cli_pub, cli_data)
133 
134 /** @def    ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI
135  *
136  *  @brief  Define a new Generic Property Client Model.
137  *
138  *  @note   This API needs to be called for each element on which
139  *          the application needs to have a Generic Property Client Model.
140  *
141  *  @param  cli_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
142  *  @param  cli_data Pointer to the unique struct esp_ble_mesh_client_t.
143  *
144  *  @return New Generic Location Client Model instance.
145  */
146 #define ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data)          \
147         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI,      \
148                     NULL, cli_pub, cli_data)
149 
150 /**
151  *  @brief Bluetooth Mesh Generic Client Model Get and Set parameters structure.
152  */
153 
154 /** Parameters of Generic OnOff Set. */
155 typedef struct {
156     bool    op_en;      /*!< Indicate if optional parameters are included */
157     uint8_t onoff;      /*!< Target value of Generic OnOff state */
158     uint8_t tid;        /*!< Transaction ID */
159     uint8_t trans_time; /*!< Time to complete state transition (optional) */
160     uint8_t delay;      /*!< Indicate message execution delay (C.1) */
161 } esp_ble_mesh_gen_onoff_set_t;
162 
163 /** Parameters of Generic Level Set. */
164 typedef struct {
165     bool    op_en;      /*!< Indicate if optional parameters are included */
166     int16_t level;      /*!< Target value of Generic Level state */
167     uint8_t tid;        /*!< Transaction ID */
168     uint8_t trans_time; /*!< Time to complete state transition (optional) */
169     uint8_t delay;      /*!< Indicate message execution delay (C.1) */
170 } esp_ble_mesh_gen_level_set_t;
171 
172 /** Parameters of Generic Delta Set. */
173 typedef struct {
174     bool    op_en;      /*!< Indicate if optional parameters are included */
175     int32_t level;      /*!< Delta change of Generic Level state */
176     uint8_t tid;        /*!< Transaction ID */
177     uint8_t trans_time; /*!< Time to complete state transition (optional) */
178     uint8_t delay;      /*!< Indicate message execution delay (C.1) */
179 } esp_ble_mesh_gen_delta_set_t;
180 
181 /** Parameters of Generic Move Set. */
182 typedef struct {
183     bool    op_en;          /*!< Indicate if optional parameters are included */
184     int16_t delta_level;    /*!< Delta Level step to calculate Move speed for Generic Level state */
185     uint8_t tid;            /*!< Transaction ID */
186     uint8_t trans_time;     /*!< Time to complete state transition (optional) */
187     uint8_t delay;          /*!< Indicate message execution delay (C.1) */
188 } esp_ble_mesh_gen_move_set_t;
189 
190 /** Parameter of Generic Default Transition Time Set. */
191 typedef struct {
192     uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
193 } esp_ble_mesh_gen_def_trans_time_set_t;
194 
195 /** Parameter of Generic OnPowerUp Set. */
196 typedef struct {
197     uint8_t onpowerup;  /*!< The value of the Generic OnPowerUp state */
198 } esp_ble_mesh_gen_onpowerup_set_t;
199 
200 /** Parameters of Generic Power Level Set. */
201 typedef struct {
202     bool     op_en;         /*!< Indicate if optional parameters are included */
203     uint16_t power;         /*!< Target value of Generic Power Actual state */
204     uint8_t  tid;           /*!< Transaction ID */
205     uint8_t  trans_time;    /*!< Time to complete state transition (optional) */
206     uint8_t  delay;         /*!< Indicate message execution delay (C.1) */
207 } esp_ble_mesh_gen_power_level_set_t;
208 
209 /** Parameter of Generic Power Default Set. */
210 typedef struct {
211     uint16_t power;         /*!< The value of the Generic Power Default state */
212 } esp_ble_mesh_gen_power_default_set_t;
213 
214 /** Parameters of Generic Power Range Set. */
215 typedef struct {
216     uint16_t range_min;     /*!< Value of Range Min field of Generic Power Range state */
217     uint16_t range_max;     /*!< Value of Range Max field of Generic Power Range state */
218 } esp_ble_mesh_gen_power_range_set_t;
219 
220 /** Parameters of Generic Location Global Set. */
221 typedef struct {
222     int32_t global_latitude;    /*!< Global Coordinates (Latitude) */
223     int32_t global_longitude;   /*!< Global Coordinates (Longitude) */
224     int16_t global_altitude;    /*!< Global Altitude */
225 } esp_ble_mesh_gen_loc_global_set_t;
226 
227 /** Parameters of Generic Location Local Set. */
228 typedef struct {
229     int16_t  local_north;       /*!< Local Coordinates (North) */
230     int16_t  local_east;        /*!< Local Coordinates (East) */
231     int16_t  local_altitude;    /*!< Local Altitude */
232     uint8_t  floor_number;      /*!< Floor Number */
233     uint16_t uncertainty;       /*!< Uncertainty */
234 } esp_ble_mesh_gen_loc_local_set_t;
235 
236 /** Parameter of Generic User Property Get. */
237 typedef struct {
238     uint16_t property_id;       /*!< Property ID identifying a Generic User Property */
239 } esp_ble_mesh_gen_user_property_get_t;
240 
241 /** Parameters of Generic User Property Set. */
242 typedef struct {
243     uint16_t property_id;   /*!< Property ID identifying a Generic User Property */
244     struct net_buf_simple *property_value;  /*!< Raw value for the User Property */
245 } esp_ble_mesh_gen_user_property_set_t;
246 
247 /** Parameter of Generic Admin Property Get. */
248 typedef struct {
249     uint16_t property_id;   /*!< Property ID identifying a Generic Admin Property */
250 } esp_ble_mesh_gen_admin_property_get_t;
251 
252 /** Parameters of Generic Admin Property Set. */
253 typedef struct {
254     uint16_t property_id;   /*!< Property ID identifying a Generic Admin Property */
255     uint8_t  user_access;   /*!< Enumeration indicating user access */
256     struct net_buf_simple *property_value;  /*!< Raw value for the Admin Property */
257 } esp_ble_mesh_gen_admin_property_set_t;
258 
259 /** Parameter of Generic Manufacturer Property Get. */
260 typedef struct {
261     uint16_t property_id;   /*!< Property ID identifying a Generic Manufacturer Property */
262 } esp_ble_mesh_gen_manufacturer_property_get_t;
263 
264 /** Parameters of Generic Manufacturer Property Set. */
265 typedef struct {
266     uint16_t property_id;   /*!< Property ID identifying a Generic Manufacturer Property */
267     uint8_t  user_access;   /*!< Enumeration indicating user access */
268 } esp_ble_mesh_gen_manufacturer_property_set_t;
269 
270 /** Parameter of Generic Client Properties Get. */
271 typedef struct {
272     uint16_t property_id;   /*!< A starting Client Property ID present within an element */
273 } esp_ble_mesh_gen_client_properties_get_t;
274 
275 /**
276  * @brief Generic Client Model get message union
277  */
278 typedef union {
279     esp_ble_mesh_gen_user_property_get_t         user_property_get;         /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET */
280     esp_ble_mesh_gen_admin_property_get_t        admin_property_get;        /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET*/
281     esp_ble_mesh_gen_manufacturer_property_get_t manufacturer_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET */
282     esp_ble_mesh_gen_client_properties_get_t     client_properties_get;     /*!< For ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET */
283 } esp_ble_mesh_generic_client_get_state_t;
284 
285 /**
286  * @brief Generic Client Model set message union
287  */
288 typedef union {
289     esp_ble_mesh_gen_onoff_set_t          onoff_set;            /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK */
290     esp_ble_mesh_gen_level_set_t          level_set;            /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK */
291     esp_ble_mesh_gen_delta_set_t          delta_set;            /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET & ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK */
292     esp_ble_mesh_gen_move_set_t           move_set;             /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET & ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK */
293     esp_ble_mesh_gen_def_trans_time_set_t def_trans_time_set;   /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET & ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK */
294     esp_ble_mesh_gen_onpowerup_set_t      power_set;            /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK */
295     esp_ble_mesh_gen_power_level_set_t    power_level_set;      /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK */
296     esp_ble_mesh_gen_power_default_set_t  power_default_set;    /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK */
297     esp_ble_mesh_gen_power_range_set_t    power_range_set;      /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK */
298     esp_ble_mesh_gen_loc_global_set_t     loc_global_set;       /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK */
299     esp_ble_mesh_gen_loc_local_set_t      loc_local_set;        /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK */
300     esp_ble_mesh_gen_user_property_set_t  user_property_set;    /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK */
301     esp_ble_mesh_gen_admin_property_set_t admin_property_set;   /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK */
302     esp_ble_mesh_gen_manufacturer_property_set_t manufacturer_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK */
303 } esp_ble_mesh_generic_client_set_state_t;
304 
305 /**
306  *  @brief Bluetooth Mesh Generic Client Model Get and Set callback parameters structure.
307  */
308 
309 /** Parameters of Generic OnOff Status. */
310 typedef struct {
311     bool    op_en;          /*!< Indicate if optional parameters are included */
312     uint8_t present_onoff;  /*!< Current value of Generic OnOff state */
313     uint8_t target_onoff;   /*!< Target value of Generic OnOff state (optional) */
314     uint8_t remain_time;    /*!< Time to complete state transition (C.1) */
315 } esp_ble_mesh_gen_onoff_status_cb_t;
316 
317 /** Parameters of Generic Level Status. */
318 typedef struct {
319     bool    op_en;          /*!< Indicate if optional parameters are included */
320     int16_t present_level;  /*!< Current value of Generic Level state */
321     int16_t target_level;   /*!< Target value of the Generic Level state (optional) */
322     uint8_t remain_time;    /*!< Time to complete state transition (C.1) */
323 } esp_ble_mesh_gen_level_status_cb_t;
324 
325 /** Parameter of Generic Default Transition Time Status. */
326 typedef struct {
327     uint8_t trans_time;     /*!< The value of the Generic Default Transition Time state */
328 } esp_ble_mesh_gen_def_trans_time_status_cb_t;
329 
330 /** Parameter of Generic OnPowerUp Status. */
331 typedef struct {
332     uint8_t onpowerup;      /*!< The value of the Generic OnPowerUp state */
333 } esp_ble_mesh_gen_onpowerup_status_cb_t;
334 
335 /** Parameters of Generic Power Level Status. */
336 typedef struct {
337     bool     op_en;         /*!< Indicate if optional parameters are included */
338     uint16_t present_power; /*!< Current value of Generic Power Actual state */
339     uint16_t target_power;  /*!< Target value of Generic Power Actual state (optional) */
340     uint8_t  remain_time;   /*!< Time to complete state transition (C.1) */
341 } esp_ble_mesh_gen_power_level_status_cb_t;
342 
343 /** Parameter of Generic Power Last Status. */
344 typedef struct {
345     uint16_t power;         /*!< The value of the Generic Power Last state */
346 } esp_ble_mesh_gen_power_last_status_cb_t;
347 
348 /** Parameter of Generic Power Default Status. */
349 typedef struct {
350     uint16_t power;         /*!< The value of the Generic Default Last state */
351 } esp_ble_mesh_gen_power_default_status_cb_t;
352 
353 /** Parameters of Generic Power Range Status. */
354 typedef struct {
355     uint8_t  status_code;   /*!< Status Code for the request message */
356     uint16_t range_min;     /*!< Value of Range Min field of Generic Power Range state */
357     uint16_t range_max;     /*!< Value of Range Max field of Generic Power Range state */
358 } esp_ble_mesh_gen_power_range_status_cb_t;
359 
360 /** Parameters of Generic Battery Status. */
361 typedef struct {
362     uint32_t battery_level     : 8;  /*!< Value of Generic Battery Level state */
363     uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */
364     uint32_t time_to_charge    : 24; /*!< Value of Generic Battery Time to Charge state */
365     uint32_t flags             : 8;  /*!< Value of Generic Battery Flags state */
366 } esp_ble_mesh_gen_battery_status_cb_t;
367 
368 /** Parameters of Generic Location Global Status. */
369 typedef struct {
370     int32_t global_latitude;  /*!< Global Coordinates (Latitude) */
371     int32_t global_longitude; /*!< Global Coordinates (Longitude) */
372     int16_t global_altitude;  /*!< Global Altitude */
373 } esp_ble_mesh_gen_loc_global_status_cb_t;
374 
375 /** Parameters of Generic Location Local Status. */
376 typedef struct {
377     int16_t  local_north;     /*!< Local Coordinates (North) */
378     int16_t  local_east;      /*!< Local Coordinates (East) */
379     int16_t  local_altitude;  /*!< Local Altitude */
380     uint8_t  floor_number;    /*!< Floor Number */
381     uint16_t uncertainty;     /*!< Uncertainty */
382 } esp_ble_mesh_gen_loc_local_status_cb_t;
383 
384 /** Parameter of Generic User Properties Status. */
385 typedef struct {
386     struct net_buf_simple *property_ids;    /*!< Buffer contains a sequence of N User Property IDs */
387 } esp_ble_mesh_gen_user_properties_status_cb_t;
388 
389 /** Parameters of Generic User Property Status. */
390 typedef struct {
391     bool     op_en;         /*!< Indicate if optional parameters are included */
392     uint16_t property_id;   /*!< Property ID identifying a Generic User Property */
393     uint8_t  user_access;   /*!< Enumeration indicating user access (optional) */
394     struct net_buf_simple *property_value;  /*!< Raw value for the User Property (C.1) */
395 } esp_ble_mesh_gen_user_property_status_cb_t;
396 
397 /** Parameter of Generic Admin Properties Status. */
398 typedef struct {
399     struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Admin Property IDs */
400 } esp_ble_mesh_gen_admin_properties_status_cb_t;
401 
402 /** Parameters of Generic Admin Property Status. */
403 typedef struct {
404     bool     op_en;         /*!< Indicate if optional parameters are included */
405     uint16_t property_id;   /*!< Property ID identifying a Generic Admin Property */
406     uint8_t  user_access;   /*!< Enumeration indicating user access (optional) */
407     struct net_buf_simple *property_value;  /*!< Raw value for the Admin Property (C.1) */
408 } esp_ble_mesh_gen_admin_property_status_cb_t;
409 
410 /** Parameter of Generic Manufacturer Properties Status. */
411 typedef struct {
412     struct net_buf_simple *property_ids;    /*!< Buffer contains a sequence of N Manufacturer Property IDs */
413 } esp_ble_mesh_gen_manufacturer_properties_status_cb_t;
414 
415 /** Parameters of Generic Manufacturer Property Status. */
416 typedef struct {
417     bool     op_en;         /*!< Indicate if optional parameters are included */
418     uint16_t property_id;   /*!< Property ID identifying a Generic Manufacturer Property */
419     uint8_t  user_access;   /*!< Enumeration indicating user access (optional) */
420     struct net_buf_simple *property_value;  /*!< Raw value for the Manufacturer Property (C.1) */
421 } esp_ble_mesh_gen_manufacturer_property_status_cb_t;
422 
423 /** Parameter of Generic Client Properties Status. */
424 typedef struct {
425     struct net_buf_simple *property_ids;    /*!< Buffer contains a sequence of N Client Property IDs */
426 } esp_ble_mesh_gen_client_properties_status_cb_t;
427 
428 /**
429  * @brief Generic Client Model received message union
430  */
431 typedef union {
432     esp_ble_mesh_gen_onoff_status_cb_t             onoff_status;            /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS */
433     esp_ble_mesh_gen_level_status_cb_t             level_status;            /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS */
434     esp_ble_mesh_gen_def_trans_time_status_cb_t    def_trans_time_status;   /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS */
435     esp_ble_mesh_gen_onpowerup_status_cb_t         onpowerup_status;        /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS */
436     esp_ble_mesh_gen_power_level_status_cb_t       power_level_status;      /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS */
437     esp_ble_mesh_gen_power_last_status_cb_t        power_last_status;       /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS */
438     esp_ble_mesh_gen_power_default_status_cb_t     power_default_status;    /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS */
439     esp_ble_mesh_gen_power_range_status_cb_t       power_range_status;      /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS */
440     esp_ble_mesh_gen_battery_status_cb_t           battery_status;          /*!< For ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS */
441     esp_ble_mesh_gen_loc_global_status_cb_t        location_global_status;  /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS */
442     esp_ble_mesh_gen_loc_local_status_cb_t         location_local_status;   /*!< ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS */
443     esp_ble_mesh_gen_user_properties_status_cb_t   user_properties_status;  /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS */
444     esp_ble_mesh_gen_user_property_status_cb_t     user_property_status;    /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS */
445     esp_ble_mesh_gen_admin_properties_status_cb_t  admin_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS */
446     esp_ble_mesh_gen_admin_property_status_cb_t    admin_property_status;   /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS */
447     esp_ble_mesh_gen_manufacturer_properties_status_cb_t manufacturer_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS */
448     esp_ble_mesh_gen_manufacturer_property_status_cb_t   manufacturer_property_status;   /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS */
449     esp_ble_mesh_gen_client_properties_status_cb_t       client_properties_status;       /*!< ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS */
450 } esp_ble_mesh_gen_client_status_cb_t;
451 
452 /** Generic Client Model callback parameters */
453 typedef struct {
454     int error_code;                                 /*!< Appropriate error code */
455     esp_ble_mesh_client_common_param_t *params;     /*!< The client common parameters. */
456     esp_ble_mesh_gen_client_status_cb_t status_cb;  /*!< The generic status message callback values */
457 } esp_ble_mesh_generic_client_cb_param_t;
458 
459 /** This enum value is the event of Generic Client Model */
460 typedef enum {
461     ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT,
462     ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT,
463     ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT,
464     ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT,
465     ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX,
466 } esp_ble_mesh_generic_client_cb_event_t;
467 
468 /**
469  *  @brief Bluetooth Mesh Generic Client Model function.
470  */
471 
472 /**
473  * @brief   Generic Client Model callback function type
474  * @param   event: Event type
475  * @param   param: Pointer to callback parameter
476  */
477 typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event,
478                                                   esp_ble_mesh_generic_client_cb_param_t *param);
479 
480 /**
481  * @brief       Register BLE Mesh Generic Client Model callback.
482  *
483  * @param[in]   callback: Pointer to the callback function.
484  *
485  * @return      ESP_OK on success or error code otherwise.
486  *
487  */
488 esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback);
489 
490 /**
491  * @brief       Get the value of Generic Server Model states using the Generic Client Model get messages.
492  *
493  * @note        If you want to find the opcodes and corresponding meanings accepted by this API,
494  *              please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h
495  *
496  * @param[in]   params:    Pointer to BLE Mesh common client parameters.
497  * @param[in]   get_state: Pointer to generic get message value.
498  *                         Shall not be set to NULL.
499  *
500  * @return      ESP_OK on success or error code otherwise.
501  *
502  */
503 esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
504                                                 esp_ble_mesh_generic_client_get_state_t *get_state);
505 
506 /**
507  * @brief       Set the value of Generic Server Model states using the Generic Client Model set messages.
508  *
509  * @note        If you want to find the opcodes and corresponding meanings accepted by this API,
510  *              please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h
511  *
512  * @param[in]   params:    Pointer to BLE Mesh common client parameters.
513  * @param[in]   set_state: Pointer to generic set message value.
514  *                         Shall not be set to NULL.
515  *
516  * @return      ESP_OK on success or error code otherwise.
517  *
518  */
519 esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
520                                                 esp_ble_mesh_generic_client_set_state_t *set_state);
521 
522 /**
523  * @brief Generic Server Models related context.
524  */
525 
526 /** @def    ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV
527  *
528  *  @brief  Define a new Generic OnOff Server Model.
529  *
530  *  @note   1. The Generic OnOff Server Model is a root model.
531  *          2. This model shall support model publication and model subscription.
532  *
533  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
534  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_onoff_srv_t.
535  *
536  *  @return New Generic OnOff Server Model instance.
537  */
538 #define ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(srv_pub, srv_data)             \
539         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV,     \
540                     NULL, srv_pub, srv_data)
541 
542 /** @def    ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV
543  *
544  *  @brief  Define a new Generic Level Server Model.
545  *
546  *  @note   1. The Generic Level Server Model is a root model.
547  *          2. This model shall support model publication and model subscription.
548  *
549  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
550  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_level_srv_t.
551  *
552  *  @return New Generic Level Server Model instance.
553  */
554 #define ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV(srv_pub, srv_data)             \
555         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV,     \
556                     NULL, srv_pub, srv_data)
557 
558 /** @def    ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV
559  *
560  *  @brief  Define a new Generic Default Transition Time Server Model.
561  *
562  *  @note   1. The Generic Default Transition Time Server Model is a root model.
563  *          2. This model shall support model publication and model subscription.
564  *
565  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
566  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_def_trans_time_srv_t.
567  *
568  *  @return New Generic Default Transition Time Server Model instance.
569  */
570 #define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV(srv_pub, srv_data)             \
571         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV,     \
572                     NULL, srv_pub, srv_data)
573 
574 /** @def    ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV
575  *
576  *  @brief  Define a new Generic Power OnOff Server Model.
577  *
578  *  @note   1. The Generic Power OnOff Server model extends the Generic OnOff Server
579  *             model. When this model is present on an element, the corresponding
580  *             Generic Power OnOff Setup Server model shall also be present.
581  *          2. This model may be used to represent a variety of devices that do not
582  *             fit any of the model descriptions that have been defined but support
583  *             the generic properties of On/Off.
584  *          3. This model shall support model publication and model subscription.
585  *
586  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
587  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_srv_t.
588  *
589  *  @return New Generic Power OnOff Server Model instance.
590  */
591 #define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV(srv_pub, srv_data)             \
592         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV,     \
593                     NULL, srv_pub, srv_data)
594 
595 /** @def    ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV
596  *
597  *  @brief  Define a new Generic Power OnOff Setup Server Model.
598  *
599  *  @note   1. The Generic Power OnOff Setup Server model extends the Generic Power
600  *             OnOff Server model and the Generic Default Transition Time Server model.
601  *          2. This model shall support model subscription.
602  *
603  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
604  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_setup_srv_t.
605  *
606  *  @return New Generic Power OnOff Setup Server Model instance.
607  */
608 #define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV(srv_pub, srv_data)             \
609         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV,     \
610                     NULL, srv_pub, srv_data)
611 
612 /** @def    ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV
613  *
614  *  @brief  Define a new Generic Power Level Server Model.
615  *
616  *  @note   1. The Generic Power Level Server model extends the Generic Power OnOff
617  *             Server model and the Generic Level Server model. When this model is
618  *             present on an Element, the corresponding Generic Power Level Setup
619  *             Server model shall also be present.
620  *          2. This model shall support model publication and model subscription.
621  *
622  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
623  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_srv_t.
624  *
625  *  @return New Generic Power Level Server Model instance.
626  */
627 #define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV(srv_pub, srv_data)             \
628         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV,     \
629                     NULL, srv_pub, srv_data)
630 
631 /** @def    ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV
632  *
633  *  @brief  Define a new Generic Power Level Setup Server Model.
634  *
635  *  @note   1. The Generic Power Level Setup Server model extends the Generic Power
636  *             Level Server model and the Generic Power OnOff Setup Server model.
637  *          2. This model shall support model subscription.
638  *
639  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
640  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_setup_srv_t.
641  *
642  *  @return New Generic Power Level Setup Server Model instance.
643  */
644 #define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV(srv_pub, srv_data)             \
645         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV,     \
646                     NULL, srv_pub, srv_data)
647 
648 /** @def    ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV
649  *
650  *  @brief  Define a new Generic Battery Server Model.
651  *
652  *  @note   1. The Generic Battery Server Model is a root model.
653  *          2. This model shall support model publication and model subscription.
654  *          3. The model may be used to represent an element that is powered by a battery.
655  *
656  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
657  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_battery_srv_t.
658  *
659  *  @return New Generic Battery Server Model instance.
660  */
661 #define ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV(srv_pub, srv_data)             \
662         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV,     \
663                     NULL, srv_pub, srv_data)
664 
665 /** @def    ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV
666  *
667  *  @brief  Define a new Generic Location Server Model.
668  *
669  *  @note   1. The Generic Location Server model is a root model. When this model
670  *             is present on an Element, the corresponding Generic Location Setup
671  *             Server model shall also be present.
672  *          2. This model shall support model publication and model subscription.
673  *          3. The model may be used to represent an element that knows its
674  *             location (global or local).
675  *
676  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
677  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_location_srv_t.
678  *
679  *  @return New Generic Location Server Model instance.
680  */
681 #define ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV(srv_pub, srv_data)             \
682         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV,     \
683                     NULL, srv_pub, srv_data)
684 
685 /** @def    ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV
686  *
687  *  @brief  Define a new Generic Location Setup Server Model.
688  *
689  *  @note   1. The Generic Location Setup Server model extends the Generic Location
690  *             Server model.
691  *          2. This model shall support model subscription.
692  *
693  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
694  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_location_setup_srv_t.
695  *
696  *  @return New Generic Location Setup Server Model instance.
697  */
698 #define ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV(srv_pub, srv_data)             \
699         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV,     \
700                     NULL, srv_pub, srv_data)
701 
702 /** @def    ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV
703  *
704  *  @brief  Define a new Generic User Property Server Model.
705  *
706  *  @note   1. The Generic User Property Server model is a root model.
707  *          2. This model shall support model publication and model subscription.
708  *
709  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
710  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_user_prop_srv_t.
711  *
712  *  @return New Generic User Property Server Model instance.
713  */
714 #define ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(srv_pub, srv_data)             \
715         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV,     \
716                     NULL, srv_pub, srv_data)
717 
718 /** @def    ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV
719  *
720  *  @brief  Define a new Generic Admin Property Server Model.
721  *
722  *  @note   1. The Generic Admin Property Server model extends the Generic User
723  *             Property Server model.
724  *          2. This model shall support model publication and model subscription.
725  *
726  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
727  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_admin_prop_srv_t.
728  *
729  *  @return New Generic Admin Property Server Model instance.
730  */
731 #define ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV(srv_pub, srv_data)            \
732         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV,    \
733                     NULL, srv_pub, srv_data)
734 
735 /** @def    ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV
736  *
737  *  @brief  Define a new Generic Manufacturer Property Server Model.
738  *
739  *  @note   1. The Generic Manufacturer Property Server model extends the Generic
740  *             User Property Server model.
741  *          2. This model shall support model publication and model subscription.
742  *
743  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
744  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_manu_prop_srv_t.
745  *
746  *  @return New Generic Manufacturer Property Server Model instance.
747  */
748 #define ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV(srv_pub, srv_data)            \
749         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV,    \
750                     NULL, srv_pub, srv_data)
751 
752 /** @def    ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV
753  *
754  *  @brief  Define a new Generic User Property Server Model.
755  *
756  *  @note   1. The Generic Client Property Server model is a root model.
757  *          2. This model shall support model publication and model subscription.
758  *
759  *  @param  srv_pub  Pointer to the unique struct esp_ble_mesh_model_pub_t.
760  *  @param  srv_data Pointer to the unique struct esp_ble_mesh_gen_client_prop_srv_t.
761  *
762  *  @return New Generic Client Property Server Model instance.
763  */
764 #define ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV(srv_pub, srv_data)             \
765         ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV,     \
766                     NULL, srv_pub, srv_data)
767 
768 /** Parameters of Generic OnOff state */
769 typedef struct {
770     uint8_t onoff;          /*!< The present value of the Generic OnOff state */
771     uint8_t target_onoff;   /*!< The target value of the Generic OnOff state */
772 } esp_ble_mesh_gen_onoff_state_t;
773 
774 /** User data of Generic OnOff Server Model */
775 typedef struct {
776     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic OnOff Server Model. Initialized internally. */
777     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
778     esp_ble_mesh_gen_onoff_state_t state;       /*!< Parameters of the Generic OnOff state */
779     esp_ble_mesh_last_msg_info_t last;          /*!< Parameters of the last received set message */
780     esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
781 } esp_ble_mesh_gen_onoff_srv_t;
782 
783 /** Parameters of Generic Level state */
784 typedef struct {
785     int16_t level;          /*!< The present value of the Generic Level state */
786     int16_t target_level;   /*!< The target value of the Generic Level state */
787 
788     /**
789      * When a new transaction starts, level should be set to last_last, and use
790      * "level + incoming delta" to calculate the target level. In another word,
791      * "last_level" is used to record "level" of the last transaction, and
792      * "last_delta" is used to record the previously received delta_level value.
793      */
794     int16_t last_level; /*!< The last value of the Generic Level state */
795     int32_t last_delta; /*!< The last delta change of the Generic Level state */
796 
797     bool move_start;    /*!< Indicate if the transition of the Generic Level state has been started */
798     bool positive;      /*!< Indicate if the transition is positive or negative */
799 } esp_ble_mesh_gen_level_state_t;
800 
801 /** User data of Generic Level Server Model */
802 typedef struct {
803     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Level Server Model. Initialized internally. */
804     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
805     esp_ble_mesh_gen_level_state_t state;       /*!< Parameters of the Generic Level state */
806     esp_ble_mesh_last_msg_info_t last;          /*!< Parameters of the last received set message */
807     esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
808     int32_t tt_delta_level;                     /*!< Delta change value of level state transition */
809 } esp_ble_mesh_gen_level_srv_t;
810 
811 /** Parameter of Generic Default Transition Time state */
812 typedef struct {
813     uint8_t trans_time;     /*!< The value of the Generic Default Transition Time state */
814 } esp_ble_mesh_gen_def_trans_time_state_t;
815 
816 /** User data of Generic Default Transition Time Server Model */
817 typedef struct {
818     esp_ble_mesh_model_t *model;                    /*!< Pointer to the Generic Default Transition Time Server Model. Initialized internally. */
819     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;        /*!< Response control of the server model received messages */
820     esp_ble_mesh_gen_def_trans_time_state_t state;  /*!< Parameters of the Generic Default Transition Time state */
821 } esp_ble_mesh_gen_def_trans_time_srv_t;
822 
823 /** Parameter of Generic OnPowerUp state */
824 typedef struct {
825     uint8_t onpowerup;      /*!< The value of the Generic OnPowerUp state */
826 } esp_ble_mesh_gen_onpowerup_state_t;
827 
828 /** User data of Generic Power OnOff Server Model */
829 typedef struct {
830     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Power OnOff Server Model. Initialized internally. */
831     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
832     esp_ble_mesh_gen_onpowerup_state_t *state;  /*!< Parameters of the Generic OnPowerUp state */
833 } esp_ble_mesh_gen_power_onoff_srv_t;
834 
835 /** User data of Generic Power OnOff Setup Server Model */
836 typedef struct {
837     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Power OnOff Setup Server Model. Initialized internally. */
838     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
839     esp_ble_mesh_gen_onpowerup_state_t *state;  /*!< Parameters of the Generic OnPowerUp state */
840 } esp_ble_mesh_gen_power_onoff_setup_srv_t;
841 
842 /** Parameters of Generic Power Level state */
843 typedef struct {
844     uint16_t power_actual;          /*!< The present value of the Generic Power Actual state */
845     uint16_t target_power_actual;   /*!< The target value of the Generic Power Actual state */
846 
847     uint16_t power_last;            /*!< The value of the Generic Power Last state */
848     uint16_t power_default;         /*!< The value of the Generic Power Default state */
849 
850     uint8_t  status_code;           /*!< The status code of setting Generic Power Range state */
851     uint16_t power_range_min;       /*!< The minimum value of the Generic Power Range state */
852     uint16_t power_range_max;       /*!< The maximum value of the Generic Power Range state */
853 } esp_ble_mesh_gen_power_level_state_t;
854 
855 /** User data of Generic Power Level Server Model */
856 typedef struct {
857     esp_ble_mesh_model_t *model;                    /*!< Pointer to the Generic Power Level Server Model. Initialized internally. */
858     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;        /*!< Response control of the server model received messages */
859     esp_ble_mesh_gen_power_level_state_t *state;    /*!< Parameters of the Generic Power Level state */
860     esp_ble_mesh_last_msg_info_t last;              /*!< Parameters of the last received set message */
861     esp_ble_mesh_state_transition_t transition;     /*!< Parameters of state transition */
862     int32_t tt_delta_level;                         /*!< Delta change value of level state transition */
863 } esp_ble_mesh_gen_power_level_srv_t;
864 
865 /** User data of Generic Power Level Setup Server Model */
866 typedef struct {
867     esp_ble_mesh_model_t *model;                    /*!< Pointer to the Generic Power Level Setup Server Model. Initialized internally. */
868     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;        /*!< Response control of the server model received messages */
869     esp_ble_mesh_gen_power_level_state_t *state;    /*!< Parameters of the Generic Power Level state */
870 } esp_ble_mesh_gen_power_level_setup_srv_t;
871 
872 /** Parameters of Generic Battery state */
873 typedef struct {
874     uint32_t battery_level : 8,         /*!< The value of the Generic Battery Level state */
875              time_to_discharge : 24;    /*!< The value of the Generic Battery Time to Discharge state */
876     uint32_t time_to_charge : 24,       /*!< The value of the Generic Battery Time to Charge state */
877              battery_flags : 8;         /*!< The value of the Generic Battery Flags state */
878 } esp_ble_mesh_gen_battery_state_t;
879 
880 /** User data of Generic Battery Server Model */
881 typedef struct {
882     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Battery Server Model. Initialized internally. */
883     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
884     esp_ble_mesh_gen_battery_state_t state;     /*!< Parameters of the Generic Battery state */
885 } esp_ble_mesh_gen_battery_srv_t;
886 
887 /** Parameters of Generic Location state */
888 typedef struct {
889     int32_t  global_latitude;   /*!< The value of the Global Latitude field */
890     int32_t  global_longitude;  /*!< The value of the Global Longitude field */
891     int16_t  global_altitude;   /*!< The value of the Global Altitude field */
892     int16_t  local_north;       /*!< The value of the Local North field */
893     int16_t  local_east;        /*!< The value of the Local East field */
894     int16_t  local_altitude;    /*!< The value of the Local Altitude field */
895     uint8_t  floor_number;      /*!< The value of the Floor Number field */
896     uint16_t uncertainty;       /*!< The value of the Uncertainty field */
897 } esp_ble_mesh_gen_location_state_t;
898 
899 /** User data of Generic Location Server Model */
900 typedef struct {
901     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Location Server Model. Initialized internally. */
902     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
903     esp_ble_mesh_gen_location_state_t *state;   /*!< Parameters of the Generic Location state */
904 } esp_ble_mesh_gen_location_srv_t;
905 
906 /** User data of Generic Location Setup Server Model */
907 typedef struct {
908     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Location Setup Server Model. Initialized internally. */
909     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
910     esp_ble_mesh_gen_location_state_t *state;   /*!< Parameters of the Generic Location state */
911 } esp_ble_mesh_gen_location_setup_srv_t;
912 
913 /** This enum value is the access value of Generic User Property */
914 typedef enum {
915     ESP_BLE_MESH_GEN_USER_ACCESS_PROHIBIT,
916     ESP_BLE_MESH_GEN_USER_ACCESS_READ,
917     ESP_BLE_MESH_GEN_USER_ACCESS_WRITE,
918     ESP_BLE_MESH_GEN_USER_ACCESS_READ_WRITE,
919 } esp_ble_mesh_gen_user_prop_access_t;
920 
921 /** This enum value is the access value of Generic Admin Property */
922 typedef enum {
923     ESP_BLE_MESH_GEN_ADMIN_NOT_USER_PROP,
924     ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ,
925     ESP_BLE_MESH_GEN_ADMIN_ACCESS_WRITE,
926     ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ_WRITE,
927 } esp_ble_mesh_gen_admin_prop_access_t;
928 
929 /** This enum value is the access value of Generic Manufacturer Property */
930 typedef enum {
931     ESP_BLE_MESH_GEN_MANU_NOT_USER_PROP,
932     ESP_BLE_MESH_GEN_MANU_ACCESS_READ,
933 } esp_ble_mesh_gen_manu_prop_access_t;
934 
935 /** Parameters of Generic Property states */
936 typedef struct {
937     uint16_t id;            /*!< The value of User/Admin/Manufacturer Property ID */
938     uint8_t  user_access;   /*!< The value of User Access field */
939     uint8_t  admin_access;  /*!< The value of Admin Access field */
940     uint8_t  manu_access;   /*!< The value of Manufacturer Access field */
941     struct net_buf_simple *val; /*!< The value of User/Admin/Manufacturer Property */
942 } esp_ble_mesh_generic_property_t;
943 
944 /** User data of Generic User Property Server Model */
945 typedef struct {
946     esp_ble_mesh_model_t *model;                    /*!< Pointer to the Generic User Property Server Model. Initialized internally. */
947     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;        /*!< Response control of the server model received messages */
948     uint8_t property_count;                         /*!< Generic User Property count */
949     esp_ble_mesh_generic_property_t *properties;    /*!< Parameters of the Generic User Property state */
950 } esp_ble_mesh_gen_user_prop_srv_t;
951 
952 /** User data of Generic Admin Property Server Model */
953 typedef struct {
954     esp_ble_mesh_model_t *model;                    /*!< Pointer to the Generic Admin Property Server Model. Initialized internally. */
955     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;        /*!< Response control of the server model received messages */
956     uint8_t property_count;                         /*!< Generic Admin Property count */
957     esp_ble_mesh_generic_property_t *properties;    /*!< Parameters of the Generic Admin Property state */
958 } esp_ble_mesh_gen_admin_prop_srv_t;
959 
960 /** User data of Generic Manufacturer Property Server Model */
961 typedef struct {
962     esp_ble_mesh_model_t *model;                    /*!< Pointer to the Generic Manufacturer Property Server Model. Initialized internally. */
963     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;        /*!< Response control of the server model received messages */
964     uint8_t property_count;                         /*!< Generic Manufacturer Property count */
965     esp_ble_mesh_generic_property_t *properties;    /*!< Parameters of the Generic Manufacturer Property state */
966 } esp_ble_mesh_gen_manu_prop_srv_t;
967 
968 /** User data of Generic Client Property Server Model */
969 typedef struct {
970     esp_ble_mesh_model_t *model;                /*!< Pointer to the Generic Client Property Server Model. Initialized internally. */
971     esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl;    /*!< Response control of the server model received messages */
972     uint8_t id_count;                           /*!< Generic Client Property ID count */
973     uint16_t *property_ids;                     /*!< Parameters of the Generic Client Property state */
974 } esp_ble_mesh_gen_client_prop_srv_t;
975 
976 /** Parameter of Generic OnOff Set state change event */
977 typedef struct {
978     uint8_t onoff;          /*!< The value of Generic OnOff state */
979 } esp_ble_mesh_state_change_gen_onoff_set_t;
980 
981 /** Parameter of Generic Level Set state change event */
982 typedef struct {
983     int16_t level;          /*!< The value of Generic Level state */
984 } esp_ble_mesh_state_change_gen_level_set_t;
985 
986 /** Parameter of Generic Delta Set state change event */
987 typedef struct {
988     int16_t level;          /*!< The value of Generic Level state */
989 } esp_ble_mesh_state_change_gen_delta_set_t;
990 
991 /** Parameter of Generic Move Set state change event */
992 typedef struct {
993     int16_t level;          /*!< The value of Generic Level state */
994 } esp_ble_mesh_state_change_gen_move_set_t;
995 
996 /** Parameter of Generic Default Transition Time Set state change event */
997 typedef struct {
998     uint8_t trans_time;     /*!< The value of Generic Default Transition Time state */
999 } esp_ble_mesh_state_change_gen_def_trans_time_set_t;
1000 
1001 /** Parameter of Generic OnPowerUp Set state change event */
1002 typedef struct {
1003     uint8_t onpowerup;      /*!< The value of Generic OnPowerUp state */
1004 } esp_ble_mesh_state_change_gen_onpowerup_set_t;
1005 
1006 /** Parameter of Generic Power Level Set state change event */
1007 typedef struct {
1008     uint16_t power;         /*!< The value of Generic Power Actual state */
1009 } esp_ble_mesh_state_change_gen_power_level_set_t;
1010 
1011 /** Parameter of Generic Power Default Set state change event */
1012 typedef struct {
1013     uint16_t power;         /*!< The value of Generic Power Default state */
1014 } esp_ble_mesh_state_change_gen_power_default_set_t;
1015 
1016 /** Parameters of Generic Power Range Set state change event */
1017 typedef struct {
1018     uint16_t range_min;     /*!< The minimum value of Generic Power Range state */
1019     uint16_t range_max;     /*!< The maximum value of Generic Power Range state */
1020 } esp_ble_mesh_state_change_gen_power_range_set_t;
1021 
1022 /** Parameters of Generic Location Global Set state change event */
1023 typedef struct {
1024     int32_t latitude;       /*!< The Global Latitude value of Generic Location state */
1025     int32_t longitude;      /*!< The Global Longitude value of Generic Location state */
1026     int16_t altitude;       /*!< The Global Altitude value of Generic Location state */
1027 } esp_ble_mesh_state_change_gen_loc_global_set_t;
1028 
1029 /** Parameters of Generic Location Local Set state change event */
1030 typedef struct {
1031     int16_t  north;         /*!< The Local North value of Generic Location state */
1032     int16_t  east;          /*!< The Local East value of Generic Location state */
1033     int16_t  altitude;      /*!< The Local Altitude value of Generic Location state */
1034     uint8_t  floor_number;  /*!< The Floor Number value of Generic Location state */
1035     uint16_t uncertainty;   /*!< The Uncertainty value of Generic Location state */
1036 } esp_ble_mesh_state_change_gen_loc_local_set_t;
1037 
1038 /** Parameters of Generic User Property Set state change event */
1039 typedef struct {
1040     uint16_t id;    /*!< The property id of Generic User Property state */
1041     struct net_buf_simple *value;   /*!< The property value of Generic User Property state */
1042 } esp_ble_mesh_state_change_gen_user_property_set_t;
1043 
1044 /** Parameters of Generic Admin Property Set state change event */
1045 typedef struct {
1046     uint16_t id;        /*!< The property id of Generic Admin Property state */
1047     uint8_t  access;    /*!< The property access of Generic Admin Property state */
1048     struct net_buf_simple *value;   /*!< The property value of Generic Admin Property state */
1049 } esp_ble_mesh_state_change_gen_admin_property_set_t;
1050 
1051 /** Parameters of Generic Manufacturer Property Set state change event */
1052 typedef struct {
1053     uint16_t id;        /*!< The property id of Generic Manufacturer Property state */
1054     uint8_t  access;    /*!< The property value of Generic Manufacturer Property state */
1055 } esp_ble_mesh_state_change_gen_manu_property_set_t;
1056 
1057 /**
1058  * @brief Generic Server Model state change value union
1059  */
1060 typedef union {
1061     /**
1062      * The recv_op in ctx can be used to decide which state is changed.
1063      */
1064     esp_ble_mesh_state_change_gen_onoff_set_t          onoff_set;           /*!< Generic OnOff Set */
1065     esp_ble_mesh_state_change_gen_level_set_t          level_set;           /*!< Generic Level Set */
1066     esp_ble_mesh_state_change_gen_delta_set_t          delta_set;           /*!< Generic Delta Set */
1067     esp_ble_mesh_state_change_gen_move_set_t           move_set;            /*!< Generic Move Set */
1068     esp_ble_mesh_state_change_gen_def_trans_time_set_t def_trans_time_set;  /*!< Generic Default Transition Time Set */
1069     esp_ble_mesh_state_change_gen_onpowerup_set_t      onpowerup_set;       /*!< Generic OnPowerUp Set */
1070     esp_ble_mesh_state_change_gen_power_level_set_t    power_level_set;     /*!< Generic Power Level Set */
1071     esp_ble_mesh_state_change_gen_power_default_set_t  power_default_set;   /*!< Generic Power Default Set */
1072     esp_ble_mesh_state_change_gen_power_range_set_t    power_range_set;     /*!< Generic Power Range Set */
1073     esp_ble_mesh_state_change_gen_loc_global_set_t     loc_global_set;      /*!< Generic Location Global Set */
1074     esp_ble_mesh_state_change_gen_loc_local_set_t      loc_local_set;       /*!< Generic Location Local Set */
1075     esp_ble_mesh_state_change_gen_user_property_set_t  user_property_set;   /*!< Generic User Property Set */
1076     esp_ble_mesh_state_change_gen_admin_property_set_t admin_property_set;  /*!< Generic Admin Property Set */
1077     esp_ble_mesh_state_change_gen_manu_property_set_t  manu_property_set;   /*!< Generic Manufacturer Property Set */
1078 } esp_ble_mesh_generic_server_state_change_t;
1079 
1080 /** Context of the received Generic User Property Get message */
1081 typedef struct {
1082     uint16_t property_id;       /*!< Property ID identifying a Generic User Property */
1083 } esp_ble_mesh_server_recv_gen_user_property_get_t;
1084 
1085 /** Context of the received Generic Admin Property Get message */
1086 typedef struct {
1087     uint16_t property_id;   /*!< Property ID identifying a Generic Admin Property */
1088 } esp_ble_mesh_server_recv_gen_admin_property_get_t;
1089 
1090 /** Context of the received Generic Manufacturer Property message */
1091 typedef struct {
1092     uint16_t property_id;   /*!< Property ID identifying a Generic Manufacturer Property */
1093 } esp_ble_mesh_server_recv_gen_manufacturer_property_get_t;
1094 
1095 /** Context of the received Generic Client Properties Get message */
1096 typedef struct {
1097     uint16_t property_id;   /*!< A starting Client Property ID present within an element */
1098 } esp_ble_mesh_server_recv_gen_client_properties_get_t;
1099 
1100 /**
1101  * @brief Generic Server Model received get message union
1102  */
1103 typedef union {
1104     esp_ble_mesh_server_recv_gen_user_property_get_t         user_property;     /*!< Generic User Property Get */
1105     esp_ble_mesh_server_recv_gen_admin_property_get_t        admin_property;    /*!< Generic Admin Property Get */
1106     esp_ble_mesh_server_recv_gen_manufacturer_property_get_t manu_property;     /*!< Generic Manufacturer Property Get */
1107     esp_ble_mesh_server_recv_gen_client_properties_get_t     client_properties; /*!< Generic Client Properties Get */
1108 } esp_ble_mesh_generic_server_recv_get_msg_t;
1109 
1110 /** Context of the received Generic OnOff Set message */
1111 typedef struct {
1112     bool    op_en;          /*!< Indicate if optional parameters are included */
1113     uint8_t onoff;          /*!< Target value of Generic OnOff state */
1114     uint8_t tid;            /*!< Transaction ID */
1115     uint8_t trans_time;     /*!< Time to complete state transition (optional) */
1116     uint8_t delay;          /*!< Indicate message execution delay (C.1) */
1117 } esp_ble_mesh_server_recv_gen_onoff_set_t;
1118 
1119 /** Context of the received Generic Level Set message */
1120 typedef struct {
1121     bool    op_en;          /*!< Indicate if optional parameters are included */
1122     int16_t level;          /*!< Target value of Generic Level state */
1123     uint8_t tid;            /*!< Transaction ID */
1124     uint8_t trans_time;     /*!< Time to complete state transition (optional) */
1125     uint8_t delay;          /*!< Indicate message execution delay (C.1) */
1126 } esp_ble_mesh_server_recv_gen_level_set_t;
1127 
1128 /** Context of the received Generic Delta Set message */
1129 typedef struct {
1130     bool    op_en;          /*!< Indicate if optional parameters are included */
1131     int32_t delta_level;    /*!< Delta change of Generic Level state */
1132     uint8_t tid;            /*!< Transaction ID */
1133     uint8_t trans_time;     /*!< Time to complete state transition (optional) */
1134     uint8_t delay;          /*!< Indicate message execution delay (C.1) */
1135 } esp_ble_mesh_server_recv_gen_delta_set_t;
1136 
1137 /** Context of the received Generic Move Set message */
1138 typedef struct {
1139     bool    op_en;          /*!< Indicate if optional parameters are included */
1140     int16_t delta_level;    /*!< Delta Level step to calculate Move speed for Generic Level state */
1141     uint8_t tid;            /*!< Transaction ID */
1142     uint8_t trans_time;     /*!< Time to complete state transition (optional) */
1143     uint8_t delay;          /*!< Indicate message execution delay (C.1) */
1144 } esp_ble_mesh_server_recv_gen_move_set_t;
1145 
1146 /** Context of the received Generic Default Transition Time Set message */
1147 typedef struct {
1148     uint8_t trans_time;     /*!< The value of the Generic Default Transition Time state */
1149 } esp_ble_mesh_server_recv_gen_def_trans_time_set_t;
1150 
1151 /** Context of the received Generic OnPowerUp Set message */
1152 typedef struct {
1153     uint8_t onpowerup;      /*!< The value of the Generic OnPowerUp state */
1154 } esp_ble_mesh_server_recv_gen_onpowerup_set_t;
1155 
1156 /** Context of the received Generic Power Level Set message */
1157 typedef struct {
1158     bool     op_en;         /*!< Indicate if optional parameters are included */
1159     uint16_t power;         /*!< Target value of Generic Power Actual state */
1160     uint8_t  tid;           /*!< Transaction ID */
1161     uint8_t  trans_time;    /*!< Time to complete state transition (optional) */
1162     uint8_t  delay;         /*!< Indicate message execution delay (C.1) */
1163 } esp_ble_mesh_server_recv_gen_power_level_set_t;
1164 
1165 /** Context of the received Generic Power Default Set message */
1166 typedef struct {
1167     uint16_t power;         /*!< The value of the Generic Power Default state */
1168 } esp_ble_mesh_server_recv_gen_power_default_set_t;
1169 
1170 /** Context of the received Generic Power Range Set message */
1171 typedef struct {
1172     uint16_t range_min;     /*!< Value of Range Min field of Generic Power Range state */
1173     uint16_t range_max;     /*!< Value of Range Max field of Generic Power Range state */
1174 } esp_ble_mesh_server_recv_gen_power_range_set_t;
1175 
1176 /** Context of the received Generic Location Global Set message */
1177 typedef struct {
1178     int32_t global_latitude;    /*!< Global Coordinates (Latitude) */
1179     int32_t global_longitude;   /*!< Global Coordinates (Longitude) */
1180     int16_t global_altitude;    /*!< Global Altitude */
1181 } esp_ble_mesh_server_recv_gen_loc_global_set_t;
1182 
1183 /** Context of the received Generic Location Local Set message */
1184 typedef struct {
1185     int16_t  local_north;       /*!< Local Coordinates (North) */
1186     int16_t  local_east;        /*!< Local Coordinates (East) */
1187     int16_t  local_altitude;    /*!< Local Altitude */
1188     uint8_t  floor_number;      /*!< Floor Number */
1189     uint16_t uncertainty;       /*!< Uncertainty */
1190 } esp_ble_mesh_server_recv_gen_loc_local_set_t;
1191 
1192 /** Context of the received Generic User Property Set message */
1193 typedef struct {
1194     uint16_t property_id;   /*!< Property ID identifying a Generic User Property */
1195     struct net_buf_simple *property_value;  /*!< Raw value for the User Property */
1196 } esp_ble_mesh_server_recv_gen_user_property_set_t;
1197 
1198 /** Context of the received Generic Admin Property Set message */
1199 typedef struct {
1200     uint16_t property_id;   /*!< Property ID identifying a Generic Admin Property */
1201     uint8_t  user_access;   /*!< Enumeration indicating user access */
1202     struct net_buf_simple *property_value;  /*!< Raw value for the Admin Property */
1203 } esp_ble_mesh_server_recv_gen_admin_property_set_t;
1204 
1205 /** Context of the received Generic Manufacturer Property Set message */
1206 typedef struct {
1207     uint16_t property_id;   /*!< Property ID identifying a Generic Manufacturer Property */
1208     uint8_t  user_access;   /*!< Enumeration indicating user access */
1209 } esp_ble_mesh_server_recv_gen_manufacturer_property_set_t;
1210 
1211 /**
1212  * @brief Generic Server Model received set message union
1213  */
1214 typedef union {
1215     esp_ble_mesh_server_recv_gen_onoff_set_t                 onoff;             /*!< Generic OnOff Set/Generic OnOff Set Unack */
1216     esp_ble_mesh_server_recv_gen_level_set_t                 level;             /*!< Generic Level Set/Generic Level Set Unack */
1217     esp_ble_mesh_server_recv_gen_delta_set_t                 delta;             /*!< Generic Delta Set/Generic Delta Set Unack */
1218     esp_ble_mesh_server_recv_gen_move_set_t                  move;              /*!< Generic Move Set/Generic Move Set Unack */
1219     esp_ble_mesh_server_recv_gen_def_trans_time_set_t        def_trans_time;    /*!< Generic Default Transition Time Set/Generic Default Transition Time Set Unack */
1220     esp_ble_mesh_server_recv_gen_onpowerup_set_t             onpowerup;         /*!< Generic OnPowerUp Set/Generic OnPowerUp Set Unack */
1221     esp_ble_mesh_server_recv_gen_power_level_set_t           power_level;       /*!< Generic Power Level Set/Generic Power Level Set Unack */
1222     esp_ble_mesh_server_recv_gen_power_default_set_t         power_default;     /*!< Generic Power Default Set/Generic Power Default Set Unack */
1223     esp_ble_mesh_server_recv_gen_power_range_set_t           power_range;       /*!< Generic Power Range Set/Generic Power Range Set Unack */
1224     esp_ble_mesh_server_recv_gen_loc_global_set_t            location_global;   /*!< Generic Location Global Set/Generic Location Global Set Unack */
1225     esp_ble_mesh_server_recv_gen_loc_local_set_t             location_local;    /*!< Generic Location Local Set/Generic Location Local Set Unack */
1226     esp_ble_mesh_server_recv_gen_user_property_set_t         user_property;     /*!< Generic User Property Set/Generic User Property Set Unack */
1227     esp_ble_mesh_server_recv_gen_admin_property_set_t        admin_property;    /*!< Generic Admin Property Set/Generic Admin Property Set Unack */
1228     esp_ble_mesh_server_recv_gen_manufacturer_property_set_t manu_property;     /*!< Generic Manufacturer Property Set/Generic Manufacturer Property Set Unack */
1229 } esp_ble_mesh_generic_server_recv_set_msg_t;
1230 
1231 /**
1232  * @brief Generic Server Model callback value union
1233  */
1234 typedef union {
1235     esp_ble_mesh_generic_server_state_change_t state_change;    /*!< ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT */
1236     esp_ble_mesh_generic_server_recv_get_msg_t get;     /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT */
1237     esp_ble_mesh_generic_server_recv_set_msg_t set;     /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT */
1238 } esp_ble_mesh_generic_server_cb_value_t;
1239 
1240 /** Generic Server Model callback parameters */
1241 typedef struct {
1242     esp_ble_mesh_model_t  *model;   /*!< Pointer to Generic Server Models */
1243     esp_ble_mesh_msg_ctx_t ctx;     /*!< Context of the received messages */
1244     esp_ble_mesh_generic_server_cb_value_t value;   /*!< Value of the received Generic Messages */
1245 } esp_ble_mesh_generic_server_cb_param_t;
1246 
1247 /** This enum value is the event of Generic Server Model */
1248 typedef enum {
1249     /**
1250      * 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
1251      *    callback to the application layer when Generic Get messages are received.
1252      * 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
1253      *    be callback to the application layer when Generic Set/Set Unack messages
1254      *    are received.
1255      */
1256     ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT,
1257     /**
1258      * When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
1259      * callback to the application layer when Generic Get messages are received.
1260      */
1261     ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT,
1262     /**
1263      * When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
1264      * callback to the application layer when Generic Set/Set Unack messages are received.
1265      */
1266     ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT,
1267     ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX,
1268 } esp_ble_mesh_generic_server_cb_event_t;
1269 
1270 /**
1271  *  @brief Bluetooth Mesh Generic Server Model function.
1272  */
1273 
1274 /**
1275  * @brief   Generic Server Model callback function type
1276  * @param   event: Event type
1277  * @param   param: Pointer to callback parameter
1278  */
1279 typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event,
1280                                                   esp_ble_mesh_generic_server_cb_param_t *param);
1281 
1282 /**
1283  * @brief       Register BLE Mesh Generic Server Model callback.
1284  *
1285  * @param[in]   callback: Pointer to the callback function.
1286  *
1287  * @return      ESP_OK on success or error code otherwise.
1288  *
1289  */
1290 esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback);
1291 
1292 #ifdef __cplusplus
1293 }
1294 #endif
1295 
1296 #endif /* _ESP_BLE_MESH_GENERIC_MODEL_API_H_ */
1297