• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved.
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 
16 /**
17  ****************************************************************************************
18  * @file sonata_mesh_api.h
19  *
20  * @brief header file - mesh api
21  *
22  ****************************************************************************************
23  */
24 
25 #ifndef _SONATA_MESH_API_H_
26 #define _SONATA_MESH_API_H_
27 
28 /*
29  * INCLUDE FILES
30  ****************************************************************************************
31  */
32 #include "sonata_utils_api.h"
33 
34 /**
35  * @defgroup SONATA_MESH_API Mesh API
36  * @{
37  */
38 
39 /**
40  * @defgroup PROFILE Mesh Profile
41  * @ingroup SONATA_MESH_API
42  * @brief Mesh Profile
43  * @{
44  */
45 
46 /*
47  * DEFINE
48  **********************************************************
49  */
50 
51 // System Address Length
52 #define MESH_ADDR_LEN              6
53 // UUID Length
54 #define MESH_UUID_LEN              16
55 // Keys Length
56 #define MESH_KEYS_LEN              16
57 
58 // Appkey Invaild local Index
59 #define MESH_APPKEY_INVALID_LID    (0xFFFF)
60 /**@} PROFILE */
61 
62 /**
63  * @defgroup ERROR Error Code
64  * @brief Error Code
65  * @ingroup SONATA_MESH_API
66  * @{
67  */
68 
69 // Not Ready
70 #define MESH_ERROR_NOT_READY       (-2)
71 // Invalid Parameter
72 #define MESH_ERROR_INVALID_PARAM   (-1)
73 // No Error
74 #define MESH_ERROR_NO_ERROR         (0)
75 // No Space
76 #define MESH_ERROR_NO_SPACE         (1)
77 /**@} ERROR */
78 
79 /**
80  * @defgroup PROVISION Provison
81  * @brief Provision
82  * @ingroup SONATA_MESH_API
83  * @{
84  */
85 
86 // Max size of Auth value
87 #define MESH_PROVISION_AUTH_MAX_NUM 16
88 /**@} PROVISION */
89 
90 /**
91  * @defgroup MODELS Mesh Models
92  * @brief Mesh Models
93  * @ingroup SONATA_MESH_API
94  * @{
95  */
96 
97 // Max number of Mesh Model
98 #define MESH_MODEL_NUM_MAX         (10)
99 // Invalid Mesh Model Local Index
100 #define MESH_MODEL_INVALID_LID     (0xFF)
101 #define MESH_VENDOR_MODEL_NUM_MAX   (2)
102 
103 /****************** Model IDs *******************/
104 
105 // Generic Server - OnOff
106 #define MESH_MODELID_GENS_OO           (0x1000)
107 // Generic Server - Level
108 #define MESH_MODELID_GENS_LVL          (0x1002)
109 // Generic Server - Default Transition Time
110 #define MESH_MODELID_GENS_DTT          (0x1004)
111 // Generic Server - Power OnOff
112 #define MESH_MODELID_GENS_POO          (0x1006)
113 // Generic Server - Power OnOff Setup
114 #define MESH_MODELID_GENS_POOS         (0x1007)
115 // Generic Server - Power Level
116 #define MESH_MODELID_GENS_PLVL         (0x1009)
117 // Generic Server - Power Level Setup
118 #define MESH_MODELID_GENS_PLVLS        (0x100A)
119 // Generic Server - Battery
120 #define MESH_MODELID_GENS_BAT          (0x100C)
121 // Generic Server - Location
122 #define MESH_MODELID_GENS_LOC          (0x100E)
123 // Generic Server - Location Setup
124 #define MESH_MODELID_GENS_LOCS         (0x100F)
125 // Generic Server - User Property
126 #define MESH_MODELID_GENS_UPROP        (0x1013)
127 // Generic Server - Admin Property
128 #define MESH_MODELID_GENS_APROP        (0x1011)
129 // Generic Server - Manufacturer Property
130 #define MESH_MODELID_GENS_MPROP        (0x1012)
131 // Generic Server - Client Property
132 #define MESH_MODELID_GENS_CPROP        (0x1014)
133 
134 // Generic Client - OnOff
135 #define MESH_MODELID_GENC_OO           (0x1001)
136 // Generic Client - Level
137 #define MESH_MODELID_GENC_LVL          (0x1003)
138 
139 // Lighting Server - Light Lightness
140 #define MESH_MODELID_LIGHTS_LN         (0x1300)
141 // Lighting Server - Light CTL
142 #define MESH_MODELID_LIGHTS_CTL        (0x1303)
143 // Lighting Server - Light HSL
144 #define MESH_MODELID_LIGHTS_HSL        (0x1307)
145 
146 // Ali Vendor Sever Model ID
147 #define MESH_MODELID_VENDOR_ALI        (0x01A80000)
148 // asr vendor sever model ID
149 #define MESH_MODELID_VENS_ASR          (0x09170002)
150 /// asr vendor client model ID
151 #define MESH_MODELID_VENC_ASR          (0x09170001)
152 // a
153 /*********** MESSAGE LENGTH******************/
154 
155 // Minimal length of Generic OnOff Set/Set Unacknowledged message
156 #define MESH_MODELID_GEN_OO_SET_MIN_LEN              (2)
157 // Length of Generic OnOff Set/Set Unacknowledged message when all field are present
158 #define MESH_MODELID_GEN_OO_SET_LEN                  (4)
159 // Minimal length of Generic OnOff Status message
160 #define MESH_MODELID_GEN_OO_STATUS_MIN_LEN           (1)
161 // Length of Generic OnOff Status message when all fields are present
162 #define MESH_MODELID_GEN_OO_STATUS_LEN               (3)
163 
164 // Minimal length of Generic Level Set/Set Unacknowledged message
165 #define MESH_MODELID_GEN_LVL_SET_MIN_LEN             (3)
166 // Length of Generic Level Set/Set Unacknowledged message when all field are present
167 #define MESH_MODELID_GEN_LVL_SET_LEN                 (5)
168 // Minimal length of Generic Delta Set/Set Unacknowledged message
169 #define MESH_MODELID_GEN_LVL_SET_DELTA_MIN_LEN       (5)
170 // Length of Generic Delta Set/Set Unacknowledged message when all field are present
171 #define MESH_MODELID_GEN_LVL_SET_DELTA_LEN           (7)
172 // Minimal length of Generic Move Set/Set Unacknowledged message
173 #define MESH_MODELID_GEN_LVL_SET_MOVE_MIN_LEN        (3)
174 // Length of Generic Move Set/Set Unacknowledged message when all field are present
175 #define MESH_MODELID_GEN_LVL_SET_MOVE_LEN            (5)
176 // Minimal length of Generic Level Status message
177 #define MESH_MODELID_GEN_LVL_STATUS_MIN_LEN          (2)
178 // Length of Generic Level Status message when all fields are present
179 #define MESH_MODELID_GEN_LVL_STATUS_LEN              (5)
180 
181 /**@} MODELS */
182 
183 /**
184  * @addtogroup PROVISION
185  * @{
186  */
187 
188 /*
189  *ENUMERATIONS
190  **********************************************************
191  */
192 
193 // Algorithms field values
194 enum mesh_prov_algo {
195     // Bit[0]: FIPS P-256 Elliptic Curve
196     MESH_PROV_ALGO_FIPS_P256_ELLIPTIC_CURVE = 0x0001,
197     /// < Bit[1-15]: Reserved for Future Use
198 };
199 
200 // Public Key Type field values
201 enum mesh_prov_pub_key_val {
202     // No OOB Public Key is used
203     MESH_PROV_PUB_KEY_OOB_NOT_USED = 0x00,
204     // OOB Public Key is used
205     MESH_PROV_PUB_KEY_OOB_USED     = 0x01,
206 
207     MESH_PROV_PUB_KEY_OOB_MAX,
208 };
209 
210 // Authentication Method field values
211 enum mesh_prov_auth_method {
212     // No OOB authentication is used
213     MESH_PROV_AUTH_NO_OOB,
214     // Static OOB authentication is used
215     MESH_PROV_AUTH_STATIC_OOB,
216     // Output OOB authentication is used
217     MESH_PROV_AUTH_OUTPUT_OOB,
218     // Input OOB authentication is used
219     MESH_PROV_AUTH_INPUT_OOB,
220 };
221 
222 // Static OOB Type field values
223 enum mesh_prov_static_oob {
224     // Bit[0]: Static OOB information available
225     MESH_PROV_STATIC_OOB_AVAILABLE = 0x01,
226     /// < Bit[1-7]: Prohibited
227 };
228 
229 // Output OOB Action field values
230 enum mesh_prov_out_oob {
231     // Bit[0]: Blink
232     MESH_PROV_OUT_OOB_BLINK          = 0x0001,
233     // Bit[1]: Beep
234     MESH_PROV_OUT_OOB_BEEP           = 0x0002,
235     // Bit[2]: Vibrate
236     MESH_PROV_OUT_OOB_VIBRATE        = 0x0004,
237     // Bit[3]: Output Numeric
238     MESH_PROV_OUT_OOB_NUMERIC        = 0x0008,
239     // Bit[4]: Output Alphanumeric
240     MESH_PROV_OUT_OOB_ALPHANUMERIC   = 0x0010,
241     /// < Bit[5-15]: Reserved for Future Use
242 };
243 
244 // Input OOB Action field values
245 enum mesh_prov_in_oob {
246     // Bit[0]: Push
247     MESH_PROV_IN_OOB_PUSH             = 0x0001,
248     // Bit[1]: Twist
249     MESH_PROV_IN_OOB_TWIST            = 0x0002,
250     // Bit[2]: Input Numeric
251     MESH_PROV_IN_OOB_NUMERIC          = 0x0004,
252     // Bit[3]: Input Alphanumeric
253     MESH_PROV_IN_OOB_ALPHANUMERIC     = 0x0008,
254     /// < Bit[4-15]: Reserved for Future Use
255 };
256 
257 /**
258 * @brief enum Role bit meaning
259 */
260 typedef enum {
261     // Device Role
262     MESH_PROV_ROLE_DEVICE       = 0x00,
263     // Provisioner Role
264     MESH_PROV_ROLE_PROVISIONER  = 0x01,
265 } mesh_prov_role_t;
266 
267 /**@}*/
268 
269 /**
270  * @addtogroup PROFILE
271  * @{
272  */
273 
274 /**
275 * @brief enum Mesh Supported Features
276 */
277 enum mesh_user_api_feat {
278     // Relay Node
279     MESH_FEAT_RELAY_NODE_SUP       = (1 << 0),
280     // Proxy Node
281     MESH_FEAT_PROXY_NODE_SUP       = (1 << 1),
282     // Friend Node
283     MESH_FEAT_FRIEND_NODE_SUP      = (1 << 2),
284     // Low Power Node
285     MESH_FEAT_LOW_POWER_NODE_SUP   = (1 << 3),
286 };
287 
288 /**
289 * @brief enum Mesh param set type
290 */
291 typedef enum {
292     // Role
293     MESH_ROLE,
294     // Addr
295     MESH_SYSTEM_ADDR,
296     // Addr Type
297     MESH_ADDR_TYPE,
298     // Provision Param for UnProv Device
299     MESH_PROV_PARAM,
300     // Node Feature
301     MESH_FEATURE_SUPPORT,
302     // Relay Transmit
303     MESH_RELAY_TRANSMIT,
304     // Network Transmit
305     MESH_NETWORK_TRANSMIT,
306     // Default TTL
307     MESH_DEFAULT_TTL,
308     // System timing
309     MESH_RUNNING_TIME,
310     // Friend Params
311     MESH_FRIEND_PARAM,
312     // Data Save Interval
313     MESH_DATA_SAVE_INTERVAL,
314     // NetKey Used By Provisioner
315     MESH_PROVISIONER_NETKEY,
316     // AppKey Used By Provisioner
317     MESH_PROVISIONER_APPKEY,
318     // Addr Pool Used By Provisioner
319     MESH_PROVISIONER_ADDR_POOL,
320     // mesh model replay number
321     MESH_NUMBER_REPLAY,
322 } mesh_param_opr_types_t;
323 
324 /**
325 * @brief enum Mesh addr type
326 */
327 typedef enum {
328     // Public Addr
329     MESH_PUBLIC_ADDR,
330     // Private Static Addr
331     MESH_PRIVATE_STATIC_ADDR,
332     // Resolvable Private Random Addr
333     MESH_RSLV_ADDR,
334     // Non-Resolvable Private Random Addr
335     MESH_NON_RSLV_ADDR,
336 } mesh_addr_types_t;
337 
338 /**
339 * @brief enum  sys cmd type
340 */
341 typedef enum {
342     // Reboot Sys
343     MESH_SYS_REBOOT,
344     // Erase Data And Reboot, Node Will Be Unprovisioned
345     MESH_SYS_RESET,
346 } mesh_sys_cmd_t;
347 
348 /**
349 * @brief enum core evt indicate type
350 */
351 typedef enum {
352     // Request Public Key OOB Info
353     MESH_PUBLIC_KEY_REQUEST,
354     // Request Auth Data OOB Info
355     MESH_AUTH_OOB_IND,
356     // Indicate Attation Time
357     MESH_ATTATION_IND,
358     // Indicate Current Provision State
359     MESH_PROVISION_STATE,
360     // Indicate MODEL And APPKEY Binding Info
361     MESH_APPKEY_BINDING,
362     // Indicate APPKEY Update
363     MESH_APPKEY_UPDATE,
364     // Indicate MODEL And APPKEY Binded
365     MESH_APPKEY_BINDED,
366     // Indicate MODEL Model Has Subscribed To A Group Addr
367     MESH_GRPADDR_SUBSED,
368     // Indicate Local NetKey Update
369     MESH_NETKEY_UPDATE,
370     // Indicate Local NetKey Set Compelete
371     MESH_NETKEY_SET_CMP,
372     // Indicate Local AppKey Set Compelete
373     MESH_APPKEY_SET_CMP,
374     // Indicate Local Model & App Compelete
375     MESH_MODEL_APP_BIND_CMP,
376     // Indicate Local Publish Set Compelete
377     MESH_PUB_SET_CMP,
378     // Indicate Local Addr Set Compelete
379     MESH_ADDR_SET_CMP,
380     // Indicate Self Addr Alloced By Provisioner
381     MESH_SELF_ADDR_IND,
382     /// Indicate run time
383     MESH_GET_RUN_TIME,
384     // Indicate Publish Addr Update
385     MESH_PUB_UPDATE,
386     // Indicate Sub Addrs Update
387     MESH_SUBS_UPDATE,
388     // Indicate Self Dev Key
389     MESH_SELF_DEV_KEY_IND,
390     // Indicate Self Dev Key
391     MESH_SELF_IV_SEQ_IND,
392     // Indicate Friend Offer
393     MESH_FRIEND_OFFER_IND,
394     // Indicate lowpower Node Status
395     MESH_LPN_STATUS_IND,
396     // Indicate  Lowpower Start CmdCompelete
397     MESH_LOWPOWER_START_CMP,
398     // Indicate  Lowpower Stop Cmd Compelete
399     MESH_LOWPOWER_STOP_CMP,
400     // Indicate  Lowpower Select Friend Cmd Compelete
401     MESH_LOWPOWER_SELECT_FRIEND_CMP,
402 } mesh_core_evt_ind_t;
403 /** @} */
404 
405 /**
406  * @addtogroup PROVISION
407  * @{
408  */
409 
410 // State of the provisioning
411 enum mesh_prov_state {
412     // Provisioning started - procedure started by a provisioner
413     MESH_PROV_STARTED,
414     // Provisioning succeed
415     MESH_PROV_SUCCEED,
416     // Provisioning failed
417     MESH_PROV_FAILED,
418 };
419 
420 /**
421 * @brief enum core provisioner evt indicate type
422 */
423 typedef enum {
424     // Indicate Provisioner found a device
425     MESH_PROV_DEVICE_IND,
426     // Indicate Peer Capability
427     MESH_PROVISIONER_PROV_CAP_IND,
428     // Request Provision Auth Data
429     MESH_PROVISIONER_PROV_AUTH_REQ,
430     // Request Provision Auth Data
431     MESH_PROVISIONER_PROVISIONING_DATA_REQ,
432     // Indicate Provisioning Result
433     MESH_PROVISIONER_STATE_IND,
434     // Indicate  Appkey Add Result
435     MESH_PROVISIONER_APPKEY_ADD_STATUS,
436     // Indicate Model App Bind Result
437     MESH_PROVISIONER_MODEL_APP_IND,
438     // Indicate Composition Data
439     MESH_PROVISIONER_COMPOSITION_DATA,
440     // Indicate Set Sub Result
441     MESH_PROV_SET_SUBS_IND,
442     // Indicate Set Remote Publish Result
443     MESH_PROV_SET_PUBLISH_IND,
444     // Indicate Set Local Publish Result
445     MESH_PROV_SET_LOCAL_PUBLISH_IND,
446     // Indicate Add Node Result
447     MESH_PROV_ADD_LOCAL_NODE_IND,
448     // Indicate Delete Local Node Result
449     MESH_PROV_DELETE_LOCAL_NODE_IND,
450     // Indicate Remote NetTransmit Status
451     MESH_PROV_NETTRANSMIT_IND,
452 } mesh_core_provisioner_evt_ind_t;
453 
454 /**
455 * @brief enum  app notify sys to compelete evt type
456 */
457 typedef enum {
458     // App Input Public Key OOB Info
459     MESH_PUBLIC_KEY_SET,
460     // App Input Auth Data OOB Info
461     MESH_AUTH_DATA_SET,
462     // Setting Local Netkey
463     MESH_SET_LOCAL_NETKEY,
464     // Setting Local Appkey
465     MESH_SET_LOCAL_APPKEY,
466     // Bind Local Model & AppKey
467     MESH_SET_LOCAL_MODEL_APP_BIND,
468     // Setting Local Publish Param
469     MESH_SET_LOCAL_PUBLISH_PARAM,
470     // Setting Local Sub Param
471     MESH_SET_LOCAL_SUBS_PARAM,
472     // Setting Local dev key
473     MESH_SET_LOCAL_DEV_KEY,
474     // Setting Local primary addr
475     MESH_SET_LOCAL_PRIM_ADDR,
476     // Setting Local iv index and seq no
477     MESH_SET_LOCAL_IV_SEQ,
478     // App Start Node LPN, Stack Will Send Friend Request
479     MESH_LOWPOWER_NODE_START,
480     // App Stop Node LPN, Clean Up Friendship
481     MESH_LOWPOWER_NODE_STOP,
482     // App Select Friend
483     MESH_LOWPOWER_SELECT_FRIEND,
484     // App Set Friend State
485     MESH_SET_LOCAL_FRIEND_STATE,
486 } mesh_core_evt_cb_t;
487 
488 /**
489 * @brief enum  app notify sys to compelete provisoner evt type
490 */
491 typedef enum {
492     // App Confrim To Provision A Device
493     MESH_PROV_PROVISION_DEVICE,
494     // Confirm selected Capability
495     MESH_PROVISIONER_PROV_CAP_CFM,
496     // Confirm Provision Auth Data
497     MESH_PROVISIONER_PROV_AUTH_CFM,
498     // Request Provision Auth Data
499     MESH_PROVISIONER_PROVISIONING_DATA_CFM,
500     // Provisioner To Get Composition Data
501     MESH_PROV_GET_COMPOSITION_DATA,
502     // Provisioner Add APPKEY To Node
503     MESH_PROV_ADD_APPKEY,
504     // Provisioner Bind Mpdel And Appkey
505     MESH_PROV_MODEL_APP_BIND,
506     // Provisioner Bind Mpdel And Appkey
507     MESH_PROV_MODEL_APP_UNBIND,
508     // Provisioner Setting Sub Param
509     MESH_PROV_SET_SUBS_PARAM,
510     // Provisioner Add Provisioned Node
511     MESH_PROV_ADD_LOCAL_NODE,
512     // Provisioner Delete Provisioned Node
513     MESH_PROV_DEL_LOCAL_NODE,
514     // Provisioner Set Local Addr
515     MESH_PROV_SET_LOCAL_ADDR,
516     // Provisioner Setting Sub Param
517     MESH_PROV_SET_PUB_PARAM,
518     // Provisioner Setting Net Transmit Param
519     MESH_PROV_SET_NETTRANSMIT_PARAM,
520 } mesh_core_provisioner_evt_cb_t;
521 
522 /**
523 * @brief enum  Proxy connectable advertising control values
524 */
525 typedef enum mesh_proxy_broadcast_ctl {
526     // Stop connectable advertising
527     MESH_PROXY_ADV_STOP = 0,
528     // Start connectable advertising with Node Identity (duration = 60s)
529     MESH_PROXY_ADV_START_NODE_ID,
530     // Start connectable advertising with Network ID (duration = 60s)
531     MESH_PROXY_ADV_START_NET,
532 } mesh_proxy_broadcast_ctl_t;
533 
534 /**@}*/
535 
536 /**
537  * @addtogroup MODELS
538  * @{
539  */
540 
541 /*
542  * ENUMERATIONS (MESSAGE CONTENT)
543  ****************************************************************************************
544  */
545 
546 // Positions in Generic OnOff Set/Set Unacknowledged message
547 enum mesh_model_gen_oo_set_pos {
548     // OnOff state value
549     MESH_MODEL_GEN_OO_SET_OO_POS = 0,
550     // TID value
551     MESH_MODEL_GEN_OO_SET_TID_POS,
552     // Transition time value
553     MESH_MODEL_GEN_OO_SET_TRANS_TIME_POS,
554     // Delay value
555     MESH_MODEL_GEN_OO_SET_DELAY_POS,
556 };
557 
558 // Positions in Generic OnOff Status message
559 enum mesh_model_gen_oo_status_pos {
560     // Present OnOff state value
561     MESH_MODEL_GEN_OO_STATUS_OO_POS = 0,
562     // Target OnOff state value
563     MESH_MODEL_GEN_OO_STATUS_TGT_OO_POS,
564     // Remaining time value
565     MESH_MODEL_GEN_OO_STATUS_REM_TIME_POS,
566 };
567 
568 // Positions in Generic Level Set/Set Unacknowledged message
569 enum mesh_model_gen_lvl_set_pos {
570     // Level value
571     MESH_MODEL_GEN_LVL_SET_LVL_POS = 0,
572     // TID value
573     MESH_MODEL_GEN_LVL_SET_TID_POS = 2,
574     // Transition time value
575     MESH_MODEL_GEN_LVL_SET_TRANS_TIME_POS,
576     // Delay value
577     MESH_MODEL_GEN_LVL_SET_DELAY_POS,
578 };
579 
580 /**
581 * @brief enum  model state
582 */
583 typedef enum {
584     // Generic OnOff state
585     MESH_STATE_GEN_ONOFF = 0,
586     // Generic Level state
587     MESH_STATE_GEN_LVL,
588     // Generic Default Transition Time state
589     MESH_STATE_GEN_DTT,
590     // Generic Power Actual state
591     MESH_STATE_GEN_POWER_ACTUAL,
592     // Generic Power Last state
593     MESH_STATE_GEN_POWER_LAST,
594     // Generic Power Default state
595     MESH_STATE_GEN_POWER_DFLT,
596     // Generic Power Range state
597     MESH_STATE_GEN_POWER_RANGE,
598     // Generic OnPowerUp state
599     MESH_STATE_GEN_ONPOWERUP,
600 
601     // Light Lightness
602     MESH_STATE_LIGHT_LN = 50,
603     // Light Lightness Linear
604     MESH_STATE_LIGHT_LN_LIN,
605     // Light Lightness Last
606     MESH_STATE_LIGHT_LN_LAST,
607     // Light Lightness Default
608     MESH_STATE_LIGHT_LN_DFLT,
609     // Light Lightness Range
610     MESH_STATE_LIGHT_LN_RANGE,
611     // Light Lightness Range Min
612     MESH_STATE_LIGHT_LN_RANGE_MIN,
613     // Light Lightness Range Max
614     MESH_STATE_LIGHT_LN_RANGE_MAX,
615 
616     // Light CTL Lightness
617     MESH_STATE_LIGHT_CTL_LN = 100,
618     // Light CTL Temperature
619     MESH_STATE_LIGHT_CTL_TEMP,
620     // Light CTL Delta UV
621     MESH_STATE_LIGHT_CTL_DELTA_UV,
622     // Light CTL Temperature Default
623     MESH_STATE_LIGHT_CTL_TEMP_DFLT,
624     // Light CTL Temperature Range
625     MESH_STATE_LIGHT_CTL_TEMP_RANGE,
626     // Light CTL Delta UV Default
627     MESH_STATE_LIGHT_CTL_DELTA_UV_DFLT,
628 
629     // Light HSL Lightness
630     MESH_STATE_LIGHT_HSL_LN = 150,
631     // Light HSL Hue
632     MESH_STATE_LIGHT_HSL_HUE,
633     // Light HSL Saturation
634     MESH_STATE_LIGHT_HSL_SAT,
635     // Light HSL Target
636     MESH_STATE_LIGHT_HSL_TGT,
637     // Light HSL Default (Lightness + Hue + Saturation)
638     MESH_STATE_LIGHT_HSL_DFLT,
639     // Light HSL Lightness Default
640     MESH_STATE_LIGHT_HSL_DFLT_LN,
641     // Light HSL Hue Default
642     MESH_STATE_LIGHT_HSL_DFLT_HUE,
643     // Light HSL Saturation Default
644     MESH_STATE_LIGHT_HSL_DFLT_SAT,
645     // Light HSL Hue Range
646     MESH_STATE_LIGHT_HSL_RANGE_HUE,
647     // Light HSL Saturation Range
648     MESH_STATE_LIGHT_HSL_RANGE_SAT,
649 
650     // Light xyL Lightness
651     MESH_STATE_LIGHT_XYL_LN = 200,
652     // Light xyL x and y
653     MESH_STATE_LIGHT_XYL_XY,
654     // Light xyL Lightness Target
655     MESH_STATE_LIGHT_XYL_LN_TGT,
656     // Light xyL x and y Target
657     MESH_STATE_LIGHT_XYL_XY_TGT,
658     // Light xyL Lightness Default
659     MESH_STATE_LIGHT_XYL_LN_DFLT,
660     // Light xyL x and y Default
661     MESH_STATE_LIGHT_XYL_XY_DFLT,
662     // Light xyL x and y Range
663     MESH_STATE_LIGHT_XYL_XY_RANGE
664 } mesh_state_type_t;
665 
666 // Mesh Scan Opr Module Define,
667 typedef enum {
668     USER_APP_INVALID_MODULE_ID,
669     USER_APP_MODULE_ID,
670     USER_WF_MODULE_ID,
671     USER_AT_MODULE_ID,
672     USER_MAX_MODULE_ID
673 } mesh_scan_opr_module_id_t;
674 
675 /*
676  * TYPE DEFINITIONS
677 **********************************************************
678 */
679 
680 // Model ID
681 typedef uint32_t modelid_t;
682 // Model Local Index
683 typedef uint8_t mesh_lid_t;
684 // Status
685 typedef int32_t STATUS     ;
686 
687 /**@}*/
688 
689 /**
690  * @addtogroup PROFILE
691  * @{
692  */
693 
694 // role struct
695 typedef struct {
696     // Role
697     uint8_t role;
698 } mesh_role_t;
699 
700 /**@} PROFILE */
701 
702 /**
703  * @addtogroup PROVISION
704  * @{
705  */
706 
707 /**
708 * @brief   provision param
709 */
710 typedef struct {
711     // Device UUID
712     uint8_t uuid[MESH_UUID_LEN];
713     // URI Hash
714     uint8_t *p_uri;
715     // Static OOB information available
716     uint8_t  static_oob;
717     // Static OOB information len
718     uint8_t   static_oob_len;
719     // OOB information
720     uint8_t oob_info;
721     // Supported Public Key OOB
722     uint8_t  pub_key_oob;
723     // Maximum size of Output OOB supported
724     uint8_t output_size;
725     // Supported Output OOB Actions
726     uint8_t output_actions;
727     // Maximum size in octets of Input OOB supported
728     uint8_t input_size;
729     // Supported Input OOB Actions
730     uint8_t input_actions;
731     // 16-bit company identifier assigned by the Bluetooth SIG
732     uint16_t cid;
733     // 16-bit vendor-assigned product identifier
734     uint16_t pid;
735     // 16-bit vendor-assigned product version identifier
736     uint16_t vid;
737     // Localization descriptor
738     uint16_t loc;
739 } mesh_prov_param_t;
740 /**@}*/
741 
742 /**
743  * @addtogroup PROFILE
744  * @{
745  */
746 
747 /**
748 * @brief   friend param
749 */
750 typedef struct {
751     // Number of addresses that can be stored for Message Replay Protection
752     uint16_t nb_addr_replay;
753     // Receive window in milliseconds when Friend feature is supported
754     uint8_t frd_rx_window_ms;
755     // Queue size when Friend feature is supported
756     uint8_t frd_queue_size;
757 } mesh_friend_param_t;
758 
759 /**
760 * @brief   mesh support feature such as relay/proxy/friend
761 */
762 typedef struct {
763     // Mask of supported features (@see enum mesh_user_api_feat)
764     uint32_t feature;  // m_user_api_feat
765 } mesh_feature_support_param_t;
766 
767 /**
768 * @brief   mesh adv interval and count
769 */
770 typedef struct {
771     // Advertising Count
772     uint8_t count;
773     // Advertising interval in ms
774     uint8_t interval;
775 } mesh_transmit_param_t;
776 
777 /**
778 * @brief   mesh default ttl
779 */
780 typedef struct {
781     // TTL
782     uint8_t ttl;
783 } mesh_default_ttl_param_t;
784 
785 /**
786 * @brief   current time of unit ms from  power off
787 */
788 typedef struct {
789     // Current clock value in milliseconds
790     uint32_t time_ms;
791     // Number of time the clock has wrapped since up time
792     uint16_t wrap;
793 } mesh_running_time_t;
794 
795 /**
796 * @brief   interval of saving data
797 */
798 typedef struct {
799     // Data Save interval
800     uint32_t time_secs;
801 } mesh_data_save_interval_t;
802 
803 /**
804 * @brief   addr type struct
805 */
806 typedef struct {
807     // Addr
808     mesh_addr_types_t type ;
809 } mesh_system_addr_type_t;
810 /** @} */
811 
812 /**
813  * @addtogroup PROVISION
814  * @{
815  */
816 
817 /**
818 * @brief   provisioner netkey set  struct
819 */
820 typedef struct {
821     // opr
822     bool addOrDel;
823     // key
824     uint8_t netkey[MESH_KEYS_LEN];
825     // key_index
826     uint16_t key_index;
827 } mesh_provisioner_netkey_t;
828 
829 /**
830 * @brief   provisioner appkey struct
831 */
832 typedef struct {
833     // opr
834     bool addOrDel;
835     // key
836     uint8_t appkey[MESH_KEYS_LEN];
837     // key_index
838     uint16_t key_index;
839     // netkey_index
840     uint16_t netkey_index;
841 } mesh_provisioner_appkey_t;
842 
843 /**
844 * @brief   provisioner addr pool struct
845 */
846 typedef struct {
847     /// provisioner addr pool start
848     uint16_t addr_start ;
849     /// provisioner addr pool end
850     uint16_t addr_end   ;
851     /// used by provisioner to communicate to unprov device
852     uint16_t addr_self  ;
853 } mesh_provisioner_addr_pool_t;
854 
855 /**
856 * @brief   mesh set params union structure
857 */
858 typedef union {
859     /// Role struct
860     mesh_role_t mesh_role;
861     /// provision param
862     mesh_prov_param_t prov_param;
863     /// mesh support feature such as relay/proxy/friend
864     mesh_feature_support_param_t feature_param;
865     /// mesh adv interval and count
866     mesh_transmit_param_t network_transmit;
867     /// mesh adv interval and count
868     mesh_transmit_param_t relay_transmit;
869     /// mesh default ttl
870     mesh_default_ttl_param_t default_ttl;
871     /// current time of unit ms from  power off
872     mesh_running_time_t running_time;
873     /// friend param
874     mesh_friend_param_t friend;
875     /// interval of saving data
876     mesh_data_save_interval_t interval;
877     ///addr type struct
878     mesh_system_addr_type_t addr_type;
879     /// provisioner netkey set  struct
880     mesh_provisioner_netkey_t netkey;
881     /// provisioner appkey struct
882     mesh_provisioner_appkey_t appkey;
883     /// provisioner addr pool struct
884     mesh_provisioner_addr_pool_t addr_pool;
885     /// mesh model repaly number
886     uint8_t replay_number;
887 } mesh_set_params_t;
888 /**@}*/
889 
890 /**
891  * @addtogroup PROFILE
892  * @{
893  */
894 
895 /**
896 * @brief   addr struce
897 */
898 typedef struct {
899     // Addr
900     uint8_t bd_addr[MESH_ADDR_LEN];
901 } mesh_system_addr_t;
902 
903 /**
904 * @brief   mesh get params union structure
905 */
906 typedef union {
907     mesh_system_addr_t addr;
908 } mesh_get_params_t;
909 
910 /**@}*/
911 
912 /**
913  * @addtogroup MODELS
914  * @{
915  */
916 
917 /**
918 * @brief   Inform reception of a specific mesh message
919 */
920 typedef struct {
921     // Model ID
922     uint32_t model_id;
923     /// Element index of the message
924     uint8_t element;
925     // Application Key Local identifier (Required for a response)
926     uint16_t   appkey_global_index;
927     // Measured RSSI level for the received PDU.
928     int8_t   rssi;
929     // 1 = if message have been received by an immediate peer; 0 = it can have been relayed
930     uint8_t  not_relayed;
931     // Mesh message operation code (can be 1, 2 or 3 octet operation code)
932     uint32_t opcode;
933     // Source address of the message (Required for a response)
934     uint16_t src;
935     // Message length
936     uint16_t msg_len;
937     // Message content
938     uint8_t  *msg;
939 } mesh_api_model_msg_rx_t;
940 
941 // Mesh Vendor Model Message Rx
942 typedef  void (* m_vendor_model_msg_rx_t)(mesh_api_model_msg_rx_t *pkt);
943 
944 /**
945 * @brief   server send msg params
946 */
947 typedef struct {
948     // Index of element the model belongs to (zero based)
949     uint8_t element;
950     // Application Key Local identifier (Required for a response)
951     int8_t   mic_64;
952     // TTL
953     int8_t   ttl;
954     // Application Key Global Index
955     int16_t  appkey_global_index;
956     // Model ID
957     uint32_t modelid;
958     // Mesh message operation code (can be 1, 2 or 3 octet operation code)
959     uint32_t opcode;
960     // Dst address of the message (Required for a response)
961     uint16_t dst;
962     // Message length
963     uint16_t msg_len;
964     // Message content
965     uint8_t  msg[__ARRAY_EMPTY];
966 } mesh_model_msg_param_t;
967 
968 // Mesh Model Message Sent Callback
969 typedef  void (* model_msg_sent_cb)(mesh_model_msg_param_t *p_param, STATUS status) ;
970 
971 // OnOff state value set structure
972 typedef struct {
973     // OnOff state value
974     uint8_t onoff;
975 } generic_onoff_set_param_t;
976 
977 // Level state value set structure
978 typedef struct {
979     // Level state value
980     uint32_t value;
981 } generic_level_set_param_t;
982 
983 // Lightness state value set structure
984 typedef struct {
985     // Lightness state value
986     uint16_t lightness;
987 } generic_lightness_set_param_t;
988 
989 /**
990  * @brief   client send msg union struct
991  */
992 typedef union {
993     /// OnOff state value set structure
994     generic_onoff_set_param_t onoff;
995     /// Level state value set structure
996     generic_level_set_param_t level;
997     /// Lightness state value set structure
998     generic_lightness_set_param_t lightness;
999 } generic_client_params_t;
1000 
1001 /**
1002 * @brief enum client msg send type
1003 */
1004 typedef enum {
1005     // Generic OnOff Set
1006     MESH_MSG_GEN_OO_SET,
1007     // Generic OnOff Set Unacknowledged
1008     MESH_MSG_GEN_OO_SET_UNACK,
1009 } mesh_client_msg_t;
1010 
1011 // mesh client msg param structure
1012 typedef struct {
1013     // Msg Type (@see mesh_client_msg_t)
1014     mesh_client_msg_t msg_type;
1015     // Transition time in milliseconds
1016     uint32_t trans_time_ms;
1017     // Destination
1018     uint16_t dst;
1019     // Delay in milliseconds
1020     uint16_t delay_ms;
1021     // Index of element the model belongs to (zero based)
1022     uint8_t  element;
1023     // Model ID
1024     modelid_t  modelid;
1025     // Application Key Global Index
1026     uint16_t  appkey_global_index;
1027     // Msg Send param
1028     generic_client_params_t set_param;
1029 } mesh_client_msg_param_t;
1030 
1031 // Client Message Sent Callback
1032 typedef  STATUS (* client_msg_sent_cb)(mesh_client_msg_param_t *p_param, STATUS status) ;
1033 
1034 /**@}*/
1035 
1036 /**
1037 *@addtogroup PROVISION
1038 *@{
1039 */
1040 
1041 // Authentication data param structure
1042 typedef struct {
1043     // Authentication Method used
1044     uint8_t method;
1045     // Size of the Output OOB used or size of the Input OOB used or 0x00
1046     uint8_t size;
1047     // Selected Output OOB Action or Input OOB Action or 0x00
1048     uint8_t action;
1049 } prov_auth_data_set_param_t;
1050 
1051 // prov Authentication data param structure
1052 typedef union {
1053     prov_auth_data_set_param_t prov_auth_data;
1054 } mesh_core_evt_set_params_t;
1055 
1056 // Node Provision State indicate structure
1057 typedef struct {
1058     // Node Provision State
1059     uint8_t state;
1060 } prov_state_ind_param_t;
1061 
1062 // Appkey Binding Indicate Parameter
1063 typedef struct {
1064     // Indicate To Add(1) Or Del(0) Binding Info
1065     uint8_t bind;
1066     // Index of element the model belongs to (zero based)
1067     uint8_t element;
1068     // Application Key Global Index
1069     uint16_t appkey_global_index;
1070     // Model ID
1071     uint32_t modelid;
1072 } appkey_binding_ind_param_t;
1073 
1074 // Unprovison Device uuid
1075 typedef struct {
1076     // Device uuid
1077     uint8_t uuid[MESH_UUID_LEN];
1078 } prov_unprov_device_ind_t;
1079 
1080 // Provision Provisioner state indicate structure
1081 typedef struct {
1082     // Device uuid
1083     uint8_t  uuid[MESH_UUID_LEN];
1084     // Device key
1085     uint8_t  devkey[MESH_KEYS_LEN];
1086     // Netkey Index
1087     uint16_t netkey_index;
1088     // Address
1089     uint16_t addr;
1090     // Element number
1091     uint16_t elm_nb;
1092     // state
1093     uint8_t  state;
1094 } prov_provisioner_state_ind_t;
1095 
1096 // Provisioner Appkey Add Status structure
1097 typedef struct {
1098     /// Srouce Address
1099     uint16_t src_addr;
1100     /// Appkey Index
1101     uint16_t appkey_index;
1102     /// Netkey Index
1103     uint16_t netkey_index;
1104     /// Status
1105     uint8_t status;
1106 } provisioner_appkey_add_status_t;
1107 
1108 // Provisioner Model application status structure
1109 typedef struct {
1110     /// Element Address
1111     uint16_t element_addr;
1112     /// Appkey Index
1113     uint16_t appkey_index;
1114     /// Netkey Index
1115     uint16_t netkey_index;
1116     /// Model Id
1117     uint32_t model_id;
1118     /// Status
1119     uint8_t status;
1120 } provisioner_model_app_status_t;
1121 
1122 // Provisioner Subcribe Add Status structure
1123 typedef struct {
1124     /// Status
1125     uint8_t status;
1126     /// Element Address
1127     uint16_t element_addr;
1128     /// Subcribe Address
1129     uint16_t sub_addr;
1130     /// Model ID
1131     uint32_t model_id;
1132 } provisioner_subs_add_status_t;
1133 
1134 // Provisioner Composition Data structure
1135 typedef struct {
1136     // Source Addr
1137     uint16_t src_addr;
1138     // Data Length
1139     uint16_t length;
1140     // Value
1141     uint8_t val[__ARRAY_EMPTY];
1142 } provisioner_composition_data_t;
1143 
1144 // Procision Select Device Parameter structure
1145 typedef struct {
1146     // Device uuid
1147     uint8_t uuid[MESH_UUID_LEN];
1148     // Indicate To Provision(1) Or Not(0)
1149     bool select;
1150 } prov_select_device_param_t;
1151 
1152 // supported provisioning capabilities indicate structure
1153 typedef struct {
1154     // Device uuid
1155     uint8_t uuid[MESH_UUID_LEN];
1156     //    Algorithms
1157     uint16_t algorithms;
1158     // Supported public key types
1159     uint8_t  pub_key_type;
1160     // Supported static OOB Types
1161     uint8_t  static_oob_type;
1162     // Maximum size of Output OOB supported
1163     uint8_t  out_oob_size;
1164     // Supported Output OOB Actions
1165     uint16_t out_oob_action;
1166     // Maximum size in octets of Input OOB supported
1167     uint8_t  in_oob_size;
1168     // Supported Input OOB Actions
1169     uint16_t in_oob_action;
1170 } provisioner_prov_cap_ind_t;
1171 
1172 // supported provisioning capabilities confirm structure
1173 typedef struct {
1174     // Device uuid
1175     uint8_t uuid[MESH_UUID_LEN];
1176     //    Algorithms
1177     uint8_t  algorithms;
1178     // Public Key used
1179     uint8_t  pub_key;
1180     // Authentication Method used
1181     uint8_t  auth_method;
1182     // Selected Output OOB Action or Input OOB Action or 0x00
1183     uint8_t  auth_action;
1184     // Size of the Output OOB used or size of the Input OOB used or 0x00
1185     uint8_t  auth_size;
1186 } provisioner_prov_cap_cfm_t;
1187 
1188 // Provisioner Provsion Auth Request structure
1189 typedef struct {
1190     // Device uuid
1191     uint8_t uuid[MESH_UUID_LEN];
1192     ///
1193     uint8_t  auth_method;
1194     // expected authentication maximum data size
1195     uint8_t  auth_size;
1196     // Authentication Action:
1197     //   - MESH_PROV_AUTH_NO_OOB     = Prohibited
1198     //   - MESH_PROV_AUTH_STATIC_OOB = 16 bytes LSB static out of band data required
1199     //   - MESH_PROV_AUTH_OUTPUT_OOB
1200     //   - MESH_PROV_AUTH_INPUT_OOB
1201     uint16_t auth_action;
1202 } provisioner_prov_auth_req_t;
1203 
1204 // Provision Provision Auth Confirm structure
1205 typedef struct {
1206     // Device uuid
1207     uint8_t uuid[MESH_UUID_LEN];
1208     // 1, Accept pairing request, 0 reject
1209     uint8_t  accept;
1210     // Authentication data size (<= requested size else pairing automatically rejected)
1211     uint8_t  auth_size;
1212     // Authentication data (LSB for a number or array of bytes)
1213     uint8_t  auth_data[MESH_PROVISION_AUTH_MAX_NUM];
1214 } provisioner_prov_auth_cfm_t;
1215 
1216 // Provisioner provisioning data parameter structure
1217 typedef struct {
1218     // Device uuid
1219     uint8_t uuid[MESH_UUID_LEN];
1220     // Element num
1221     uint16_t elm_nb;
1222 } provisioner_provisioning_data_param_t;
1223 
1224 // Provisioner Publish Set status structure
1225 typedef struct {
1226     /// Status
1227     uint8_t status;
1228     /// Element Address
1229     uint16_t element_addr;
1230     /// Publish Address
1231     uint16_t pub_addr;
1232     /// Publish Appkey Index
1233     uint16_t appkey_index : 12;
1234     /// Publish Friendship CredentialFlag
1235     uint16_t credentialFlag : 1;
1236     /// Reserved for Future Use
1237     uint16_t rfu : 3;
1238     /// Default TTL value for the outgoing messages
1239     uint8_t  ttl;
1240     /// Period for periodic status publishing
1241     uint8_t  period;
1242     /// Number of retransmissions for each published message
1243     uint8_t  retransmitCount : 3;
1244     /// Number of 50-millisecond steps between retransmissions
1245     uint8_t  retransmitIntervalSteps : 5;
1246     /// Model Identifier
1247     uint32_t model_id;
1248 } provisioner_pub_set_status_t;
1249 
1250 // Network Transmit Status structure
1251 typedef struct {
1252     /// Source Address
1253     uint16_t src_addr;
1254     /// Network Transmit Count
1255     uint8_t  retransmitCount : 3;
1256     /// Network Transmit Interval Steps
1257     uint8_t  retransmitIntervalSteps : 5;
1258 } provisioner_nettransmit_status_t;
1259 
1260 // Mesh Core Provision Event Indicate Parameter union
1261 typedef union {
1262 
1263     /// Unprovison Device uuid
1264     prov_unprov_device_ind_t        unprov_device_ind;
1265     /// Provision Provisioner state indicate structure
1266     prov_provisioner_state_ind_t    provision_state_ind;
1267     /// Provisioner Appkey Add Status structure
1268     provisioner_appkey_add_status_t appkey_add_status;
1269     /// Provisioner Model application status structure
1270     provisioner_model_app_status_t  model_app_status;
1271     /// Provisioner Composition Data structure
1272     provisioner_composition_data_t  composition_data;
1273     /// Provisioner Subcribe Add Status structure
1274     provisioner_subs_add_status_t   sub_add_status;
1275     /// supported provisioning capabilities indicate structure
1276     provisioner_prov_cap_ind_t      prov_cap;
1277     // Provisioner Provsion Auth Request structure
1278     provisioner_prov_auth_req_t     prov_auth;
1279     /// Provisioner provisioning data parameter structure
1280     provisioner_provisioning_data_param_t     prov_data;
1281     /// Provisioner Publish Set status structure
1282     provisioner_pub_set_status_t    pub_set_status;
1283     /// Network Transmit Status structure
1284     provisioner_nettransmit_status_t nettransmit_status;
1285 } mesh_core_provisioner_evt_ind_params_t;
1286 
1287 /**
1288 * @brief   provisioner netkey struct
1289 */
1290 typedef struct mesh_set_local_netkey {
1291     // opr
1292     bool addOrDel;
1293     // key
1294     uint8_t netkey[MESH_KEYS_LEN];
1295     // key_index
1296     uint16_t key_index;
1297 } mesh_set_local_netkey_t;
1298 
1299 /**
1300 * @brief   provisioner appkey struct
1301 */
1302 typedef struct mesh_set_local_appkey {
1303     // opr
1304     bool addOrDel;
1305     // key
1306     uint8_t appkey[MESH_KEYS_LEN];
1307     // key_index
1308     uint16_t key_index;
1309     uint16_t netkey_index;
1310 } mesh_set_local_appkey_t;
1311 
1312 /**
1313 * @brief  Model App Bind message structure
1314 */
1315 typedef struct mesh_set_local_model_app_bind {
1316     /// Element Address
1317     uint16_t element_addr;
1318     /// Model Identifier
1319     uint32_t model_id;
1320     /// Appkey Index
1321     uint16_t appkey_index;
1322 } mesh_set_local_model_app_bind_t;
1323 
1324 // Mesh Model Local Publication set structure
1325 typedef struct mesh_local_pub_set {
1326     /// Element Address
1327     uint16_t element_addr;
1328     /// Value of the Publish Address
1329     uint16_t pub_addr;
1330     /// Index of the application key
1331     uint16_t appkey_index : 12;
1332     /// Publish Friendship CredentialFlag
1333     uint16_t credentialFlag : 1;
1334     /// Reserved for Future Use
1335     uint16_t rfu : 3;
1336     /// Default TTL value for the outgoing messages
1337     uint8_t  ttl;
1338     /// Period for periodic status publishing
1339     uint8_t  period;
1340     /// Number of retransmissions for each published message
1341     uint8_t  retransmitCount : 3;
1342     /// Number of 50-millisecond steps between retransmissions
1343     uint8_t  retransmitIntervalSteps : 5;
1344     /// Model Identifier
1345     uint32_t model_id;
1346 } mesh_local_pub_set_t;
1347 
1348 // Structure For Appkey Update Ind
1349 typedef struct mesh_appkey_update_ind {
1350     // AppKey index
1351     uint16_t appkey_index;
1352     // AppKey
1353     uint8_t  key[MESH_KEYS_LEN];
1354     // Added (> 0) or deleted (= 0)
1355     uint8_t added;
1356 } mesh_appkey_update_ind_t;
1357 
1358 // Structure For Netkey Update Ind
1359 typedef struct mesh_netkey_update_ind {
1360     // Netkey index
1361     uint16_t netkey_index;
1362     // Network Key
1363     uint8_t  key[MESH_KEYS_LEN];
1364     // Added (> 0) or deleted (= 0)
1365     uint8_t added;
1366 } mesh_netkey_update_ind_t;
1367 
1368 // Structure For Self Addr Ind
1369 typedef struct mesh_self_addr_ind {
1370     // Addr
1371     uint16_t addr;
1372 } mesh_self_addr_ind_t;
1373 
1374 // Structure For get run time Ind
1375 typedef struct mesh_get_run_time_ind {
1376     // Addr
1377     uint32_t clock_ms;
1378     uint16_t nb_wrap;
1379 
1380 } mesh_get_run_time_ind_t;
1381 
1382 // Structure For Dev Key Ind
1383 typedef struct mesh_dev_key_ind {
1384     uint8_t key[MESH_KEYS_LEN];
1385 } mesh_dev_key_ind_t;
1386 
1387 // Structure For pulish addr  Ind
1388 typedef struct mesh_publish_addr_ind {
1389     uint16_t element_addr;
1390     // Model ID
1391     uint32_t model_id;
1392     // Publication address
1393     uint16_t addr;
1394     // AppKey ID
1395     uint16_t appkey_index;
1396     // TTL
1397     uint8_t  ttl;
1398     // Period
1399     uint8_t  period;
1400     // Retransmission parameters
1401     uint8_t  retx_params;
1402     // Friend credentials
1403     uint8_t  friend_cred;
1404     // Label UUID
1405     uint8_t  label_uuid[MESH_UUID_LEN];
1406 } mesh_publish_addr_ind_t;
1407 
1408 // Structure For sub addr  Ind
1409 typedef struct mesh_sub_addr_ind {
1410     uint16_t element_addr;
1411     // Sub address
1412     uint16_t addr;
1413     // Model ID
1414     uint32_t model_id;
1415     // Label UUID
1416     uint8_t  label_uuid[MESH_UUID_LEN];
1417     // Add (> 0) or deleted (= 0)
1418     uint8_t  addOrDel;
1419 } mesh_sub_addr_ind_t;
1420 
1421 // Structure For iv seq Ind
1422 typedef struct mesh_iv_seq_ind {
1423     // IV Index
1424     uint32_t iv;
1425     // Seq NO
1426     uint32_t seq;
1427 } mesh_iv_seq_ind_t;
1428 
1429 // Structure For Friend Offer Ind
1430 typedef struct mesh_friend_offer_ind {
1431     uint16_t friend_addr;
1432     uint8_t  rx_window;
1433     uint8_t  queue_size;
1434     uint8_t  subs_list_size;
1435     int8_t   rssi;
1436 } mesh_friend_offer_ind_t;
1437 
1438 // Structure For Friend Offer Ind
1439 typedef struct mesh_lowper_status_ind {
1440     uint16_t friend_addr;
1441     uint16_t  status;
1442 } mesh_lowper_status_ind_t;
1443 
1444 // Structure For Friend Offer Ind
1445 typedef struct mesh_cmp_status_ind {
1446     uint16_t status;
1447 } mesh_cmp_status_ind_t;
1448 
1449 // Mesh  Set Local Subcribtion
1450 typedef struct mesh_set_local_subs {
1451     // Add (> 0) or deleted (= 0)
1452     uint8_t  addOrDel;
1453     /// Element Address
1454     uint16_t element_addr;
1455     /// Subcribe Address
1456     uint16_t sub_addr;
1457     /// Model Identifier
1458     uint32_t  model_id;
1459 } mesh_set_local_subs_t;
1460 
1461 // Mesh Provisioner Set Primary Addr
1462 typedef struct mesh_set_local_prim_addr {
1463     uint16_t addr;
1464 } mesh_set_local_prim_addr_t;
1465 
1466 // Mesh  Set Local Dev key
1467 typedef struct mesh_set_local_dev_key {
1468     uint8_t dev_key[MESH_KEYS_LEN];
1469 } mesh_set_local_dev_key_t;
1470 
1471 // Mesh  Set Local Iv Index And Seq NO
1472 typedef struct mesh_set_local_iv_seq {
1473     uint32_t iv;
1474     uint32_t seq;
1475 } mesh_set_local_iv_seq_t;
1476 
1477 // Mesh  start lpn
1478 typedef struct mesh_start_lpn_param {
1479     uint32_t poll_timeout_100ms;
1480     uint32_t poll_intv_ms;
1481     uint16_t prev_addr;
1482     uint8_t  rx_delay;
1483     uint8_t  rssi_factor;
1484     uint8_t  rx_window_factor;
1485     uint8_t  min_queue_size_log;
1486 } mesh_start_lpn_param_t;
1487 
1488 // Mesh  select friend
1489 typedef struct mesh_select_friend_param {
1490     uint16_t addr;
1491 } mesh_select_friend_param_t;
1492 
1493 // Mesh  Set friend state
1494 typedef struct mesh_set_friend_state {
1495     uint32_t state;
1496 } mesh_set_friend_state_t;
1497 
1498 // Mesh Core Event indicate parameters structure
1499 typedef union {
1500     /// Authentication data param structure
1501     prov_auth_data_set_param_t prov_auth_data_param;
1502     /// Node Provision State indicate structure
1503     prov_state_ind_param_t prov_state_ind;
1504     // Appkey Binding Indicate Parameter
1505     appkey_binding_ind_param_t appkey_bind;
1506     // Structure For Appkey Update Ind
1507     mesh_appkey_update_ind_t   appkey_update_ind;
1508     // Structure For Netkey Update Ind
1509     mesh_netkey_update_ind_t   netkey_updata_ind;
1510     // Structure For Self Addr Ind
1511     mesh_self_addr_ind_t       self_addr_ind;
1512     /// structture for get run time
1513     mesh_get_run_time_ind_t    run_time_ind;
1514     /// structure for dev key
1515     mesh_dev_key_ind_t    dev_key;
1516     /// structure for iv index  and seq no
1517     mesh_iv_seq_ind_t iv_seq;
1518     /// structure for friend offer info
1519     mesh_friend_offer_ind_t friend_offer;
1520     /// structure for status ind
1521     mesh_cmp_status_ind_t status_ind;
1522     /// structure for lowpower node status ind
1523     mesh_lowper_status_ind_t lpn_status;
1524 } mesh_core_evt_ind_params_t;
1525 
1526 // Mesh Core Event callback parameter structure
1527 typedef union {
1528     /// provisioner appkey struct
1529     mesh_set_local_appkey_t              local_appkey_set;
1530     /// provisioner netkey struct
1531     mesh_set_local_netkey_t              local_netkey_set;
1532     /// Model App Bind message structure
1533     mesh_set_local_model_app_bind_t      local_model_app_bind;
1534     /// Mesh Model Local Publication set structure
1535     mesh_local_pub_set_t                 local_pub_set;
1536     /// Mesh  Set Local Subcribtion
1537     mesh_set_local_subs_t    local_sub_set;
1538     /// Mesh  Set Local Primary addr
1539     mesh_set_local_prim_addr_t prim_addr;
1540     /// Mesh  Set Local Dev key
1541     mesh_set_local_dev_key_t   local_dev_key;
1542     /// Mesh  Set Local iv and seq
1543     mesh_set_local_iv_seq_t    local_iv_seq;
1544     /// Mesh  Start lpn
1545     mesh_start_lpn_param_t     lpn_param;
1546     /// Mesh  Select Friend
1547     mesh_select_friend_param_t  friend_param;
1548     /// structure for local friend state
1549     mesh_set_friend_state_t friend_state;
1550 } mesh_core_evt_cb_params_t;
1551 
1552 // Provision Get Composition Structure
1553 typedef struct mesh_provisioner_get_composition {
1554     /// Destination Address
1555     uint16_t dst;
1556     /// Index of the Network key
1557     uint16_t netkey_index;
1558     /// Page number of the Composition Data
1559     uint8_t page;
1560 } mesh_provisioner_get_composition_t;
1561 
1562 // Provisioner Add Appkey Structure
1563 typedef struct mesh_provisioner_add_appkey {
1564     /// Destination Address
1565     uint16_t dst;
1566     /// Index of the Network key
1567     uint16_t netkey_index;
1568     /// Index of the Application key
1569     uint16_t appkey_index;
1570     /// Application key
1571     uint8_t appkey[MESH_KEYS_LEN];
1572 } mesh_provisioner_add_appkey_t;
1573 
1574 // Provisioner Model App Bind Structure
1575 typedef struct mesh_provisioner_mmodel_app {
1576     /// Destination Address
1577     uint16_t dst;
1578     /// Element Address
1579     uint16_t element_addr;
1580     /// Index of the Network key
1581     uint16_t netkey_index;
1582     /// Index of the Application key
1583     uint16_t appkey_index;
1584     /// Model identifier
1585     uint32_t model_id;
1586 } mesh_provisioner_model_app_t;
1587 
1588 // Provisioner Subcription Set Structure
1589 typedef struct mesh_provisioner_subs_set {
1590     // Added (> 0) or deleted (= 0)
1591     uint8_t  addOrDel;
1592     /// Element Address
1593     uint16_t element_addr;
1594     /// Subcription Address
1595     uint16_t sub_addr;
1596     /// Index of Network key
1597     uint16_t netkey_index;
1598     /// Model identifier
1599     uint32_t model_id;
1600 } mesh_provisioner_subs_set_t;
1601 
1602 // Provisioner Node Delete Structure
1603 typedef struct mesh_provisioner_node_delete {
1604     /// Node Address
1605     uint16_t addr;
1606 } mesh_provisioner_node_delete_t;
1607 
1608 // Provisioner Node Add Structure
1609 typedef struct mesh_provisioner_node_add {
1610     /// Device key
1611     uint8_t  devkey[MESH_KEYS_LEN];
1612     /// Netkey Index
1613     uint16_t netkey_index;
1614     /// Address
1615     uint16_t addr;
1616     /// Element number
1617     uint16_t elm_nb;
1618 } mesh_provisioner_node_add_t;
1619 
1620 // Node Address Set Structure
1621 typedef struct mesh_provisioner_addr_set {
1622     /// Node Address
1623     uint16_t addr;
1624 } mesh_provisioner_addr_set_t;
1625 
1626 // Mesh Provision Data confirm Structure
1627 typedef struct  mesh_prov_data_cfm {
1628     uint8_t uuid[MESH_UUID_LEN];
1629     // Network Key
1630     uint8_t  net_key[MESH_KEYS_LEN];
1631     // Network Key Index
1632     uint16_t netkey_index;
1633     // Unicast Address of the primary element
1634     uint16_t unicast_addr;
1635 } mesh_prov_data_cfm_t;
1636 
1637 // Mesh Provisioner Set Pubication Parameter Structure
1638 typedef struct mesh_provisioner_set_pub_param {
1639     /// Element Address
1640     uint16_t element_addr;
1641     /// Value of the publish address
1642     uint16_t pub_addr;
1643     /// Index of the application key
1644     uint16_t appkey_index : 12;
1645     /// Value of the Friendship Credential Flag
1646     uint16_t credentialFlag : 1;
1647     /// Reserved for Future Use
1648     uint16_t rfu : 3;
1649     /// Default TTL value for the outgoing messages
1650     uint8_t  ttl;
1651     /// Period for periodic status publishing
1652     uint8_t  period;
1653     /// Number of retransmissions for each published message
1654     uint8_t  retransmitCount : 3;
1655     /// Number of 50-millisecond steps between retransmissions
1656     uint8_t  retransmitIntervalSteps : 5;
1657     /// Model Identifier
1658     uint32_t model_id;
1659     /// Index of the Network key
1660     uint16_t netkey_index;
1661 } mesh_provisioner_set_pub_param_t;
1662 
1663 // Mesh Provisioner set nettransmit parameter Structure
1664 typedef struct mesh_provisioner_set_nettransmit_param {
1665     /// Address of Element
1666     uint16_t element_addr;
1667     /// Index of Netkey
1668     uint16_t netkey_index;
1669     /// Number of transmissions for each Network PDU originating from the node
1670     uint8_t  retransmitCount : 3;
1671     /// Number of 10-millisecond steps between transmissions
1672     uint8_t  retransmitIntervalSteps : 5;
1673 } mesh_provisioner_set_nettransmit_param_t;
1674 
1675 // Mesh Core Provisioner Event Callback Parameter Union
1676 typedef union {
1677     /// Procision Select Device Parameter structure
1678     prov_select_device_param_t         unprov_device_param;
1679     // supported provisioning capabilities confirm structure
1680     provisioner_prov_cap_cfm_t         prov_cap_cfm_param;
1681     // Provision Provision Auth Confirm structure
1682     provisioner_prov_auth_cfm_t        prov_auth_cfm_param;
1683     /// Mesh Provision Data confirm Structure
1684     mesh_prov_data_cfm_t               prov_data_cfm_param;
1685     /// Provision Get Composition Structure
1686     mesh_provisioner_get_composition_t get_composition_data;
1687     /// Provisioner Add Appkey Structure
1688     mesh_provisioner_add_appkey_t      add_appkey;
1689     /// Provisioner Model App Bind Structure
1690     mesh_provisioner_model_app_t       model_app_bind;
1691     /// Provisioner Subcription Set Structure
1692     mesh_provisioner_subs_set_t        subs_set;
1693     /// Provisioner Node Delete Structure
1694     mesh_provisioner_node_delete_t     node_delete;
1695     /// Provisioner Node Add Structure
1696     mesh_provisioner_node_add_t        node_add;
1697     /// Node Address Set Structure
1698     mesh_provisioner_addr_set_t        node_addr;
1699     /// Mesh Provisioner Set Pubication Parameter Structure
1700     mesh_provisioner_set_pub_param_t   pub_set;
1701     /// Mesh Provisioner set nettransmit parameter structure
1702     mesh_provisioner_set_nettransmit_param_t nettranssmit_set;
1703 } mesh_core_provisioner_evt_cb_params_t;
1704 
1705 /**@}*/
1706 
1707 /**
1708  * @addtogroup PROFILE
1709  * @{
1710  */
1711 
1712 // Mesh Core Event indicate Callback
1713 typedef STATUS (*mesh_core_evt_ind_cb)(mesh_core_evt_ind_t evt, mesh_core_evt_ind_params_t *p_param);
1714 
1715 // Server State indicate handler
1716 typedef  void (* srv_state_ind_handle)(void *p_param) ;
1717 /**@}*/
1718 
1719 /**
1720  * @addtogroup PROVISION
1721  * @{
1722  */
1723 
1724 // Mesh Core Provisioner Event indicate Callback
1725 typedef STATUS (*mesh_core_provisioner_evt_ind_cb)(mesh_core_provisioner_evt_ind_t evt,
1726         mesh_core_provisioner_evt_ind_params_t *p_param);
1727 /**@}*/
1728 
1729 /**
1730  * @addtogroup MODELS
1731  * @{
1732  */
1733 
1734 /**
1735 * @brief   State entry structure
1736 */
1737 typedef struct {
1738     // Indicate Node State Follow by type
1739     uint32_t state;
1740     // State Type (@see mesh_state_type_t)
1741     mesh_state_type_t type;
1742     //  Transition Time in milliseconds
1743     uint32_t trans_time_ms;
1744 } mesh_state_ind_t;
1745 
1746 // Model request to publish a new message
1747 typedef struct mesh_model_publish_param {
1748     // - M_API_MODEL_PUBLISH: Model request to publish a new message
1749     // Operation code of the message
1750     uint32_t opcode;
1751     // Model ID
1752     uint32_t modelid;
1753     // Index of element the model belongs to (zero based)
1754     uint8_t element;
1755     // 1 = Segmented PDU force transport MIC to 64 bits ; 0 = 32 bits transport MIC
1756     uint8_t  trans_mic_64;
1757     // Message length
1758     uint16_t len;
1759     // Message content
1760     uint8_t  msg[__ARRAY_EMPTY];
1761 } mesh_model_publish_param_t;
1762 
1763 // Message Publishde callback
1764 typedef  STATUS (* msg_published_cb)(mesh_model_publish_param_t *p_param, STATUS status) ;
1765 
1766 // Sig Nodel State callback
1767 typedef  void (* sig_model_state_cb)(mesh_state_ind_t *p_state) ;
1768 /**@}*/
1769 
1770 /**
1771  * @addtogroup PROFILE
1772  * @{
1773  */
1774 
1775 // Mesh Start Complete fuc
1776 typedef  void (* mesh_start_complete)(void) ;
1777 
1778 // Mesh Pause Scan Complete fuc
1779 typedef  void (* mesh_scan_pasuse_cb)(void) ;
1780 
1781 // Mesh Resume Scan Complete fuc
1782 typedef  void (* mesh_scan_resume_cb)(void) ;
1783 
1784 /*
1785  * FUNCTION DECLARATIONS
1786 **********************************************************
1787 */
1788 
1789 /**
1790  ***********************************************************
1791  * @brief Func  start mesh protocol
1792  *
1793  * @param[in]  cb    started callback @see mesh_start_complete
1794  *
1795  ************************************************************
1796 */
1797 void sonata_mesh_start(mesh_start_complete cb);
1798 /**@}*/
1799 
1800 /**
1801  * @addtogroup MODELS
1802  * @{
1803  */
1804 
1805 /**
1806  ***********************************************************
1807  * @brief Func  publish msg
1808  *
1809  * @param[in]  param    @see mesh_model_publish_param_t
1810  * @param[in]  end_cb   @see msg_published_cb
1811  * @return STATUS
1812  * @retval MESH_ERROR_INVALID_PARAM  The parameter to publish is invalid.
1813  * @retval MESH_ERROR_NO_SPACE       No space to use
1814  * @retval MESH_ERROR_NO_ERROR       No error/Success
1815  ************************************************************
1816 */
1817 STATUS  mesh_msg_publish(mesh_model_publish_param_t *param, msg_published_cb end_cb);
1818 
1819 /**
1820  ***********************************************************
1821  * @brief Func  used for client model  to send msg
1822  *
1823  * @param[in]  param   message param   @see mesh_client_msg_param_t
1824  * @param[in]  end_cb  callback func after msg be sent    @see client_msg_sent_cb
1825  * @return STATUS
1826  * @retval MESH_ERROR_NO_SPACE       No space to use
1827  * @retval MESH_ERROR_NO_ERROR       No error/Success
1828  ************************************************************
1829 */
1830 STATUS sonata_mesh_client_send_msg(mesh_client_msg_param_t *param, client_msg_sent_cb end_cb);
1831 
1832 /**
1833  ***********************************************************
1834  * @brief Func   used for server model  to send msg
1835  *
1836  * @param[in]  param   message param   @see mesh_model_msg_param_t
1837  * @param[in]  sent_cb    callback func after msg be sent    @see model_msg_sent_cb
1838  * @return STATUS
1839  * @retval MESH_ERROR_NO_SPACE       No space to use
1840  * @retval MESH_ERROR_NO_ERROR       No error/Success
1841  ************************************************************
1842 */
1843 STATUS  sonata_mesh_msg_send(mesh_model_msg_param_t *param, model_msg_sent_cb sent_cb);
1844 
1845 /**
1846  ***********************************************************
1847  * @brief  Register SIG model
1848  *
1849  * @param[in]  modelid    SIG model ID
1850  * @param[in]  element    which element to reg
1851  * @param[in]  is_main    if it is a main service
1852  * @param[in]  cb         model state handle, callback by stack after recieve pkt @see sig_model_state_cb
1853  * @return Status of model register
1854  * @retval MESH_ERROR_NOT_READY      Not ready to register
1855  * @retval MESH_ERROR_NO_SPACE       No space to use
1856  * @retval MESH_ERROR_NO_ERROR       No error/Success
1857  ************************************************************
1858 */
1859 STATUS sonata_mesh_model_register(uint32_t modelid, uint8_t element, bool is_main, sig_model_state_cb cb);
1860 
1861 /**
1862  ***********************************************************
1863  * @brief Func  register vendor model
1864  *
1865  * @param[in]  modelid    vendor model ID
1866  * @param[in]  element    which element to reg
1867  * @param[in]  pkt_cb     model state handle, callback by stack after recieve pkt @see m_vendor_model_msg_rx_t
1868  * @return STATUS
1869  * @retval MESH_ERROR_NOT_READY      Not ready to register
1870  * @retval MESH_ERROR_NO_SPACE       No space to use,Vendor model toolbox is full
1871  * @retval MESH_ERROR_NO_ERROR       No error/Success
1872  ************************************************************
1873 */
1874 STATUS mesh_vendor_model_register(uint32_t modelid, uint8_t element, m_vendor_model_msg_rx_t pkt_cb);
1875 
1876 /**
1877  ***********************************************************
1878  * @brief Func  bind appkey of command
1879  *
1880  * @param[in]   element       which element to reg.
1881  * @param[in]   model_id      model id.
1882  * @param[in]   app_key_id    id of app key.
1883  *
1884  * @retval 0
1885  ************************************************************
1886 */
1887 uint8_t sonata_mesh_app_key_bind(uint32_t element, uint32_t model_id, uint16_t app_key_id);
1888 
1889 /**
1890  ***********************************************************
1891  * @brief Func  subscribed to a group addr
1892  *
1893  * @param[in]   element       which element to reg.
1894  * @param[in]   model_id      model id.
1895  * @param[in]   group_addr    group addr.
1896  *
1897  * @retval 0
1898  ************************************************************
1899 */
1900 uint8_t sonata_mesh_subs_group_addr(uint32_t element, uint32_t model_id, uint16_t group_addr);
1901 
1902 /**
1903  ***********************************************************
1904  * @brief Func  Set value of a local state
1905  *
1906  * @param[in]   state       State value.
1907  * @param[in]   state_id    State identifier.
1908  * @param[in]   mdl_lid     Model local index.
1909  *
1910  * @return None
1911  ************************************************************
1912 */
1913 
1914 void m_api_srv_set(uint32_t state, modelid_t modelid);
1915 /**@}*/
1916 
1917 /**
1918  * @addtogroup PROFILE
1919  * @{
1920  */
1921 
1922 /**
1923  ***********************************************************
1924  * @brief Func  config mesh param
1925  *
1926  * @param[in]  type     param type    @see mesh_param_opr_types_t
1927  * @param[in]  p_param   param struct  @see mesh_set_params_t
1928  * @return STATUS
1929  * @retval MESH_ERROR_NO_ERROR       No error/Success
1930  ************************************************************
1931 */
1932 STATUS sonata_mesh_param_set(mesh_param_opr_types_t type, mesh_set_params_t *p_param);
1933 
1934 /**
1935  ***********************************************************
1936  * @brief Func  get mesh setting info
1937  *
1938  * @param[in]  type     param type     @see mesh_param_opr_types_t
1939  * @param[in]  p_param   param struct  @see mesh_get_params_t
1940  * @return STATUS
1941  * @retval MESH_ERROR_NO_ERROR       No error/Success
1942  ************************************************************
1943 */
1944 STATUS sonata_mesh_param_get(mesh_param_opr_types_t type, mesh_get_params_t *p_param);
1945 
1946 /**
1947  ***********************************************************
1948  * @brief Func  notify mesh stack to clean data
1949  *
1950  * @param[in]  clean_cb  callback after clean finished
1951  *
1952  * @return STATUS
1953  * @retval MESH_ERROR_NO_ERROR       No error/Success
1954  ************************************************************
1955 */
1956 STATUS sonata_mesh_clean_data(void (*clean_cb)(void));
1957 
1958 /**
1959  ***********************************************************
1960  * @brief Func  save data immedimately
1961  *
1962  * @return STATUS
1963  * @retval MESH_ERROR_NO_ERROR       No error/Success
1964  ************************************************************
1965 */
1966 STATUS sonata_mesh_save_data(void);
1967 
1968 /**
1969  ***********************************************************
1970  * @brief Func  set interval of saving data
1971  *
1972  * @param[in]  secs   time of unit of sec
1973  *
1974  * @return STATUS
1975  * @retval MESH_ERROR_NO_ERROR       No error/Success
1976  ************************************************************
1977 */
1978 STATUS sonata_mesh_set_save_interval(uint32_t secs);
1979 
1980 /**
1981  ***********************************************************
1982  * @brief Func  to broadcast proxy service
1983  *
1984  * @param[in]  ctl  action @see mesh_proxy_adv_ctl_t
1985  *
1986  ************************************************************
1987 */
1988 void sonata_mesh_proxy_service_broadcast(mesh_proxy_broadcast_ctl_t ctl);
1989 
1990 /**
1991  ***********************************************************
1992  * @brief Func  register callback for event handle
1993  *
1994  * @param[in]  cb   callback list   @see mesh_core_evt_ind_cb
1995  *
1996  * @retval MESH_ERROR_NO_ERROR       No error/Success
1997  ************************************************************
1998 */
1999 void sonata_mesh_register_core_evt_ind(mesh_core_evt_ind_cb cb);
2000 
2001 /**
2002  ***********************************************************
2003  * @brief Func  app notify the provisioner to finish something
2004  *
2005  * @param[in]  evt       @see mesh_core_provisioner_evt_cb_t
2006  * @param[in]  p_param   @see mesh_core_provisioner_evt_cb_params_t
2007  *
2008  * @retval MESH_ERROR_NO_ERROR       No error/Success
2009  ************************************************************
2010 */
2011 int mesh_core_provisioner_evt_cb(mesh_core_provisioner_evt_cb_t evt, mesh_core_provisioner_evt_cb_params_t *p_param);
2012 
2013 /**
2014  ***********************************************************
2015  * @brief Func  app notify the stack to finish something
2016  *
2017  * @param[in]  evt       @see mesh_core_evt_cb_t
2018  * @param[in]  p_param   @see mesh_core_evt_cb_params_t
2019  *
2020  * @retval MESH_ERROR_NO_ERROR         No error/Success
2021  ************************************************************
2022 */
2023 int mesh_core_evt_cb(mesh_core_evt_cb_t evt, mesh_core_evt_cb_params_t *p_param);
2024 /**@}*/
2025 
2026 /**
2027  * @addtogroup PROVISION
2028  * @{
2029  */
2030 
2031 /**
2032  ***********************************************************
2033  * @brief Func  register evt indication for provisioner event
2034  *
2035  * @param[in]  cb   callback list   @see mesh_core_provisioner_evt_ind_cb
2036  *
2037  ************************************************************
2038 */
2039 void sonata_mesh_provisioner_register_core_evt_ind(mesh_core_provisioner_evt_ind_cb cb);
2040 
2041 /**
2042  ***********************************************************
2043  * @brief Func  judge the node is provisioned
2044  *
2045  * @retval TRUE  Provisioned
2046  * @retval FALSE Unprovisioned
2047  ************************************************************
2048 */
2049 bool sonata_mesh_is_provisioned(void);
2050 
2051 /**
2052  **********************************************************
2053  * @brief Func  response to provision authentication data request.
2054  *
2055  * @param[in]   accept       accept or not.
2056  * @param[in]   auth_size    length of authentication data
2057  * @param[in]   auth_data    pointer to authentication data memory
2058  *
2059  * @return  None.
2060  ************************************************************
2061  */
2062 void sonata_mesh_send_prov_auth_data_rsp(uint8_t accept, uint8_t auth_size, uint8_t *auth_data);
2063 /**@}*/
2064 
2065 /**
2066  * @addtogroup PROFILE
2067  * @{
2068  */
2069 
2070 /**
2071  ***********************************************************
2072  * @brief Func  random num generator word
2073  *
2074  * @return Random word value
2075  ************************************************************
2076 */
2077 uint32_t sonata_mesh_rand_word(void);
2078 
2079 /**
2080  ***********************************************************
2081  * @brief Func  random num generator for uint16_t
2082  *
2083  * @return Random half word value
2084  ************************************************************
2085 */
2086 uint16_t sonata_mesh_rand_hword(void);
2087 
2088 /**
2089  ***********************************************************
2090  * @brief Func  get src addr of Client
2091  *
2092  * @return Source Address
2093  ************************************************************
2094 */
2095 uint16_t sonata_mesh_get_src_addr(void);
2096 /**
2097  ****************************************************************************************
2098  * @brief Get device run time
2099  *
2100  ****************************************************************************************
2101  */
2102 void app_mesh_api_get_run_time(void);
2103 
2104 /**
2105  ***********************************************************
2106  * @brief Func  pause mesh scan
2107  *
2108  * @param[in]  module      module id defined @see mesh_scan_opr_module_id
2109  * @param[in]  cb          mesh scan pause complete callback
2110  *
2111  * @return void pause mesh scan
2112  ************************************************************
2113 */
2114 void sonata_mesh_scan_pause(mesh_scan_opr_module_id_t module, mesh_scan_pasuse_cb cb);
2115 
2116 /**
2117  ***********************************************************
2118  * @brief Func  resume mesh scan
2119  *
2120  * @param[in]  module      module id defined @see mesh_scan_opr_module_id
2121  * @param[in]  cb          mesh scan resume complete callback
2122  *
2123  * @return void
2124  ************************************************************
2125 */
2126 void sonata_mesh_scan_resume(mesh_scan_opr_module_id_t module, mesh_scan_resume_cb cb);
2127 
2128 /**
2129  ***********************************************************
2130  * @brief Func  get netkey after system is running
2131  * @param[in]  key_index        netkey global index
2132  * @param[in]  key          key storage
2133  *
2134  * @retval MESH_ERROR_NO_ERROR         No Error/Success
2135  * @retval MESH_ERROR_INVALID_PARAM    Not Found/Fail
2136  ************************************************************
2137 */
2138 STATUS sonata_mesh_get_netkey(uint16_t key_index, uint8_t *key);
2139 
2140 /**
2141  ***********************************************************
2142  * @brief Func  get appkey after system is running
2143  * @param[in]  key_index        appkey global index
2144  * @param[in]  key          key storage
2145  *
2146  * @retval MESH_ERROR_NO_ERROR         No error/Success
2147  * @retval MESH_ERROR_INVALID_PARAM    Not Found/Fail
2148  ************************************************************
2149 */
2150 STATUS sonata_mesh_get_appkey(uint16_t key_index, uint8_t *key);
2151 
2152 /**
2153  ***********************************************************
2154  * @brief Func  get node first addr
2155  *
2156  * @
2157  *
2158  * @retval uint16_t         addr
2159 
2160  ************************************************************
2161 */
2162 uint16_t  sonata_mesh_get_prim_addr(void);
2163 
2164 /**
2165  ***********************************************************
2166  * @brief Func  get devkey after system is running
2167  * @param[in]  key          key storage
2168  *
2169  * @retval void
2170  ************************************************************
2171 */
2172 void sonata_mesh_get_dev_key(uint8_t *key);
2173 
2174 /**
2175  ***********************************************************
2176  * @brief Func  get iv index and seq no
2177  * @param[in]  iv          porter to iv index
2178  * @param[in]  seq         porter to seq no
2179  *
2180  * @retval void
2181  ************************************************************
2182 */
2183 void sonata_mesh_get_iv_seq(uint32_t *iv, uint32_t *seq);
2184 
2185 /**
2186  ***********************************************************
2187  * @brief Func  get subscribe list size
2188  * @param[in]  unicast_addr          element addr
2189  * @param[in]  model_id         model ID
2190  *
2191  * @retval uint16_t           size
2192  ************************************************************
2193 */
2194 uint16_t sonata_mesh_get_subs_size(uint16_t unicast_addr, uint32_t model_id);
2195 
2196 /**
2197  ***********************************************************
2198  * @brief Func  start adv unprov beacon
2199  *
2200  *
2201  *
2202  * @retval void
2203  ************************************************************
2204 */
2205 void sonata_mesh_start_unprov_beacon(void);
2206 
2207 /**
2208  ***********************************************************
2209  * @brief Func  stop adv unprov beacon
2210  *
2211  *
2212  *
2213  * @retval void
2214  ************************************************************
2215 */
2216 void sonata_mesh_stop_unprov_beacon(void);
2217 
2218 /** @}*/
2219 
2220 /** @}*/
2221 #endif // _SONATA_MESH_API_H_
2222 
2223