Update a payload format to be compatible to OIC spec in easysetup
authorParkhi <h_w.park@samsung.com>
Wed, 30 Nov 2016 02:42:56 +0000 (11:42 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 6 Dec 2016 05:07:47 +0000 (05:07 +0000)
1. In a response for get/post request with batch interface,
   "rep" keyword should be included for containing child resource's properties
   for each child resource.
2. Provisioning resource is a collection resource so it should have
   a "oic.wk.col" resource type.
3. "links" property for baseline and linklist interfaces should include a
   "p"(i.e. policy) property.

e.g. response for baseline:
{
  "rt":[
    "oic.wk.prov",
    "oic.wk.col"
  ],
  "if":[
    "oic.if.baseline",
    "oic.if.ll",
    "oic.if.b"
  ],
  "ps":0,
  "lec":0,
  "links":[
    {
      "href":"/WiFiProvisioningResURI",
      "rt":[
        "oic.wk.wifi"
      ],
      "if":[
        "oic.if.baseline"
      ],
      "p":{
        "bm":3
      }
    },
    {
      "href":"/DevConfProvisioningResURI",
      "rt":[
        "oic.wk.devconf"
      ],
      "if":[
        "oic.if.baseline"
      ],
      "p":{
        "bm":3
      }
    },
    {
      "href":"/CloudServerProvisioningResURI",
      "rt":[
        "oic.wk.cloudserver"
      ],
      "if":[
        "oic.if.baseline"
      ],
      "p":{
        "bm":3
      }
    }
  ]
}

e.g. response for linklist:
{
  "links":[
    {
      "href":"/WiFiProvisioningResURI",
      "rt":[
        "oic.wk.wifi"
      ],
      "if":[
        "oic.if.baseline"
      ],
      "p":{
        "bm":3
      }
    },
    {
      "href":"/DevConfProvisioningResURI",
      "rt":[
        "oic.wk.devconf"
      ],
      "if":[
        "oic.if.baseline"
      ],
      "p":{
        "bm":3
      }
    },
    {
      "href":"/CloudServerProvisioningResURI",
      "rt":[
        "oic.wk.cloudserver"
      ],
      "if":[
        "oic.if.baseline"
      ],
      "p":{
        "bm":3
      }
    }
  ]
}

e.g. response for batch:
[
  {
    "href":"/ProvisioningResURI",
    "rep":{
      "if":[
        "oic.if.baseline",
        "oic.if.ll",
        "oic.if.b"
      ],
      "rt":[
        "oic.wk.prov",
        "oic.wk.col"
      ],
      "ps":0,
      "lec":0
    }
  },
  {
    "href":"/WiFiProvisioningResURI",
    "rep":{
      "if":[
        "oic.if.baseline"
      ],
      "rt":[
        "oic.wk.wifi"
      ],
      "swmt":[
        2,
        3,
        4
      ],
      "swf":1,
      "tnn":"",
      "cd":"",
      "wat":0,
      "wet":0
    }
  },
  {
    "href":"/CloudServerProvisioningResURI",
    "rep":{
      "if":[
        "oic.if.baseline"
      ],
      "rt":[
        "oic.wk.cloudserver"
      ],
      "ac":"",
      "apn":"",
      "cis":""
    }
  },
  {
    "href":"/DevConfProvisioningResURI",
    "rep":{
      "if":[
        "oic.if.baseline"
      ],
      "rt":[
        "oic.wk.devconf"
      ],
      "dn":"Test Device",
      "mnmo":"Test Model Number",
      "loc":"",
      "lang":"",
      "ctry":""
    }
  }

]

Change-Id: I13ccda6fedb7c628dc77cc13e84c1c10c0e1b487
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Signed-off-by: Parkhi <h_w.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14855
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit e1409c4bb075b7be18d911b07df07568a694c971)
Reviewed-on: https://gerrit.iotivity.org/gerrit/15139

