Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / plugins / zigbee_wrapper / telegesis_wrapper / include / twtypes.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This API only works with:
25  *      Telegesis ETRX357
26  *      CICIE R310 B110615
27  *
28  */
29
30 #ifndef TWTYPES_H_
31 #define TWTYPES_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif // __cplusplus
36
37 #include <stdint.h>
38 #include <stdbool.h>
39
40 #define DEVICE_BAUDRATE                 (B19200)
41 #define MAX_ZIGBEE_BYTES                (512)
42 #define MAX_ZIGBEE_ENROLLED_DEVICES     (255)
43
44 #define TIME_OUT_00_SECOND      (0)
45 #define TIME_OUT_01_SECOND      (1)
46 #define TIME_OUT_05_SECONDS     (5)
47 #define TIME_OUT_07_SECONDS     (7)
48 #define TIME_OUT_10_SECONDS     (10)
49 #define TIME_OUT_15_SECONDS     (15)
50
51 #define SIMPLEDESC_RESPONSE_EXPECTED_LINES (6)
52
53 #define ZB_PROFILE_ID_HOME_AUTOMATION       "0104"
54
55 #define ZB_CLUSTER_IDENTIFY                 "0003"
56 #define ZB_CLUSTER_ON_OFF                   "0006"
57 #define ZB_CLUSTER_TEMPERATURE_MEASUREMENT  "0402"
58 #define ZB_CLUSTER_IAS_ZONE                 "0500"
59 #define ZB_CLUSTER_COLOR_CONTROL            "0300"
60
61 #define AT_STR_ERROR_OK             "00"
62 #define AT_STR_ERROR_INVALID_OP     "70"
63
64 #define AT_STR_ERROR_EVERYTHING_OK                              "00"
65 #define AT_STR_ERROR_NODE_IS_PART_OF_PAN                        "28"
66 #define AT_STR_ERROR_MESSAGE_NOT_SENT_TO_TARGET_SUCCESSFULLY    "66"
67 #define AT_STR_ERROR_INVALID_OPERATION                          "70"
68
69
70 #define SENDMODE                "0"
71 #define SEPARATOR               ","
72 #define SEPARATOR_LENGTH        strlen(SEPARATOR)
73
74 #define AT_CMD_RESET                                    "AT&F"
75 #define AT_CMD_GET_NETWORK_INFO                         "AT+N"
76 #define AT_CMD_ESTABLISH_NETWORK                        "AT+EN"
77 #define AT_CMD_PERMIT_JOIN                              "AT+PJOIN:"
78 #define AT_CMD_MATCH_REQUEST                            "AT+MATCHREQ:"
79 #define AT_CMD_SIMPLE_DESC                              "AT+SIMPLEDESC:"
80 #define AT_CMD_WRITE_ATR                                "AT+WRITEATR:"
81 #define AT_CMD_READ_ATR                                 "AT+READATR:"
82 #define AT_CMD_RUN_ON_OFF                               "AT+RONOFF:"
83 #define AT_CMD_MOVE_TO_LEVEL                            "AT+LCMVTOLEV:"
84 #define AT_CMD_DOOR_LOCK                                "AT+DRLOCK:"
85 #define AT_CMD_COLOR_CTRL_MOVE_TO_COLOR_TEMPERATURE     "AT+CCMVTOCT:"
86 #define AT_CMD_GET_LOCAL_EUI                            "ATS04?"
87 #define AT_CMD_REMOTE_EUI_REQUEST                       "AT+EUIREQ:"
88
89 #define TW_ENDCONTROL_ERROR_STRING                      "ERROR:"
90
91 #define SIZE_EUI                    (17)
92 #define SIZE_NODEID                 (5)
93 #define SIZE_CLUSTERID              (5)
94 #define SIZE_ENDPOINTID             (3)
95
96 #define SIZE_ZONESTATUS             (5)
97 #define SIZE_ZONESTATUS_EXTENDED    (3)
98 #define SIZE_ZONEID                 (3)
99 #define SIZE_ZONETYPE               (5)
100 #define SIZE_UPDATE_DELAY_TIME      (5)
101
102 //-----------------------------------------------------------------------------
103 // Typedefs
104 //-----------------------------------------------------------------------------
105 typedef enum
106 {
107     ZB_STATE_UNKNOWN,
108     ZB_STATE_INIT
109 } TWState;
110
111 typedef struct
112 {
113     TWState state;
114     uint64_t panId;
115     uint64_t extPanId;
116
117     char*   remoteAttributeValueRead;
118     uint8_t remoteAtrributeValueReadLength;
119 } TWStatus;
120
121 typedef enum
122 {
123     TW_RESULT_OK = 0,
124
125     TW_RESULT_ERROR_LINE_COUNT,
126     TW_RESULT_NO_LOCAL_PAN,
127     TW_RESULT_HAS_LOCAL_PAN,
128     TW_RESULT_NEW_LOCAL_PAN_ESTABLISHED,
129     TW_RESULT_DEVICE_JOINED,
130     TW_RESULT_FOUND_NO_MATCHED_DEVICE,
131     TW_RESULT_FOUND_MATCHED_DEVICES,
132     TW_RESULT_HAS_CLUSTERS,
133     TW_RESULT_HAS_NO_CLUSTER,
134     TW_RESULT_REMOTE_ATTR_HAS_VALUE,
135
136     TW_RESULT_UNKNOWN,
137
138     TW_RESULT_ERROR_INVALID_PARAMS,
139     TW_RESULT_ERROR_INVALID_PORT,
140     TW_RESULT_ERROR_NO_MEMORY,
141     TW_RESULT_ERROR_INVALID_OP,
142     TW_RESULT_ERROR_NOTIMPL,
143
144     TW_RESULT_ERROR = 255
145
146 } TWResultCode;
147
148 typedef enum
149 {
150     AT_ERROR_EVERYTHING_OK  = 0,
151     AT_ERROR_NODE_IS_PART_OF_PAN = 28,
152     AT_ERROR_MESSAGE_NOT_SENT_TO_TARGET_SUCCESSFULLY   = 66,
153     AT_ERROR_INVALID_OPERATION  = 70,
154
155 } TWATErrorCode;
156
157 typedef enum
158 {
159     TW_ENDCONTROL_OK = 0,
160     TW_ENDCONTROL_ERROR,
161     TW_ENDCONTROL_ACK,
162     TW_ENDCONTROL_SEQ,
163     TW_ENDCONTROL_MAX_VALUE
164
165 } TWEndControl;
166
167 typedef struct
168 {
169     const char * endStr;
170     TWEndControl endControl;
171
172 } TWEndControlMap;
173
174
175 #ifdef __cplusplus
176 }
177 #endif // __cplusplus
178
179 #endif /* TWTYPES_H_ */