1 /*
2  * Copyright (C) 2018-2020 Alibaba Group Holding Limited
3  */
4 
5 #ifndef __GENIE_EVENT_H__
6 #define __GENIE_EVENT_H__
7 
8 #include <stdint.h>
9 #include <stdbool.h>
10 
11 #ifndef GENIE_PROV_SUCCESS_REPORT_TIMEOUT
12 #define GENIE_PROV_SUCCESS_REPORT_TIMEOUT 30
13 #endif
14 
15 typedef enum
16 {
17     GENIE_EVT_NONE = 0,
18     GENIE_EVT_SW_RESET,       /* triggered from cloud */
19     GENIE_EVT_HW_RESET_START, /* triggered from user */
20     GENIE_EVT_BT_READY,
21     GENIE_EVT_MESH_READY, // Used to sync device's state with cloud
22 
23     GENIE_EVT_SDK_AIS_DISCON = 10,
24     GENIE_EVT_SDK_AIS_CONNECT,
25     GENIE_EVT_SDK_MESH_PBADV_START,
26     GENIE_EVT_SDK_MESH_PBADV_TIMEOUT,
27     GENIE_EVT_SDK_MESH_SILENT_START,
28 
29     GENIE_EVT_SDK_MESH_PROV_START = 20,
30     GENIE_EVT_SDK_MESH_PROV_DATA,
31     GENIE_EVT_SDK_MESH_PROV_TIMEOUT,
32     GENIE_EVT_SDK_MESH_PROV_SUCCESS,
33     GENIE_EVT_SDK_MESH_PROV_FAIL,
34 
35     GENIE_EVT_SDK_APPKEY_ADD = 30,
36     GENIE_EVT_SDK_APPKEY_DEL,
37     GENIE_EVT_SDK_APPKEY_UPDATE,
38     GENIE_EVT_SDK_NETKEY_ADD,
39     GENIE_EVT_SDK_NETKEY_DEL,
40     GENIE_EVT_SDK_NETKEY_UPDATE,
41 
42     GENIE_EVT_SDK_HB_SET = 40,
43 #ifdef CONFIG_BT_MESH_CTRL_RELAY
44     GENIE_EVT_SDK_CTRL_RELAY_SET,
45 #endif
46     GENIE_EVT_SDK_SEQ_UPDATE,
47 
48     GENIE_EVT_TIMEOUT = 50,
49     GENIE_EVT_DOWN_MSG,
50     GENIE_EVT_VENDOR_MODEL_MSG,
51     GENIE_EVT_SIG_MODEL_MSG,
52     GENIE_EVT_USER_TRANS_CYCLE,
53     GENIE_EVT_USER_ACTION_DONE
54 } genie_event_e;
55 
56 typedef enum _genie_down_mesg_type
57 {
58     GENIE_DOWN_MESG_VENDOR_TYPE = 0,
59     GENIE_DOWN_MESG_SIG_TYPE
60 } genie_down_mesg_type;
61 
62 typedef struct _sig_model_msg
63 {
64     uint8_t element_id;
65     uint16_t opcode;
66     uint16_t len;
67     uint8_t *data;
68 } sig_model_msg;
69 
70 typedef struct _genie_down_msg_s
71 {
72     uint8_t element_id;
73     uint16_t len;
74     uint8_t *data;
75 } genie_down_msg_t;
76 
77 /**
78  * @brief The handler for the underlying events. If necessary
79  *        this handler dispatch the user events to applications.
80  * @param[in] event refers to the event details.
81  * @param[in] args refers to the additional information for the event.
82  */
83 void genie_event(genie_event_e event, void *args);
84 
85 int genie_down_msg(genie_down_mesg_type msg_type, uint32_t opcode, void *p_msg);
86 
87 #endif
88