Merge all changes of easy setup in master branch to 1.2-rel branch
[platform/upstream/iotivity.git] / service / easy-setup / inc / escommon.h
index e0577e7..8ce57b0 100755 (executable)
@@ -30,14 +30,9 @@ extern "C"
 #endif
 
 // Defines
-#define OIC_STRING_MAX_VALUE    100
-#define IPV4_ADDR_SIZE          16
-#define IP_PORT                 55555
-
-/**
- * @brief Mac address length for BT port
- */
-#define NET_MACADDR_SIZE 18
+#define OIC_STRING_MAX_VALUE    64
+#define MAX_WEBLINKLEN          3
+#define NUM_WIFIMODE            5
 
 /**
  * Attributes used to form a proper easysetup conforming JSON message.
@@ -58,76 +53,131 @@ extern "C"
 #define OC_RSRVD_ES_DEVNAME                "dn"
 #define OC_RSRVD_ES_LANGUAGE               "lang"
 #define OC_RSRVD_ES_COUNTRY                "ctry"
+#define OC_RSRVD_ES_MODELNUMBER            "mnmo"
+#define OC_RSRVD_ES_LOCATION               "loc"
+#define OC_RSRVD_ES_HREF                   "href"
 
 /**
  * Easysetup defined resoruce types and uris.
  */
-#define OC_RSRVD_ES_RES_TYPE_PROV         "ocf.wk.prov"
+#define OC_RSRVD_ES_RES_TYPE_PROV         "oic.wk.prov"
 #define OC_RSRVD_ES_URI_PROV              "/ProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_WIFI         "ocf.wk.wifi"
+#define OC_RSRVD_ES_RES_TYPE_WIFI         "oic.wk.wifi"
 #define OC_RSRVD_ES_URI_WIFI              "/WiFiProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER  "ocf.wk.cloudserver"
+#define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER  "oic.wk.cloudserver"
 #define OC_RSRVD_ES_URI_CLOUDSERVER       "/CloudServerProvisioningResURI"
-#define OC_RSRVD_ES_RES_TYPE_DEVCONF      "ocf.wk.devconf"
+#define OC_RSRVD_ES_RES_TYPE_DEVCONF      "oic.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
 
+/**
+ * @brief  Supported WIFI frequency like 2.4G and 5G
+ */
 typedef enum
 {
-    WiFi_11A = 0,
-    WiFi_11B,
-    WiFi_11G,
-    WiFi_11N,
-    WiFi_11AC,
-    WiFi_EOF = 999,
-} WIFI_MODE;
+    WIFI_24G = 0,       /**< 2.4G **/
+    WIFI_5G,            /**< 5G **/
+    WIFI_BOTH,          /**< 2.4G and 5G **/
+    WIFI_FREQ_NONE      /**< EOF **/
+} WIFI_FREQ;
 
+/**
+ * @brief  Supported WIFI mode like 802.11g and 802.11n
+ */
 typedef enum
 {
-    WiFi_24G = 0,
-    WiFi_5G,
-    WiFi_BOTH
-} WIFI_FREQ;
+    WIFI_11A = 0,       /**< 802.11a **/
+    WIFI_11B,           /**< 802.11b **/
+    WIFI_11G,           /**< 802.11g **/
+    WIFI_11N,           /**< 802.11n **/
+    WIFI_11AC,          /**< 802.11ac **/
+    WiFi_EOF = 999
+} WIFI_MODE;
 
+
+/**
+ * @brief  WIFI Authentication tlype of the Enroller
+ */
 typedef enum
 {
-    NONE_AUTH = 0,
-    WEP,
-    WPA_PSK,
-    WPA2_PSK
+    NONE_AUTH = 0,      /**< NO authentication **/
+    WEP,                /**< WEP **/
+    WPA_PSK,            /**< WPA-PSK **/
+    WPA2_PSK            /**< WPA2-PSK **/
 } WIFI_AUTHTYPE;
 
+/**
+ * @brief  WIFI encryption type of the Enroller
+ */
 typedef enum
 {
-    NONE_ENC = 0,
-    WEP_64,
-    WEP_128,
-    TKIP,
-    AES,
-    TKIP_AES
+    NONE_ENC = 0,       /**< NO encryption **/
+    WEP_64,             /**< WEP-64 **/
+    WEP_128,            /**< WEP-128**/
+    TKIP,               /**< TKIP **/
+    AES,                /**< AES **/
+    TKIP_AES            /**< TKIP-AES **/
 } WIFI_ENCTYPE;
 
+/**
+ * @brief A result of Easy Setup
+ */
 typedef enum
 {
-    ES_ERROR = -1,
+    /**
+     * 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
+
+    /**
+     * 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 = 20,
+
+    /**
+     * 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 because DTLS handshake failure happens
+     */
+    ES_OWNERSHIP_TRANSFER_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,
+
+    /**
+     * 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;
 
+/**
+ * @brief Indicate which resource is created in Enrollee
+ */
 typedef enum
 {
     ES_WIFI_RESOURCE = 0x01,
@@ -135,41 +185,10 @@ typedef enum
     ES_DEVCONF_RESOURCE = 0x04
 } ESResourceMask;
 
-typedef struct
-{
-    char ssid[MAX_SSIDLEN]; /**< ssid of the Enroller**/
-    char pwd[MAX_CREDLEN]; /**< pwd of the Enroller**/
-    WIFI_AUTHTYPE authtype; /**< auth type of the Enroller**/
-    WIFI_ENCTYPE enctype; /**< encryption type of the Enroller**/
-} ESWiFiProvData;
-
-typedef struct
-{
-    char language[OIC_STRING_MAX_VALUE];
-    char country[OIC_STRING_MAX_VALUE];
-} ESDevConfProvData;
-
-typedef struct
-{
-    char authCode[OIC_STRING_MAX_VALUE];
-    char authProvider[OIC_STRING_MAX_VALUE];
-    char ciServer[OIC_STRING_MAX_VALUE];
-    char serverID[OIC_STRING_MAX_VALUE];
-} ESCloudProvData;
-
-typedef struct
-{
-    struct
-    {
-        WIFI_MODE mode[NUM_WIFIMODE];
-        WIFI_FREQ freq;
-    } WiFi;
-    struct
-    {
-        char deviceName[MAX_DEVICELEN];
-    } DevConf;
-} ESDeviceProperty;
-
+/**
+ * @brief Indicate enrollee and provisioning status. Provisioning status is shown in "provisioning
+ *        status" property in provisioning resource.
+ */
 typedef enum
 {
     /**
@@ -203,6 +222,9 @@ typedef enum
     ES_STATE_REGISTRRED_FAIL_TO_CLOUD
 } ESEnrolleeState, ProvStatus;
 
+/**
+ * @brief Indicate last error code to describe a reason of error during easy setup.
+ */
 typedef enum
 {
     /**