Merge remote-tracking branch 'origin/extended-easysetup'
[platform/upstream/iotivity.git] / service / easy-setup / inc / escommon.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics 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 #ifndef ES_COMMON_H_
22 #define ES_COMMON_H_
23
24 #include "ocstack.h"
25 #include "octypes.h"
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 // Defines
33 #define OIC_STRING_MAX_VALUE    100
34 #define IPV4_ADDR_SIZE          16
35 #define IP_PORT                 55555
36
37 /**
38  * @brief Mac address length for BT port
39  */
40 #define NET_MACADDR_SIZE 18
41
42 /**
43  * Attributes used to form a proper easysetup conforming JSON message.
44  */
45 #define OC_RSRVD_ES_PROVSTATUS             "ps"
46 #define OC_RSRVD_ES_LAST_ERRORCODE         "lec"
47 #define OC_RSRVD_ES_LINKS                  "links"
48 #define OC_RSRVD_ES_SUPPORTEDWIFIMODE      "swmt"
49 #define OC_RSRVD_ES_SUPPORTEDWIFIFREQ      "swf"
50 #define OC_RSRVD_ES_SSID                   "tnn"
51 #define OC_RSRVD_ES_CRED                   "cd"
52 #define OC_RSRVD_ES_AUTHTYPE               "wat"
53 #define OC_RSRVD_ES_ENCTYPE                "wet"
54 #define OC_RSRVD_ES_AUTHCODE               "ac"
55 #define OC_RSRVD_ES_AUTHPROVIDER           "apn"
56 #define OC_RSRVD_ES_CISERVER               "cis"
57 #define OC_RSRVD_ES_SERVERID               "sid"
58 #define OC_RSRVD_ES_DEVNAME                "dn"
59 #define OC_RSRVD_ES_LANGUAGE               "lang"
60 #define OC_RSRVD_ES_COUNTRY                "ctry"
61
62 /**
63  * Easysetup defined resoruce types and uris.
64  */
65 #define OC_RSRVD_ES_RES_TYPE_PROV         "ocf.wk.prov"
66 #define OC_RSRVD_ES_URI_PROV              "/ProvisioningResURI"
67 #define OC_RSRVD_ES_RES_TYPE_WIFI         "ocf.wk.wifi"
68 #define OC_RSRVD_ES_URI_WIFI              "/WiFiProvisioningResURI"
69 #define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER  "ocf.wk.cloudserver"
70 #define OC_RSRVD_ES_URI_CLOUDSERVER       "/CloudServerProvisioningResURI"
71 #define OC_RSRVD_ES_RES_TYPE_DEVCONF      "ocf.wk.devconf"
72 #define OC_RSRVD_ES_URI_DEVCONF           "/DevConfProvisioningResURI"
73
74 #define NUM_WIFIMODE    10
75 #define MAX_SSIDLEN     33
76 #define MAX_CREDLEN     20
77
78 #define MAX_DEVICELEN   100
79 #define MAX_WEBLINKLEN  100
80
81 /**
82  * @brief  Supported WIFI frequency like 2.4G and 5G
83  */
84 typedef enum
85 {
86     WIFI_24G = 0,       /**< 2.4G **/
87     WIFI_5G,            /**< 5G **/
88     WIFI_BOTH,          /**< 2.4G and 5G **/
89     WIFI_FREQ_NONE      /**< EOF **/
90 } WIFI_FREQ;
91
92 /**
93  * @brief  Supported WIFI mode like 802.11g and 802.11n
94  */
95 typedef enum
96 {
97     WIFI_11A = 0,       /**< 802.11a **/
98     WIFI_11B,           /**< 802.11b **/
99     WIFI_11G,           /**< 802.11g **/
100     WIFI_11N,           /**< 802.11n **/
101     WIFI_11AC,          /**< 802.11ac **/
102     WiFi_EOF = 999
103 } WIFI_MODE;
104
105
106 /**
107  * @brief  WIFI Authentication tlype of the Enroller
108  */
109 typedef enum
110 {
111     NONE_AUTH = 0,      /**< NO authentication **/
112     WEP,                /**< WEP **/
113     WPA_PSK,            /**< WPA-PSK **/
114     WPA2_PSK            /**< WPA2-PSK **/
115 } WIFI_AUTHTYPE;
116
117 /**
118  * @brief  WIFI encryption type of the Enroller
119  */
120 typedef enum
121 {
122     NONE_ENC = 0,       /**< NO encryption **/
123     WEP_64,             /**< WEP-64 **/
124     WEP_128,            /**< WEP-128**/
125     TKIP,               /**< TKIP **/
126     AES,                /**< AES **/
127     TKIP_AES            /**< TKIP-AES **/
128 } WIFI_ENCTYPE;
129
130 typedef enum
131 {
132     ES_ERROR = -1,
133     ES_OK = 0,
134     ES_NETWORKFOUND = 1,
135     ES_NETWORKCONNECTED,
136     ES_NETWORKNOTCONNECTED,
137     ES_RESOURCECREATED = 11,
138     ES_RECVREQOFPROVRES = 21,
139     ES_RECVREQOFNETRES,
140     ES_RECVUPDATEOFPROVRES,
141     ES_RECVTRIGGEROFPROVRES,
142     ES_UNAUTHORIZED = 31,
143     ES_UNSUPPORTED_OPERATION = 41
144 } ESResult;
145
146 /**
147  * @brief Indicate which resource is created in Enrollee
148  */
149 typedef enum
150 {
151     ES_WIFI_RESOURCE = 0x01,
152     ES_CLOUD_RESOURCE = 0x02,
153     ES_DEVCONF_RESOURCE = 0x04
154 } ESResourceMask;
155
156 /**
157  * @brief Indicate enrollee and provisioning status. Provisioning status is shown in "provisioning
158  *        status" property in provisioning resource.
159  */
160 typedef enum
161 {
162     /**
163      * Default state of the device
164      */
165     ES_STATE_INIT = 0,
166
167     /**
168     * Status indicating being cnnecting to target network
169     */
170     ES_STATE_CONNECTING_TO_ENROLLER,
171
172     /**
173     * Status indicating successful conection to target network
174     */
175     ES_STATE_CONNECTED_TO_ENROLLER,
176
177     /**
178     * Status indicating failure connection to target network
179     */
180     ES_STATE_CONNECTED_FAIL_TO_ENROLLER,
181
182     /**
183     * Status indicating successful registration to cloud
184     */
185     ES_STATE_REGISTERED_TO_CLOUD,
186
187     /**
188     * Status indicating failure registeration to cloud
189     */
190     ES_STATE_REGISTRRED_FAIL_TO_CLOUD
191 } ESEnrolleeState, ProvStatus;
192
193 /**
194  * @brief Indicate last error code to describe a reason of error during easy setup.
195  */
196 typedef enum
197 {
198     /**
199      * Init Error Code
200      */
201     ES_ERRCODE_NO_ERROR = 0,
202
203     /**
204     * Error Code that given WiFi's SSID is not found
205     */
206     ES_ERRCODE_SSID_NOT_FOUND,
207
208     /**
209     * Error Code that given WiFi's Password is wrong
210     */
211     ES_ERRCODE_PW_WRONG,
212
213     /**
214     * Error Code that IP address is not allocated
215     */
216     ES_ERRCODE_IP_NOT_ALLOCATED,
217
218     /**
219     * Error Code that there is no Internet connection
220     */
221     ES_ERRCODE_NO_INTERNETCONNECTION,
222
223     /**
224     * Error Code that Timeout occured
225     */
226     ES_ERRCODE_TIMEOUT,
227
228     /**
229     * Error Code that Unknown error occured
230     */
231     ES_ERRCODE_UNKNOWN
232 } ESErrorCode;
233
234 #ifdef __cplusplus
235 }
236 #endif
237
238 #endif //ES_COMMON_H_