1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
33 #define OC_RSRVD_ES_RES_TYPE_COL "oic.wk.col"
34 #define OC_RSRVD_ES_INTERFACE "if"
35 #define OC_RSRVD_ES_RES_TYPE "rt"
39 #define OIC_STRING_MAX_VALUE 256
40 #define OIC_STRING_ACCESS_TOKEN_MAX_VALUE 1024
41 #define MAX_WEBLINKLEN 3
42 #define NUM_WIFIMODE 10
43 #define NUM_CONNECT_TYPE 3
46 * Attributes used to form a proper easysetup conforming JSON message.
48 #define OC_RSRVD_ES_PROVSTATUS "ps"
49 #define OC_RSRVD_ES_LAST_ERRORCODE "lec"
50 #define OC_RSRVD_ES_LINKS "links"
51 #define OC_RSRVD_ES_SUPPORTEDWIFIMODE "swmt"
52 #define OC_RSRVD_ES_SUPPORTEDWIFIFREQ "swf"
53 #define OC_RSRVD_ES_SSID "tnn"
54 #define OC_RSRVD_ES_CRED "cd"
55 #define OC_RSRVD_ES_AUTHTYPE "wat"
56 #define OC_RSRVD_ES_ENCTYPE "wet"
57 #define OC_RSRVD_ES_AUTHCODE "ac"
58 #define OC_RSRVD_ES_ACCESSTOKEN "at"
59 #define OC_RSRVD_ES_ACCESSTOKEN_TYPE "att"
60 #define OC_RSRVD_ES_AUTHPROVIDER "apn"
61 #define OC_RSRVD_ES_CISERVER "cis"
62 #define OC_RSRVD_ES_SERVERID "sid"
63 #define OC_RSRVD_ES_DEVNAME "dn"
64 #define OC_RSRVD_ES_HREF "href"
65 #define OC_RSRVD_ES_CONNECT "cn"
68 * Easysetup defined resoruce types and uris.
70 #define OC_RSRVD_ES_RES_TYPE_EASYSETUP "oic.r.easysetup"
71 #define OC_RSRVD_ES_URI_EASYSETUP "/EasySetupResURI"
72 #define OC_RSRVD_ES_RES_TYPE_WIFICONF "oic.r.wificonf"
73 #define OC_RSRVD_ES_URI_WIFICONF "/WiFiConfResURI"
74 #define OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF "oic.r.coapcloudconf"
75 #define OC_RSRVD_ES_URI_COAPCLOUDCONF "/CoapCloudConfResURI"
76 #define OC_RSRVD_ES_RES_TYPE_DEVCONF "oic.r.devconf"
77 #define OC_RSRVD_ES_URI_DEVCONF "/DevConfResURI"
81 * @brief Supported WIFI frequency like 2.4G and 5G
85 WIFI_24G = 0, /**< 2.4G **/
87 WIFI_BOTH, /**< 2.4G and 5G **/
88 WIFI_FREQ_NONE /**< EOF **/
92 * @brief Supported WIFI mode like 802.11g and 802.11n
96 WIFI_11A = 0, /**< 802.11a **/
97 WIFI_11B, /**< 802.11b **/
98 WIFI_11G, /**< 802.11g **/
99 WIFI_11N, /**< 802.11n **/
100 WIFI_11AC, /**< 802.11ac **/
106 * @brief WIFI Authentication tlype of the Enroller
110 NONE_AUTH = 0, /**< NO authentication **/
112 WPA_PSK, /**< WPA-PSK **/
113 WPA2_PSK, /**< WPA2-PSK **/
114 FT_PSK /**< FT-PSK **/
118 * @brief WIFI encryption type of the Enroller
122 NONE_ENC = 0, /**< NO encryption **/
123 WEP_64, /**< WEP-64 **/
124 WEP_128, /**< WEP-128**/
127 TKIP_AES /**< TKIP-AES **/
131 * @brief OAuth Access Token Types. "bearer" and "mac" types are supported.
135 NONE_OAUTH_TOKENTYPE = 0,
136 OAUTH_TOKENTYPE_BEARER,
141 * @brief A target configuration type to be connected (or executed)
145 ES_CONNECT_NONE = 0, /**< Init value **/
146 ES_CONNECT_WIFI = 1, /**< WiFi Conf resource **/
147 ES_CONNECT_COAPCLOUD = 2 /**< Coap Cloud Conf resource **/
151 * @brief A result of Easy Setup
156 * Provisioning succeeds.
161 * Secure resource is discovered.
163 ES_SECURE_RESOURCE_IS_DISCOVERED = 1,
166 * Enrollee discovery fails in cloud provisioning
168 ES_ENROLLEE_DISCOVERY_FAILURE = 11,
171 * Valid GET or POST request fails for some reason.
172 * This failure may happen when it failed to receive any response from Enrollee by a timeout threshold
174 ES_COMMUNICATION_ERROR,
177 * Security opertion is not supported because Mediator is built as unsecured mode.
179 ES_SEC_OPERATION_IS_NOT_SUPPORTED,
182 * Security resource discovery fails due to loss of discovery packet or absence of the resource in a network
184 ES_SECURE_RESOURCE_DISCOVERY_FAILURE,
187 * Ownership transfer fails due to one of unexpected reasons.
188 * E.g. A packet loss even with retransmission happens during ownership transfer.
189 * E.g. Mediator's owned status is 'unowned'
190 * E.g. A user confirmation for random pin-based or certificate-based OT fails
192 ES_OWNERSHIP_TRANSFER_FAILURE = 20,
195 * Ownership transfer which is cert-based method fails due to user confirmation is denied.
197 ES_USER_DENIED_CONFIRMATION_REQ,
200 * Ownership transfer which is cert-based method fails due to wrong certificate.
202 ES_AUTHENTICATION_FAILURE_WITH_WRONG_CERT,
205 * Ownership transfer which is random-pin method fails due to wrong pin.
207 ES_AUTHENTICATION_FAILURE_WITH_WRONG_PIN,
210 * Ownership information is not synchronized between Mediator and Enrollee.
211 * e.g. A mediator's PDM DB has an ownership information to the found enrollee
212 * but it is actually owned by other mediator.
213 * That can happen where the found enrollee is reset and performed in easy setup without any inform to the first mediator.
214 * e.g. A list of owned devices managed in mediator's PMD db has no element for the found enrollee.
215 * That can happen where only mediator is reset without any inform to the enrollee.
216 * To proceed an ownership transfer to the enrollee, it needs to reset the enrollee's SVR DB for its owner, i.e. the mediator
218 ES_OWNERSHIP_IS_NOT_SYNCHRONIZED,
221 * MOT is not supported at the target Enrollee device.
223 * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
224 * @note If the mediator gets this values, it means OT has been successfully done
225 * (or already took an ownership, before), but failed MOT configuration.
227 ES_MOT_NOT_SUPPORTED = 30,
230 * MOT enabling is failed.
232 * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
233 * @note If the mediator gets this values, it means OT has been successfully done
234 * (or already took an ownership, before), but failed MOT configuration.
236 ES_MOT_ENABLING_FAILURE,
239 * MOT method selection is failed
241 * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
242 * @note If the mediator gets this values, it means OT has been successfully done
243 * (or already took an ownership, before), but failed MOT configuration.
245 ES_MOT_METHOD_SELECTION_FAILURE,
248 * A provisioning of Pre-configured pin number for MOT is failed
250 * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
251 * @note If the mediator gets this values, it means OT has been successfully done
252 * (or already took an ownership, before), but failed MOT configuration.
254 ES_PRE_CONFIG_PIN_PROVISIONING_FAILURE,
257 * ACL provisioning fails in cloud provisioning.
258 * It could be that UUID format of cloud server is wrong.
259 * Or any response for the provisioning request is not arrived at Mediator
261 ES_ACL_PROVISIONING_FAILURE = 40,
264 * Cert. provisioning fails in cloud provisioning.
265 * It could be that you put a wrong cred ID of which the corresponding certificate does not exist in SVR DB.
266 * Or any response for the provisioning request is not arrived at Mediator
268 ES_CERT_PROVISIONING_FAILURE,
271 * Provisioning fails for some reason.
278 * @brief Indicate which resource is created in Enrollee
282 ES_WIFICONF_RESOURCE = 0x01,
283 ES_COAPCLOUDCONF_RESOURCE = 0x02,
284 ES_DEVCONF_RESOURCE = 0x04
288 * @brief Indicate enrollee and provisioning status. Provisioning status is shown in "provisioning
289 * status" property in easysetup resource.
294 * Default state of the device
299 * Status indicating being connecting to target network
301 ES_STATE_CONNECTING_TO_ENROLLER,
304 * Status indicating successful conection to target network
306 ES_STATE_CONNECTED_TO_ENROLLER,
309 * Status indicating connection failure to target network
311 ES_STATE_FAILED_TO_CONNECT_TO_ENROLLER,
314 * Status indicating being registering to cloud
316 ES_STATE_REGISTERING_TO_CLOUD,
319 * Status indicating successful registration to cloud
321 ES_STATE_REGISTERED_TO_CLOUD,
324 * Status indicating registeration failure to cloud
326 ES_STATE_FAILED_TO_REGISTER_TO_CLOUD,
329 * Status indicating being publishing resources to cloud
331 ES_STATE_PUBLISHING_RESOURCES_TO_CLOUD,
334 * Status indicating successful resource publish to cloud
336 ES_STATE_PUBLISHED_RESOURCES_TO_CLOUD,
339 * Status indicating resource publish failure to cloud
341 ES_STATE_FAILED_TO_PUBLISH_RESOURCES_TO_CLOUD,
344 * Status indicating aborted provisioning by enrollee
346 ES_STATE_ABORTED_PROVISIONING_BY_ENROLLEE,
349 * End of Easy setup status
352 } ESEnrolleeState, ProvStatus;
355 * @brief Indicate last error code to describe a reason of error during easy setup.
362 ES_ERRCODE_NO_ERROR = 0,
365 * Error Code that given WiFi's SSID is not found
367 ES_ERRCODE_SSID_NOT_FOUND,
370 * Error Code that given WiFi's Password is wrong
375 * Error Code that IP address is not allocated
377 ES_ERRCODE_IP_NOT_ALLOCATED,
380 * Error Code that there is no Internet connection
382 ES_ERRCODE_NO_INTERNETCONNECTION,
385 * Error Code that Timeout occured
390 * Error Code that cloud server is not reachable due to wrong URL of cloud server, for example.
392 ES_ERRCODE_FAILED_TO_ACCESS_CLOUD_SERVER,
395 * Error Code that no response is arrived from cloud server
397 ES_ERRCODE_NO_RESPONSE_FROM_CLOUD_SERVER,
400 * Error Code that a delivered authcode is not valid.
402 ES_ERRCODE_INVALID_AUTHCODE,
405 * Error Code that a given access token is not valid due to its expiration, for example.
407 ES_ERRCODE_INVALID_ACCESSTOKEN,
410 * Error Code that a refresh of expired access token is failed due to some reasons.
412 ES_ERRCODE_FAILED_TO_REFRESH_ACCESSTOKEN,
415 * Error Code that a target device is not discovered in cloud server
417 ES_ERRCODE_FAILED_TO_FIND_REGISTERED_DEVICE_IN_CLOUD,
420 * Error Code that a target user does not exist in cloud server.
422 ES_ERRCODE_FAILED_TO_FIND_REGISTERED_USER_IN_CLOUD,
425 * Error Code that an enrollee can not connect to a target WiFi AP because the AP resides in
426 * an unsupported WiFi frequency.
428 ES_ERRCODE_UNSUPPORTED_WIFI_FREQUENCY,
431 * Error Code that Unknown error occured
433 ES_ERRCODE_UNKNOWN = 255
440 #endif //ES_COMMON_H_