1 /*
2  * Copyright (C) 2015-2019 Alibaba Group Holding Limited
3  */
4 
5 #ifndef UAGENT_TYPE_H
6 #define UAGENT_TYPE_H
7 
8 /* type define */
9 typedef unsigned short ua_mod_t;
10 typedef unsigned short ua_func_t;
11 typedef unsigned char  service_agent_rlt_t;
12 
13 #define SERVICE_AGENT_FAIL (service_agent_rlt_t)0x00
14 #define SERVICE_AGENT_OK   (service_agent_rlt_t)0x01
15 
16 /* uagent support function name size, include null-terminated */
17 #define UAGENT_FUNC_NAME_SIZE 12
18 
19 /* Values for ua_send_policy_t are constructed by a bitwise-inclusive OR of flags
20  * from the @send_policy_bit_ctrl_t
21  */
22 typedef unsigned char ua_send_policy_t;
23 
24 typedef enum {
25     send_policy_save_cloud      = 0x01,
26     send_policy_trans_guarantee = 0x02,
27     send_policy_object          = 0x04,
28     send_policy_delay           = 0x08,
29     send_policy_delay_dump      = 0x10,
30 } send_policy_bit_ctrl_t;
31 
32 #define POLICY_SET(POLICY, MASK) ((POLICY&MASK) == MASK)
33 
34 /* uAgent module name */
35 #define UAGENT_MOD_UAGENT     (ua_mod_t)0
36 
37 /* externel module  - cloud */
38 #define UAGENT_MOD_CLOUD      (ua_mod_t)5
39 
40 /* uND module */
41 #define UAGENT_MOD_UND        (ua_mod_t)0x10
42 
43 /* uLog module  */
44 #define UAGENT_MOD_ULOG       (ua_mod_t)0x11
45 
46 /* uOTA module  */
47 #define UAGENT_MOD_OTA        (ua_mod_t)0x12
48 
49 /* CLI module  */
50 #define UAGENT_MOD_CLI        (ua_mod_t)0x13
51 
52 
53 #define UAGENT_MOD_BROAD_CAST (ua_mod_t)0xff
54 
55 /* ------------------------ Function List ------------------------ */
56 /* Inner function type used to register module */
57 #define UAGENT_FUNC_UA_REGISTER              (ua_func_t)0x0001
58 
59 #define UAGENT_FUNC_UA_UNREGISTER            (ua_func_t)0x0002
60 
61 #define UAGENT_FUNC_UA_RQST_CONN             (ua_func_t)0x0003
62 
63 #define UAGENT_FUNC_UA_DUMP_DELAY_SEND       (ua_func_t)0x0004
64 
65 #define UAGENT_FUNC_UA_DUMP_DELAY_SEND_PARAM (ua_func_t)0x0005
66 
67 /**
68  * Nofity connect build, format is {"comm conn":1}/ {"comm conn":0}.
69  * Refer @UAGENT_NOTICE_CONNECT for format when using.
70  * Remark: the cb will be called to indicates current situation right now when register.
71  */
72 #define UAGENT_FUNC_NOTIFY_CLOUD_CONN (ua_func_t)0x0011
73 
74 #define UAGENT_FUNC_INT_TEL           (ua_func_t)0x0021
75 
76 #define UAGENT_FUNC_UA_SHOW_LIST      (ua_func_t)0x0051
77 
78 /* aquire high level service is enable executed */
79 #define UAGENT_FUNC_UA_APPLY          (ua_func_t)0x8000
80 
81 /* reboot */
82 #define UAGENT_FUNC_REBOOT            (ua_func_t)0x8002
83 
84 /* Auth high level service is enable executed */
85 #define UAGENT_FUNC_UA_AUTH           (ua_func_t)0x8055
86 
87 /* user only can use [H]BASE~[H]BASE+0x100 */
88 #define UAGENT_USER_FUNC_SIZE         (ua_func_t)0x100
89 /* base of user define function */
90 #define UAGENT_FUNC_USER_BASE         (ua_func_t)0x0400
91 
92 /* base of user define function, which shall be authrized */
93 #define UAGENT_FUNC_AUTH_USER_BASE    (ua_func_t)0x8400
94 
95 /* user service function, this call-back will be called if related telegram received
96  * (inner telegram or externel telegram
97  */
98 typedef int (*on_customer_service)(void *arg, const unsigned short len, void *str);
99 
100 typedef struct {
101     ua_mod_t       mod;
102     unsigned char  func_count;
103     char          *name;
104     char          *version;
105 } uagent_mod_info_t;
106 
107 typedef struct _uagent_func_node_t {
108     ua_func_t                   func;
109     char                        func_name[UAGENT_FUNC_NAME_SIZE];
110     on_customer_service         service;
111     void                       *argu;
112     struct _uagent_func_node_t *next;
113 } uagent_func_node_t;
114 
115 typedef struct {
116     uagent_mod_info_t   mod_info;
117     uagent_func_node_t *header;
118 } mod_func_t;
119 
120 #define UAGENT_NOTICE_CONNECT "{\"comm conn\":%d}"
121 
122 #endif /* UAGENT_TYPE_H */
123 
124