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