1 /*
2  * Copyright (C) 2018-2020 Alibaba Group Holding Limited
3  */
4 
5 #ifndef __GENIE_VENDOR_MODEL_H__
6 #define __GENIE_VENDOR_MODEL_H__
7 
8 #define VENDOR_OP_ATTR_GET_STATUS 0xD0
9 #define VENDOR_OP_ATTR_SET_ACK 0xD1
10 #define VENDOR_OP_ATTR_SET_UNACK 0xD2
11 #define VENDOR_OP_ATTR_STATUS 0xD3
12 #define VENDOR_OP_ATTR_INDICATE 0xD4
13 #define VENDOR_OP_ATTR_CONFIME 0xD5
14 #define VENDOR_OP_ATTR_INDICATE_TG 0xDE
15 #define VENDOR_OP_ATTR_CONFIME_TG 0xDF
16 #define VENDOR_OP_ATTR_TRANS_MSG 0xCF
17 #define VENDOR_OP_ATTR_TRANS_INDICATE 0xCE
18 #define VENDOR_OP_ATTR_TRANS_ACK 0xCD
19 
20 #define ATTR_TYPE_REPORT_VERSION 0xFF01
21 #define ATTR_TYPE_DEVICE_EVENT 0xF009
22 
23 #define ATTR_TYPE_VOLTAGE_LEVEL 0x0105
24 
25 #define VENDOR_MODEL_VERSION 10 //vendor model version:1.0
26 #define SDK_VERSION 13          //SDK version:1.3
27 
28 /* Event List - Refer to Device Event List */
29 #define EL_FAULT_T 0x00    /* malfunction event */
30 #define EL_LOW_BAT_T 0x01  /* low battery event */
31 #define EL_DEV_UP_T 0x03   /* device power up */
32 #define EL_HW_RESET_T 0x23 /* hardware reset event */
33 
34 /* Vendor timer error code */
35 #define ERR_CODE_UNIXTIME 0x80
36 #define ERR_CODE_NOTSUP_ATTR_OP 0x82
37 #define ERR_CODE_NOTSUP_ATTR_PARAM 0x83
38 #define ERR_CODE_TIMER_SETTING 0x84
39 #define ERR_CODE_TIMER_INDEX 0x85
40 #define ERR_CODE_TIMER_FULL 0x86
41 #define ERR_CODE_TIMER_PRIORDIC_PARAM 0x87
42 
43 /* Vendor timer ali attr type */
44 #define ERROR_CODE_T 0x0000
45 #define TIMING_TIMEOUT_T 0xF009
46 #define TIMING_SETTING_T 0xF010
47 #define TIMING_PERIODIC_SETTING_T 0xF011
48 #define TIMING_DELETE_T 0xF012
49 #define TIMING_SYNC_T 0xF01D
50 #define TIMEZONE_SETTING_T 0xF01E
51 #define UNIX_TIME_T 0xF01F
52 
53 #define EL_TIMING_TIMEOUT_T 0x11 /* timer timeout event */
54 
55 #ifndef VENDOR_MODEL_MSG_MAX_RETRY_TIMES
56 #define VENDOR_MODEL_MSG_DFT_RETRY_TIMES 45
57 #endif
58 
59 #ifndef VENDOR_MODEL_MSG_MAX_RETRY_TIMES
60 #define VENDOR_MODEL_MSG_MAX_RETRY_TIMES 45
61 #endif
62 
63 #ifndef VENDOR_MODEL_MSG_RETRY_PERIOD
64 #define VENDOR_MODEL_MSG_RETRY_PERIOD 400
65 #endif
66 
67 #define GENIE_MODEL_SEG_COUNT 8
68 #define GENIE_MODEL_MTU (GENIE_MODEL_SEG_COUNT * 12)
69 
70 #define CONFIG_MESH_VENDOR_MODEL_SRV 0x0000
71 
72 #define VENDOR_MODEL_OPC_NUM 9
73 
74 extern struct bt_mesh_model_pub genie_model_pub;
75 extern const struct bt_mesh_model_op genie_model_op[VENDOR_MODEL_OPC_NUM];
76 
77 #define MESH_MODEL_VENDOR_SRV(_user_data) BT_MESH_MODEL_VND(CONFIG_MESH_VENDOR_COMPANY_ID, CONFIG_MESH_VENDOR_MODEL_SRV, \
78                                                             genie_model_op, &genie_model_pub, _user_data)
79 
80 int genie_model_handle_mesg(genie_transport_model_param_t *p_msg);
81 
82 #endif
83