#endif
// Defines
-#define OIC_STRING_MAX_VALUE 100
-#define IPV4_ADDR_SIZE 16
-#define IP_PORT 55555
+#define OC_RSRVD_ES_RES_TYPE_COL "oic.wk.col"
+#define OC_RSRVD_ES_INTERFACE "if"
+#define OC_RSRVD_ES_RES_TYPE "rt"
-/**
- * @brief Mac address length for BT port
- */
-#define NET_MACADDR_SIZE 18
+
+
+#define OIC_STRING_MAX_VALUE 256
+#define MAX_WEBLINKLEN 3
+#define NUM_WIFIMODE 10
+#define NUM_CONNECT_TYPE 3
/**
* Attributes used to form a proper easysetup conforming JSON message.
#define OC_RSRVD_ES_AUTHTYPE "wat"
#define OC_RSRVD_ES_ENCTYPE "wet"
#define OC_RSRVD_ES_AUTHCODE "ac"
+#define OC_RSRVD_ES_ACCESSTOKEN "at"
+#define OC_RSRVD_ES_ACCESSTOKEN_TYPE "att"
#define OC_RSRVD_ES_AUTHPROVIDER "apn"
#define OC_RSRVD_ES_CISERVER "cis"
#define OC_RSRVD_ES_SERVERID "sid"
#define OC_RSRVD_ES_DEVNAME "dn"
-#define OC_RSRVD_ES_LANGUAGE "lang"
-#define OC_RSRVD_ES_COUNTRY "ctry"
+#define OC_RSRVD_ES_HREF "href"
+#define OC_RSRVD_ES_CONNECT "cn"
/**
* Easysetup defined resoruce types and uris.
*/
-#define OC_RSRVD_ES_RES_TYPE_PROV "ocf.wk.prov"
-#define OC_RSRVD_ES_URI_PROV "/ProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_WIFI "ocf.wk.wifi"
-#define OC_RSRVD_ES_URI_WIFI "/WiFiProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER "ocf.wk.cloudserver"
-#define OC_RSRVD_ES_URI_CLOUDSERVER "/CloudServerProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_DEVCONF "ocf.wk.devconf"
-#define OC_RSRVD_ES_URI_DEVCONF "/DevConfProvisioningResURI"
-
-#define NUM_WIFIMODE 10
-#define MAX_SSIDLEN 33
-#define MAX_CREDLEN 20
-
-#define MAX_DEVICELEN 100
-#define MAX_WEBLINKLEN 100
+#define OC_RSRVD_ES_RES_TYPE_EASYSETUP "oic.r.easysetup"
+#define OC_RSRVD_ES_URI_EASYSETUP "/EasySetupResURI"
+#define OC_RSRVD_ES_RES_TYPE_WIFICONF "oic.r.wificonf"
+#define OC_RSRVD_ES_URI_WIFICONF "/WiFiConfResURI"
+#define OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF "oic.r.coapcloudconf"
+#define OC_RSRVD_ES_URI_COAPCLOUDCONF "/CoapCloudConfResURI"
+#define OC_RSRVD_ES_RES_TYPE_DEVCONF "oic.r.devconf"
+#define OC_RSRVD_ES_URI_DEVCONF "/DevConfResURI"
+
/**
* @brief Supported WIFI frequency like 2.4G and 5G
TKIP_AES /**< TKIP-AES **/
} WIFI_ENCTYPE;
+/**
+ * @brief OAuth Access Token Types. "bearer" and "mac" types are supported.
+ */
+typedef enum
+{
+ NONE_OAUTH_TOKENTYPE = 0,
+ OAUTH_TOKENTYPE_BEARER,
+ OAUTH_TOKENTYPE_MAC
+} OAUTH_TOKENTYPE;
+
+/**
+ * @brief A target configuration type to be connected (or executed)
+ */
typedef enum
{
- ES_ERROR = -1,
+ ES_CONNECT_NONE = 0, /**< Init value **/
+ ES_CONNECT_WIFI = 1, /**< WiFi Conf resource **/
+ ES_CONNECT_COAPCLOUD = 2 /**< Coap Cloud Conf resource **/
+} ES_CONNECT_TYPE;
+
+/**
+ * @brief A result of Easy Setup
+ */
+typedef enum
+{
+ /**
+ * Provisioning succeeds.
+ */
ES_OK = 0,
- ES_NETWORKFOUND = 1,
- ES_NETWORKCONNECTED,
- ES_NETWORKNOTCONNECTED,
- ES_RESOURCECREATED = 11,
- ES_RECVREQOFPROVRES = 21,
- ES_RECVREQOFNETRES,
- ES_RECVUPDATEOFPROVRES,
- ES_RECVTRIGGEROFPROVRES,
- ES_UNAUTHORIZED = 31
+
+ /**
+ * Secure resource is discovered.
+ */
+ ES_SECURE_RESOURCE_IS_DISCOVERED = 1,
+
+ /**
+ * Enrollee discovery fails in cloud provisioning
+ */
+ ES_ENROLLEE_DISCOVERY_FAILURE = 11,
+
+ /**
+ * Valid GET or POST request fails for some reason.
+ * This failure may happen when it failed to receive any response from Enrollee by a timeout threshold
+ */
+ ES_COMMUNICATION_ERROR,
+
+ /**
+ * Security opertion is not supported because Mediator is built as unsecured mode.
+ */
+ ES_SEC_OPERATION_IS_NOT_SUPPORTED,
+
+ /**
+ * Security resource discovery fails due to loss of discovery packet or absence of the resource in a network
+ */
+ ES_SECURE_RESOURCE_DISCOVERY_FAILURE,
+
+ /**
+ * Ownership transfer fails due to one of unexpected reasons.
+ * E.g. A packet loss even with retransmission happens during ownership transfer.
+ * E.g. Mediator's owned status is 'unowned'
+ * E.g. A user confirmation for random pin-based or certificate-based OT fails
+ */
+ ES_OWNERSHIP_TRANSFER_FAILURE = 20,
+
+ /**
+ * Ownership transfer which is cert-based method fails due to user confirmation is denied.
+ */
+ ES_USER_DENIED_CONFIRMATION_REQ,
+
+ /**
+ * Ownership transfer which is cert-based method fails due to wrong certificate.
+ */
+ ES_AUTHENTICATION_FAILURE_WITH_WRONG_CERT,
+
+ /**
+ * Ownership transfer which is random-pin method fails due to wrong pin.
+ */
+ ES_AUTHENTICATION_FAILURE_WITH_WRONG_PIN,
+
+ /**
+ * Ownership information is not synchronized between Mediator and Enrollee.
+ * e.g. A mediator's PDM DB has an ownership information to the found enrollee
+ * but it is actually owned by other mediator.
+ * That can happen where the found enrollee is reset and performed in easy setup without any inform to the first mediator.
+ * e.g. A list of owned devices managed in mediator's PMD db has no element for the found enrollee.
+ * That can happen where only mediator is reset without any inform to the enrollee.
+ * To proceed an ownership transfer to the enrollee, it needs to reset the enrollee's SVR DB for its owner, i.e. the mediator
+ */
+ ES_OWNERSHIP_IS_NOT_SYNCHRONIZED,
+
+ /**
+ * MOT is not supported at the target Enrollee device.
+ *
+ * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+ * @note If the mediator gets this values, it means OT has been successfully done
+ * (or already took an ownership, before), but failed MOT configuration.
+ */
+ ES_MOT_NOT_SUPPORTED = 30,
+
+ /**
+ * MOT enabling is failed.
+ *
+ * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+ * @note If the mediator gets this values, it means OT has been successfully done
+ * (or already took an ownership, before), but failed MOT configuration.
+ */
+ ES_MOT_ENABLING_FAILURE,
+
+ /**
+ * MOT method selection is failed
+ *
+ * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+ * @note If the mediator gets this values, it means OT has been successfully done
+ * (or already took an ownership, before), but failed MOT configuration.
+ */
+ ES_MOT_METHOD_SELECTION_FAILURE,
+
+ /**
+ * A provisioning of Pre-configured pin number for MOT is failed
+ *
+ * @note This ESResult values will be returned ONLY IF a mediator is a first owner to an Enrollee.
+ * @note If the mediator gets this values, it means OT has been successfully done
+ * (or already took an ownership, before), but failed MOT configuration.
+ */
+ ES_PRE_CONFIG_PIN_PROVISIONING_FAILURE,
+
+ /**
+ * ACL provisioning fails in cloud provisioning.
+ * It could be that UUID format of cloud server is wrong.
+ * Or any response for the provisioning request is not arrived at Mediator
+ */
+ ES_ACL_PROVISIONING_FAILURE = 40,
+
+ /**
+ * Cert. provisioning fails in cloud provisioning.
+ * It could be that you put a wrong cred ID of which the corresponding certificate does not exist in SVR DB.
+ * Or any response for the provisioning request is not arrived at Mediator
+ */
+ ES_CERT_PROVISIONING_FAILURE,
+
+ /**
+ * Provisioning fails for some reason.
+ */
+
+ ES_ERROR = 255
} ESResult;
/**
*/
typedef enum
{
- ES_WIFI_RESOURCE = 0x01,
- ES_CLOUD_RESOURCE = 0x02,
+ ES_WIFICONF_RESOURCE = 0x01,
+ ES_COAPCLOUDCONF_RESOURCE = 0x02,
ES_DEVCONF_RESOURCE = 0x04
} ESResourceMask;
/**
* @brief Indicate enrollee and provisioning status. Provisioning status is shown in "provisioning
- * status" property in provisioning resource.
+ * status" property in easysetup resource.
*/
typedef enum
{
ES_STATE_INIT = 0,
/**
- * Status indicating being cnnecting to target network
- */
+ * Status indicating being connecting to target network
+ */
ES_STATE_CONNECTING_TO_ENROLLER,
/**
- * Status indicating successful conection to target network
- */
+ * Status indicating successful conection to target network
+ */
ES_STATE_CONNECTED_TO_ENROLLER,
/**
- * Status indicating failure connection to target network
- */
- ES_STATE_CONNECTED_FAIL_TO_ENROLLER,
+ * Status indicating connection failure to target network
+ */
+ ES_STATE_FAILED_TO_CONNECT_TO_ENROLLER,
+
+ /**
+ * Status indicating being registering to cloud
+ */
+ ES_STATE_REGISTERING_TO_CLOUD,
/**
- * Status indicating successful registration to cloud
- */
+ * Status indicating successful registration to cloud
+ */
ES_STATE_REGISTERED_TO_CLOUD,
/**
- * Status indicating failure registeration to cloud
- */
- ES_STATE_REGISTRRED_FAIL_TO_CLOUD
+ * Status indicating registeration failure to cloud
+ */
+ ES_STATE_FAILED_TO_REGISTER_TO_CLOUD,
+
+ /**
+ * Status indicating being publishing resources to cloud
+ */
+ ES_STATE_PUBLISHING_RESOURCES_TO_CLOUD,
+
+ /**
+ * Status indicating successful resource publish to cloud
+ */
+ ES_STATE_PUBLISHED_RESOURCES_TO_CLOUD,
+
+ /**
+ * Status indicating resource publish failure to cloud
+ */
+ ES_STATE_FAILED_TO_PUBLISH_RESOURCES_TO_CLOUD,
+
+ /**
+ * End of Easy setup status
+ */
+ ES_STATE_EOF = 255
} ESEnrolleeState, ProvStatus;
/**
ES_ERRCODE_NO_ERROR = 0,
/**
- * Error Code that given WiFi's SSID is not found
- */
+ * Error Code that given WiFi's SSID is not found
+ */
ES_ERRCODE_SSID_NOT_FOUND,
/**
- * Error Code that given WiFi's Password is wrong
- */
+ * Error Code that given WiFi's Password is wrong
+ */
ES_ERRCODE_PW_WRONG,
/**
- * Error Code that IP address is not allocated
- */
+ * Error Code that IP address is not allocated
+ */
ES_ERRCODE_IP_NOT_ALLOCATED,
/**
- * Error Code that there is no Internet connection
- */
+ * Error Code that there is no Internet connection
+ */
ES_ERRCODE_NO_INTERNETCONNECTION,
/**
- * Error Code that Timeout occured
- */
+ * Error Code that Timeout occured
+ */
ES_ERRCODE_TIMEOUT,
/**
- * Error Code that Unknown error occured
- */
- ES_ERRCODE_UNKNOWN
+ * Error Code that cloud server is not reachable due to wrong URL of cloud server, for example.
+ */
+ ES_ERRCODE_FAILED_TO_ACCESS_CLOUD_SERVER,
+
+ /**
+ * Error Code that no response is arrived from cloud server
+ */
+ ES_ERRCODE_NO_RESPONSE_FROM_CLOUD_SERVER,
+
+ /**
+ * Error Code that a delivered authcode is not valid.
+ */
+ ES_ERRCODE_INVALID_AUTHCODE,
+
+ /**
+ * Error Code that a given access token is not valid due to its expiration, for example.
+ */
+ ES_ERRCODE_INVALID_ACCESSTOKEN,
+
+ /**
+ * Error Code that a refresh of expired access token is failed due to some reasons.
+ */
+ ES_ERRCODE_FAILED_TO_REFRESH_ACCESSTOKEN,
+
+ /**
+ * Error Code that a target device is not discovered in cloud server
+ */
+ ES_ERRCODE_FAILED_TO_FIND_REGISTERED_DEVICE_IN_CLOUD,
+
+ /**
+ * Error Code that a target user does not exist in cloud server.
+ */
+ ES_ERRCODE_FAILED_TO_FIND_REGISTERED_USER_IN_CLOUD,
+
+ /**
+ * Error Code that an enrollee can not connect to a target WiFi AP because the AP resides in
+ * an unsupported WiFi frequency.
+ */
+ ES_ERRCODE_UNSUPPORTED_WIFI_FREQUENCY,
+
+ /**
+ * Error Code that Unknown error occured
+ */
+ ES_ERRCODE_UNKNOWN = 255
} ESErrorCode;
#ifdef __cplusplus