1 /*
2  * Copyright (C) 2018-2020 Alibaba Group Holding Limited
3  */
4 
5 #ifndef __GENIE_MESH_H__
6 #define __GENIE_MESH_H__
7 
8 #include <stddef.h>
9 #include <net/buf.h>
10 
11 #include <mesh/access.h>
12 #include <mesh/main.h>
13 #include <mesh/cfg_srv.h>
14 #include <mesh/health_srv.h>
15 
16 #include "genie_service.h"
17 
18 #define CONFIG_MESH_VENDOR_COMPANY_ID (0x01A8)
19 #define CONFIG_MESH_VENDOR_MODEL_SRV 0x0000
20 #define CONFIG_MESH_VENDOR_MODEL_CLI 0x0001
21 
22 #define GENIE_MESH_INIT_PHARSE_II_HW_RESET_DELAY (2000)       //Unit:ms
23 #define GENIE_MESH_INIT_PHARSE_II_DELAY_START_MIN (1000)      //Unit:ms
24 #define GENIE_MESH_INIT_PHARSE_II_DELAY_START_MAX (10 * 1000) //Unit:ms
25 
26 #define GENIE_MESH_INIT_PHARSE_II_CHECK_APPKEY_INTERVAL (1000)                                                //Unit:ms
27 #define GENIE_MESH_INIT_PHARSE_II_CHECK_APPKEY_TIMEOUT (30 * GENIE_MESH_INIT_PHARSE_II_CHECK_APPKEY_INTERVAL) //Unit:ms
28 
29 #define ALI_MODEL_TAG "\t[ALI_MODEL]"
30 
31 #define MODEL_D(f, ...) printf("%d " ALI_MODEL_TAG "[D] %s " f "\n", (bt_u32_t)aos_now_ms(), __func__, ##__VA_ARGS__)
32 #define MODEL_I(f, ...) printf(ALI_MODEL_TAG "[I] %s " f "\n", __func__, ##__VA_ARGS__)
33 #define MODEL_E(f, ...) printf(ALI_MODEL_TAG "[E] %s " f "\n", __func__, ##__VA_ARGS__)
34 
35 typedef enum _genie_mesh_init_state_e
36 {
37     GENIE_MESH_INIT_STATE_PROVISION = 1,
38     GENIE_MESH_INIT_STATE_HW_RESET,
39     GENIE_MESH_INIT_STATE_NORMAL_BOOT,
40 } genie_mesh_init_state_e;
41 
42 #if 0
43 typedef enum _genie_mesh_work_type_e
44 {
45     GENIE_MESH_WORK_TYPE_INVALID,
46     GENIE_MESH_WORK_TYPE_HW_RESET,
47     GENIE_MESH_WORK_TYPE_READY,
48     GENIE_MESH_WORK_TYPE_PROV_TIMEOUT,
49 } genie_mesh_work_type_e;
50 #endif
51 
52 struct bt_mesh_elem *genie_mesh_get_primary_element(void);
53 
54 int genie_mesh_init(struct bt_mesh_elem *p_mesh_elem, unsigned int mesh_elem_counts);
55 
56 int genie_mesh_init_pharse_ii(void);
57 
58 void genie_mesh_ready_checktimer_restart(uint32_t timeout);
59 
60 int genie_mesh_suspend(bool force);
61 
62 int genie_mesh_resume(void);
63 
64 void genie_mesh_load_group_addr(void);
65 
66 #endif
67