service/easy-setup/enrollee/SConscript
service/easy-setup/enrollee/src/resourcehandler.c
service/easy-setup/enrollee/src/resourcehandler.h
service/easy-setup/inc/escommon.h
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/ESConstants.java
service/easy-setup/mediator/richsdk/android/EasySetupCore/src/main/java/org/iotivity/service/easysetup/mediator/EnrolleeConf.java
service/easy-setup/mediator/richsdk/inc/ESRichCommon.h

index ab4a2e2..b80fc90 100644 (file)
@@ -46,6 +46,7 @@ enrollee_env.PrependUnique(CPPPATH = [
                 enrollee_env.get('SRC_DIR') + '/resource/csdk/stack/include',
                 enrollee_env.get('SRC_DIR') + '/resource/csdk/logger/include',
                enrollee_env.get('SRC_DIR') + '/resource/csdk/security/include',
+               enrollee_env.get('SRC_DIR') + '/resource/csdk/connectivity/api',
                enrollee_env.get('SRC_DIR') + '/extlibs/cjson',
                enrollee_env.get('SRC_DIR') + '/service/easy-setup/inc',
                enrollee_env.get('SRC_DIR') + '/service/easy-setup/enrollee/inc',
index a6450d8..6c12afb 100755 (executable)
@@ -23,6 +23,7 @@
 #include "ocpayload.h"
 #include "oic_string.h"
 #include "oic_malloc.h"
+#include "cautilinterface.h"
 
 /**
  * @var ES_RH_TAG
@@ -140,7 +141,6 @@ OCStackResult initProvResource(bool isSecured)
 {
     gProvResource.status = ES_STATE_INIT;
     gProvResource.lastErrCode = ES_ERRCODE_NO_ERROR;
-    OICStrcpy(gProvResource.ocfWebLinks, MAX_WEBLINKLEN, "");
 
     OCStackResult res = OC_STACK_ERROR;
     if (isSecured)
@@ -162,6 +162,13 @@ OCStackResult initProvResource(bool isSecured)
         return res;
     }
 
+    res = OCBindResourceTypeToResource(gProvResource.handle, OC_RSRVD_ES_RES_TYPE_COL);
+    if(res)
+    {
+        OIC_LOG_V(INFO, ES_RH_TAG, "Binding Resource type with result: %s", getResult(res));
+        return res;
+    }
+
     res = OCBindResourceInterfaceToResource(gProvResource.handle, OC_RSRVD_INTERFACE_LL);
     if(res)
     {
@@ -295,8 +302,8 @@ void updateWiFiResource(OCRepPayload* input)
         return ;
     }
 
-    memset(wiFiData->ssid, 0, MAX_WEBLINKLEN);
-    memset(wiFiData->pwd, 0, MAX_WEBLINKLEN);
+    memset(wiFiData->ssid, 0, OIC_STRING_MAX_VALUE);
+    memset(wiFiData->pwd, 0, OIC_STRING_MAX_VALUE);
     wiFiData->authtype = NONE_AUTH;
     wiFiData->enctype = NONE_AUTH;
     wiFiData->userdata = NULL;
@@ -493,7 +500,7 @@ void updateDevConfResource(OCRepPayload* input)
     OICFree(devConfData);
 }
 
-OCRepPayload* constructResponseOfWiFi()
+OCRepPayload* constructResponseOfWiFi(char *interface)
 {
     OCRepPayload* payload = OCRepPayloadCreate();
     if (!payload)
@@ -510,8 +517,40 @@ OCRepPayload* constructResponseOfWiFi()
 
     OIC_LOG(INFO, ES_RH_TAG, "constructResponse wifi res");
     OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_WIFI);
-    OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
-    OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_WIFI);
+
+    OCRepPayload* repPayload = NULL;
+    OCRepPayload* tempPayload = NULL;
+    if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+    {
+        repPayload = OCRepPayloadCreate();
+        if (!repPayload)
+        {
+            OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+            return NULL;
+        }
+
+        tempPayload = payload;
+        payload = repPayload;
+
+        size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
+        char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+
+        interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
+
+        OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_INTERFACE, (char **)interfaces, interfacesDimensions);
+
+        size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
+        char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+
+        resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_WIFI);
+
+        OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_RES_TYPE, (char **)resourceTypes, resourceTypesDimensions);
+    }
+    else
+    {
+        OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
+        OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_WIFI);\r
+    }
 
     size_t dimensions[MAX_REP_ARRAY_DEPTH] = {gWiFiResource.numMode, 0, 0};
     int64_t *modes_64 = (int64_t *)OICMalloc(gWiFiResource.numMode * sizeof(int64_t));
@@ -532,10 +571,16 @@ OCRepPayload* constructResponseOfWiFi()
         gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_WIFI);
     }
 
+    if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+    {
+        payload = tempPayload;
+        OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
+    }
+
     return payload;
 }
 
-OCRepPayload* constructResponseOfCloud()
+OCRepPayload* constructResponseOfCloud(char *interface)
 {
     OCRepPayload* payload = OCRepPayloadCreate();
     if (!payload)
@@ -552,8 +597,40 @@ OCRepPayload* constructResponseOfCloud()
 
     OIC_LOG(INFO, ES_RH_TAG, "constructResponse cloudserver res");
     OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_CLOUDSERVER);
-    OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
-    OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER);
+
+    OCRepPayload* repPayload = NULL;
+    OCRepPayload* tempPayload = NULL;
+    if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+    {
+        repPayload = OCRepPayloadCreate();
+        if (!repPayload)
+        {
+            OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+            return NULL;
+        }
+
+        tempPayload = payload;
+        payload = repPayload;
+
+        size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
+        char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+
+        interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
+
+        OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_INTERFACE, (char **)interfaces, interfacesDimensions);
+
+        size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
+        char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+
+        resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_CLOUDSERVER);
+
+        OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_RES_TYPE, (char **)resourceTypes, resourceTypesDimensions);
+    }
+    else
+    {
+        OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
+        OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER);
+    }
 
     OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHCODE, gCloudResource.authCode);
     OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHPROVIDER, gCloudResource.authProvider);
@@ -564,10 +641,16 @@ OCRepPayload* constructResponseOfCloud()
         gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER);
     }
 
+    if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+    {
+        payload = tempPayload;
+        OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
+    }
+
     return payload;
 }
 
-OCRepPayload* constructResponseOfDevConf()
+OCRepPayload* constructResponseOfDevConf(char *interface)
 {
     OCRepPayload* payload = OCRepPayloadCreate();
     if (!payload)
@@ -584,8 +667,40 @@ OCRepPayload* constructResponseOfDevConf()
 
     OIC_LOG(INFO, ES_RH_TAG, "constructResponse devconf res");
     OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_DEVCONF);
-    OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
-    OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_DEVCONF);
+
+    OCRepPayload* repPayload = NULL;
+    OCRepPayload* tempPayload = NULL;
+    if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+    {
+        repPayload = OCRepPayloadCreate();
+        if (!repPayload)
+        {
+            OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+            return NULL;
+        }
+
+        tempPayload = payload;
+        payload = repPayload;
+
+        size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
+        char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+
+        interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
+
+        OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_INTERFACE, (char **)interfaces, interfacesDimensions);
+
+        size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
+        char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+
+        resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_DEVCONF);
+
+        OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_RES_TYPE, (char **)resourceTypes, resourceTypesDimensions);
+    }
+    else
+    {
+        OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
+        OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_DEVCONF);
+    }
 
     OCRepPayloadSetPropString(payload, OC_RSRVD_ES_DEVNAME, gDevConfResource.devName);
     OCRepPayloadSetPropString(payload, OC_RSRVD_ES_MODELNUMBER, gDevConfResource.modelNumber);
@@ -598,6 +713,12 @@ OCRepPayload* constructResponseOfDevConf()
         gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_DEVCONF);
     }
 
+    if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+    {
+        payload = tempPayload;
+        OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
+    }
+
     return payload;
 }
 
@@ -652,6 +773,26 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
             OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE,
                                             (const char **)resourceInterface, dimensions);
 
+            OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)gWiFiResource.handle);
+            OCRepPayload *policy = OCRepPayloadCreate();
+            if (!policy)
+            {
+                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+                return NULL;
+            }
+
+            OCRepPayloadSetPropInt(policy, OC_RSRVD_BITMAP,
+                                    ((p & OC_DISCOVERABLE) | (p & OC_OBSERVABLE)));
+            if (p & OC_SECURE)
+            {
+                OCRepPayloadSetPropBool(policy, OC_RSRVD_SECURE, p & OC_SECURE);
+                uint16_t securePort = CAGetAssignedPortNumber(ehRequest->devAddr.adapter,
+                                                                    ehRequest->devAddr.flags);
+                OCRepPayloadSetPropInt(policy, OC_RSRVD_HOSTING_PORT, securePort);
+            }
+
+            OCRepPayloadSetPropObject(add, OC_RSRVD_POLICY, policy);
+
             arrayPayload[childResCnt++] = add;
         }
 
@@ -686,6 +827,26 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
             OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE,
                                             (const char **)resourceInterface, dimensions);
 
+            OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)gDevConfResource.handle);
+            OCRepPayload *policy = OCRepPayloadCreate();
+            if (!policy)
+            {
+                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+                return NULL;
+            }
+
+            OCRepPayloadSetPropInt(policy, OC_RSRVD_BITMAP,
+                                    ((p & OC_DISCOVERABLE) | (p & OC_OBSERVABLE)));
+            if (p & OC_SECURE)
+            {
+                OCRepPayloadSetPropBool(policy, OC_RSRVD_SECURE, p & OC_SECURE);
+                uint16_t securePort = CAGetAssignedPortNumber(ehRequest->devAddr.adapter,
+                                                                    ehRequest->devAddr.flags);
+                OCRepPayloadSetPropInt(policy, OC_RSRVD_HOSTING_PORT, securePort);
+            }
+
+            OCRepPayloadSetPropObject(add, OC_RSRVD_POLICY, policy);
+
             arrayPayload[childResCnt++] = add;
         }
 
@@ -720,6 +881,26 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
             OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE,
                                             (const char **)resourceInterface, dimensions);
 
+            OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)gCloudResource.handle);
+            OCRepPayload *policy = OCRepPayloadCreate();
+            if (!policy)
+            {
+                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+                return NULL;
+            }
+
+            OCRepPayloadSetPropInt(policy, OC_RSRVD_BITMAP,
+                                    ((p & OC_DISCOVERABLE) | (p & OC_OBSERVABLE)));
+            if (p & OC_SECURE)
+            {
+                OCRepPayloadSetPropBool(policy, OC_RSRVD_SECURE, p & OC_SECURE);
+                uint16_t securePort = CAGetAssignedPortNumber(ehRequest->devAddr.adapter,
+                                                                    ehRequest->devAddr.flags);
+                OCRepPayloadSetPropInt(policy, OC_RSRVD_HOSTING_PORT, securePort);
+            }
+
+            OCRepPayloadSetPropObject(add, OC_RSRVD_POLICY, policy);
+
             arrayPayload[childResCnt++] = add;
         }
 
@@ -735,6 +916,7 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
             OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_LL);
             OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_BATCH);
             OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_PROV);
+            OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_COL);
 
             OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS, gProvResource.status);
             OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE, gProvResource.lastErrCode);
@@ -743,26 +925,7 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
         }
         else    // link list interface
         {
-            OCRepPayload* head = payload;
-            OCRepPayload* nextPayload = NULL;
-
-            for(int i = 0 ; i < childResCnt ; ++i)
-            {
-                nextPayload = arrayPayload[i];
-                if(nextPayload != NULL)
-                {
-                    payload->next = nextPayload;
-                    payload = payload->next;
-                }
-            }
-            if(head->next != NULL)
-            {
-                payload = head->next;
-            }
-            else
-            {
-                payload = head;
-            }
+            OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_ES_LINKS, arrayPayload, dimensions);
         }
     } else if (
         ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
@@ -770,13 +933,37 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
     {
         OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
         OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_PROV);
-        OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
-        OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_LL);
-        OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_BATCH);
-        OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_PROV);
 
-        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS, gProvResource.status);
-        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE, gProvResource.lastErrCode);
+        OCRepPayload* repPayload = NULL;
+
+        repPayload = OCRepPayloadCreate();
+        if (!repPayload)
+        {
+            OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+            return NULL;
+        }
+
+        size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {3, 0, 0};
+        char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+
+        interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
+        interfaces[1] = OICStrdup(OC_RSRVD_INTERFACE_LL);
+        interfaces[2] = OICStrdup(OC_RSRVD_INTERFACE_BATCH);
+
+        OCRepPayloadSetStringArray(repPayload, OC_RSRVD_ES_INTERFACE, (char **)interfaces, interfacesDimensions);
+
+        size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {2, 0, 0};
+        char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+
+        resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_PROV);
+        resourceTypes[1] = OICStrdup(OC_RSRVD_ES_RES_TYPE_COL);
+
+        OCRepPayloadSetStringArray(repPayload, OC_RSRVD_ES_RES_TYPE, (char **)resourceTypes, resourceTypesDimensions);
+
+        OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_PROVSTATUS, gProvResource.status);
+        OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_LAST_ERRORCODE, gProvResource.lastErrCode);
+
+        OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
     }
 
     if(gWriteUserdataCb)
@@ -791,21 +978,21 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
             OCRepPayload* head = payload;
             OCRepPayload* nextPayload = NULL;
 
-            nextPayload = constructResponseOfWiFi();
+            nextPayload = constructResponseOfWiFi(OC_RSRVD_INTERFACE_BATCH);
             if(nextPayload != NULL)
             {
                 payload->next = nextPayload;
                 payload = payload->next;
             }
 
-            nextPayload = constructResponseOfCloud();
+            nextPayload = constructResponseOfCloud(OC_RSRVD_INTERFACE_BATCH);
             if(nextPayload != NULL)
             {
                 payload->next = nextPayload;
                 payload = payload->next;
             }
 
-            nextPayload = constructResponseOfDevConf();
+            nextPayload = constructResponseOfDevConf(OC_RSRVD_INTERFACE_BATCH);
             if(nextPayload != NULL)
             {
                 payload->next = nextPayload;
@@ -1021,7 +1208,7 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRep
         }
         else
         {
-            getResp = constructResponseOfWiFi();
+            getResp = constructResponseOfWiFi(OC_RSRVD_INTERFACE_DEFAULT);
         }
     }
     else if(ehRequest->resource == gCloudResource.handle)
@@ -1033,7 +1220,7 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRep
         }
         else
         {
-            getResp = constructResponseOfCloud();
+            getResp = constructResponseOfCloud(OC_RSRVD_INTERFACE_DEFAULT);
         }
     }
     else if(ehRequest->resource == gDevConfResource.handle)
@@ -1045,7 +1232,7 @@ OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRep
         }
         else
         {
-            getResp = constructResponseOfDevConf();
+            getResp = constructResponseOfDevConf(OC_RSRVD_INTERFACE_DEFAULT);
         }
     }
 
@@ -1137,15 +1324,15 @@ OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRe
     }
     else if(ehRequest->resource == gWiFiResource.handle)
     {
-        getResp = constructResponseOfWiFi();
+        getResp = constructResponseOfWiFi(OC_RSRVD_INTERFACE_DEFAULT);
     }
     else if(ehRequest->resource == gCloudResource.handle)
     {
-        getResp = constructResponseOfCloud();
+        getResp = constructResponseOfCloud(OC_RSRVD_INTERFACE_DEFAULT);
     }
     else if(ehRequest->resource == gDevConfResource.handle)
     {
-        getResp = constructResponseOfDevConf();
+        getResp = constructResponseOfDevConf(OC_RSRVD_INTERFACE_DEFAULT);
     }
 
     if (!getResp)
index 5860450..03a6a05 100755 (executable)
@@ -47,7 +47,6 @@ typedef struct PROVRESOURCE
     OCResourceHandle handle;
     ProvStatus status; // provisiong status
     ESErrorCode lastErrCode;
-    char ocfWebLinks[MAX_WEBLINKLEN];
 } ProvResource;
 
 typedef struct
index f0b7e8e..c350109 100755 (executable)
@@ -30,6 +30,12 @@ extern "C"
 #endif
 
 // Defines
+#define OC_RSRVD_ES_RES_TYPE_COL          "oic.wk.col"
+#define OC_RSRVD_ES_INTERFACE             "if"
+#define OC_RSRVD_ES_RES_TYPE              "rt"
+
+
+
 #define OIC_STRING_MAX_VALUE    64
 #define MAX_WEBLINKLEN          3
 #define NUM_WIFIMODE            5
index a7f077e..b023d6c 100755 (executable)
@@ -22,6 +22,8 @@ package org.iotivity.service.easysetup.mediator;
 
 public class ESConstants {
 
+    public static final String OC_RSRVD_REPRESENTATION = "rep";
+
     public static final String OC_RSRVD_ES_PROVSTATUS = "ps";
     public static final String OC_RSRVD_ES_LAST_ERRORCODE = "lec";
     public static final String OC_RSRVD_ES_LINKS = "links";
index 7deca03..becbe52 100755 (executable)
@@ -75,8 +75,18 @@ public class EnrolleeConf
             {
                 try
                 {
-                    if(child.hasAttribute(ESConstants.OC_RSRVD_ES_DEVNAME)) {
-                        return (String) child.getValue(ESConstants.OC_RSRVD_ES_DEVNAME);
+                    OcRepresentation rep;
+                    if(child.hasAttribute(ESConstants.OC_RSRVD_REPRESENTATION))
+                    {
+                        rep = (OcRepresentation)child.getValue(ESConstants.OC_RSRVD_REPRESENTATION);
+                    }
+                    else
+                    {
+                        return null;
+                    }
+
+                    if(rep.hasAttribute(ESConstants.OC_RSRVD_ES_DEVNAME)) {
+                        return (String) rep.getValue(ESConstants.OC_RSRVD_ES_DEVNAME);
                     }
                 } catch (OcException e) {
                     Log.e(TAG, "getWiFiModes is failed.");
@@ -105,8 +115,18 @@ public class EnrolleeConf
             {
                 try
                 {
-                    if(child.hasAttribute(ESConstants.OC_RSRVD_ES_MODELNUMBER)) {
-                        return (String) child.getValue(ESConstants.OC_RSRVD_ES_MODELNUMBER);
+                    OcRepresentation rep;
+                    if(child.hasAttribute(ESConstants.OC_RSRVD_REPRESENTATION))
+                    {
+                        rep = (OcRepresentation)child.getValue(ESConstants.OC_RSRVD_REPRESENTATION);
+                    }
+                    else
+                    {
+                        return null;
+                    }
+
+                    if(rep.hasAttribute(ESConstants.OC_RSRVD_ES_MODELNUMBER)) {
+                        return (String) rep.getValue(ESConstants.OC_RSRVD_ES_MODELNUMBER);
                     }
                 } catch (OcException e) {
                     Log.e(TAG, "getModelNumber is failed.");
@@ -134,8 +154,18 @@ public class EnrolleeConf
             if(child.getUri().indexOf(ESConstants.OC_RSRVD_ES_URI_WIFI) != -1)
             {
                 try {
-                    if (child.hasAttribute(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIMODE)) {
-                        int modes_int[] = child.getValue(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIMODE);
+                    OcRepresentation rep;
+                    if(child.hasAttribute(ESConstants.OC_RSRVD_REPRESENTATION))
+                    {
+                        rep = (OcRepresentation)child.getValue(ESConstants.OC_RSRVD_REPRESENTATION);
+                    }
+                    else
+                    {
+                        return null;
+                    }
+
+                    if (rep.hasAttribute(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIMODE)) {
+                        int modes_int[] = rep.getValue(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIMODE);
                         for (int i = 0 ; i < modes_int.length ; ++i) {
                             modes.add(WIFI_MODE.fromInt(modes_int[i]));
                         }
@@ -166,9 +196,19 @@ public class EnrolleeConf
             if(child.getUri().indexOf(ESConstants.OC_RSRVD_ES_URI_WIFI) != -1)
             {
                 try{
-                    if(child.hasAttribute(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIFREQ))
+                    OcRepresentation rep;
+                    if(child.hasAttribute(ESConstants.OC_RSRVD_REPRESENTATION))
+                    {
+                        rep = (OcRepresentation)child.getValue(ESConstants.OC_RSRVD_REPRESENTATION);
+                    }
+                    else
+                    {
+                        return null;
+                    }
+
+                    if(rep.hasAttribute(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIFREQ))
                         return WIFI_FREQ.fromInt(
-                                (int)child.getValue(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIFREQ));
+                                (int)rep.getValue(ESConstants.OC_RSRVD_ES_SUPPORTEDWIFIFREQ));
                 } catch (OcException e) {
                     Log.e(TAG, "getWiFiFreq is failed.");
                 }
index 9bafeae..41fc10c 100755 (executable)
@@ -522,9 +522,19 @@ namespace OIC
                 {
                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
                     {
-                        if(child->hasAttribute(OC_RSRVD_ES_DEVNAME))
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
                         {
-                            return child->getValue<std::string>(OC_RSRVD_ES_DEVNAME);
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return std::string("");
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_DEVNAME))
+                        {
+                            return rep.getValue<std::string>(OC_RSRVD_ES_DEVNAME);
                         }
                     }
                 }
@@ -543,9 +553,19 @@ namespace OIC
                 {
                     if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
                     {
-                        if(child->hasAttribute(OC_RSRVD_ES_MODELNUMBER))
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return std::string("");
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_MODELNUMBER))
                         {
-                            return child->getValue<std::string>(OC_RSRVD_ES_MODELNUMBER);
+                            return rep.getValue<std::string>(OC_RSRVD_ES_MODELNUMBER);
                         }
                     }
                 }
@@ -569,9 +589,19 @@ namespace OIC
                 {
                     if(child->getUri().find(OC_RSRVD_ES_URI_WIFI) != std::string::npos)
                     {
-                        if(child->hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
                         {
-                            for(auto it : child->getValue
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return modes;
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
+                        {
+                            for(auto it : rep.getValue
                                         <std::vector<int>>(OC_RSRVD_ES_SUPPORTEDWIFIMODE))
                             {
                                 modes.push_back(static_cast<WIFI_MODE>(it));
@@ -596,10 +626,20 @@ namespace OIC
                 {
                     if(child->getUri().find(OC_RSRVD_ES_URI_WIFI) != std::string::npos)
                     {
-                        if(child->hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIFREQ))
+                        OCRepresentation rep;
+                        if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+                        {
+                            rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                        }
+                        else
+                        {
+                            return WIFI_FREQ_NONE;
+                        }
+
+                        if(rep.hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIFREQ))
                         {
                             return static_cast<WIFI_FREQ>(
-                                        child->getValue<int>(OC_RSRVD_ES_SUPPORTEDWIFIFREQ));
+                                        rep.getValue<int>(OC_RSRVD_ES_SUPPORTEDWIFIFREQ));
                         }
                     }
                 }