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