[EasySetup] Fix links in baseline & ll response 29/22629/10
authorAnkur Bansal <ankur.b1@samsung.com>
Thu, 14 Sep 2017 05:35:10 +0000 (11:05 +0530)
committerUze Choi <uzchoi@samsung.com>
Wed, 18 Oct 2017 08:37:13 +0000 (08:37 +0000)
Update oic.r.easysetup baseline and link list response to correctly fill
links property.
Use OCLinksPayloadArrayCreate API to create the links payload for batch
& link list interface. OCLinksPayloadArrayCreate API internally takes
care of creating the most part of payload based on the properties of the
resource. This will replace the logic of creating each property of links
payload for each of the easy setup resources from the code.
In link list interface response, add handling for both OCF & OIC
response (for backward compatibility).

Bug:https://jira.iotivity.org/browse/IOT-2711

Change-Id: I46ca2e2d635cb78e8c7fc7c5ef95d9e16327abb9
Signed-off-by: Ankur Bansal <ankur.b1@samsung.com>
(cherry picked from commit 787a73bd227c69e313145ec978ee96769fa31112)

service/easy-setup/enrollee/src/resourcehandler.c

index 2c2640b..ad44e8f 100644 (file)
 #include "cautilinterface.h"
 #include "payload_logging.h"
 
+// TODO: Remove this flag and enable the code it guards.
+// This is a temporary workaround to ignore the failure of OCLinksPayloadArrayCreate
+// in some cases. This allows the response to still be made, even though links property will be
+// missing.
+// Bug: IOT-2762
+#define ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+
 /**
  * @var ES_RH_TAG
  * @brief Logging tag for module name.
@@ -1021,238 +1028,153 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest)
         return NULL;
     }
 
-    // Requested interface is Link list interface
-    if (!ehRequest->query ||
-        (ehRequest->query && !strcmp(ehRequest->query, "")) ||
-        (ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_LL)) ||
-        (ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
-    {
-        const OCRepPayload *arrayPayload[3] = {NULL};
-
-        int childResCnt = 0;
-
-        if (g_ESWiFiConfResource.handle != NULL)
-        {
-            OCRepPayload *add = OCRepPayloadCreate();
-            if (!add)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
-
-            size_t dimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
-            char **resourceType = NULL;
-            resourceType = (char **)OICMalloc(sizeof(char *) * 1);
-            char **resourceInterface = NULL;
-            resourceInterface = (char **)OICMalloc(sizeof(char *) * 1);
-
-            if (!resourceType || !resourceInterface)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
-
-            resourceType[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_WIFICONF);
-            resourceInterface[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
-
-            add->base.type = PAYLOAD_TYPE_REPRESENTATION;
-            OCRepPayloadSetPropString(add, OC_RSRVD_HREF, OC_RSRVD_ES_URI_WIFICONF);
-            OCRepPayloadSetStringArray(add, OC_RSRVD_RESOURCE_TYPE,
-                                            (const char **)resourceType, dimensions);
-            OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE,
-                                            (const char **)resourceInterface, dimensions);
+    OIC_LOG_V(DEBUG, ES_RH_TAG, "constructResponseOfEasySetup: qry = %s",
+            (ehRequest->query) ? (ehRequest->query) : "null");
 
-            OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)g_ESWiFiConfResource.handle);
-            OCRepPayload *policy = OCRepPayloadCreate();
-            if (!policy)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
+    // Requested interface is Link list or baseline interface
+     if (!ehRequest->query ||
+         (ehRequest->query && !strcmp(ehRequest->query, "")) ||
+         (ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_LL)) ||
+         (ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
+     {
+        size_t arraySize;
+        OCRepPayload **linkArr = OCLinksPayloadArrayCreate(OC_RSRVD_ES_URI_EASYSETUP, ehRequest,
+                &arraySize);
 
-            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);
-            }
+#ifdef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+        bool linkArrConstructed = true; // TODO: Remove this when
+                                        // ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE is removed.
+#endif
 
-            OCRepPayloadSetPropObject(add, OC_RSRVD_POLICY, policy);
-
-            arrayPayload[childResCnt++] = add;
-        }
-
-        if (g_ESDevConfResource.handle != NULL)
+        if (!linkArr || (arraySize == 0))
         {
-            OCRepPayload *add = OCRepPayloadCreate();
-            if (!add)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
+            OIC_LOG(ERROR, ES_RH_TAG, "Failed to create Easy Setup collections ll response.");
 
-            size_t dimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
-            char **resourceType = NULL;
-            resourceType = (char **)OICMalloc(sizeof(char *) * 1);
-            char **resourceInterface = NULL;
-            resourceInterface = (char **)OICMalloc(sizeof(char *) * 1);
-
-            if (!resourceType || !resourceInterface)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
-
-            resourceType[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_DEVCONF);
-            resourceInterface[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
-
-            add->base.type = PAYLOAD_TYPE_REPRESENTATION;
-            OCRepPayloadSetPropString(add, OC_RSRVD_HREF, OC_RSRVD_ES_URI_DEVCONF);
-            OCRepPayloadSetStringArray(add, OC_RSRVD_RESOURCE_TYPE,
-                                            (const char **)resourceType, dimensions);
-            OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE,
-                                            (const char **)resourceInterface, dimensions);
-
-            OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)g_ESDevConfResource.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;
+#ifdef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+            linkArrConstructed = false;
+#else
+            OICFree(linkArr);
+            OCRepPayloadDestroy(payload);
+            return NULL;
+#endif
         }
-
-        if (g_ESCoapCloudConfResource.handle != NULL)
+#ifndef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+        else
         {
-            OCRepPayload *add = OCRepPayloadCreate();
-            if (!add)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
-
-            size_t dimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
-            char **resourceType = NULL;
-            resourceType = (char **)OICMalloc(sizeof(char *) * 1);
-            char **resourceInterface = NULL;
-            resourceInterface = (char **)OICMalloc(sizeof(char *) * 1);
-
-            if (!resourceType || !resourceInterface)
-            {
-                OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                return NULL;
-            }
+#endif
+            OIC_LOG(DEBUG, ES_RH_TAG, "Constructed links payload.");
 
-            resourceType[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF);
-            resourceInterface[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
-
-            add->base.type = PAYLOAD_TYPE_REPRESENTATION;
-            OCRepPayloadSetPropString(add, OC_RSRVD_HREF, OC_RSRVD_ES_URI_COAPCLOUDCONF);
-            OCRepPayloadSetStringArray(add, OC_RSRVD_RESOURCE_TYPE,
-                                            (const char **)resourceType, dimensions);
-            OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE,
-                                            (const char **)resourceInterface, dimensions);
-
-            OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)g_ESCoapCloudConfResource.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)
+            if (!ehRequest->query || (ehRequest->query && !strcmp(ehRequest->query, ""))
+                    || (ehRequest->query
+                            && CompareResourceInterface(ehRequest->query,
+                                    OC_RSRVD_INTERFACE_DEFAULT)))
             {
-                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;
-        }
-
-        size_t dimensions[MAX_REP_ARRAY_DEPTH] = {childResCnt, 0, 0};
-
-        if (!ehRequest->query ||
-            (ehRequest->query && !strcmp(ehRequest->query, "")) ||
-            (ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
-        {
-            OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res (Default interface)");
-            OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_EASYSETUP);
-            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_EASYSETUP);
-            OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_COL);
+                OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res (Default interface)");
+                OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_EASYSETUP);
+                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_EASYSETUP);
+                OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_COL);
+
+                OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS,
+                        g_ESEasySetupResource.status);
+                OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE,
+                        g_ESEasySetupResource.lastErrCode);
+
+                if (g_ESEasySetupResource.numRequest > 0)
+                {
+                    size_t dimensions[MAX_REP_ARRAY_DEPTH] = { g_ESEasySetupResource.numRequest, 0,
+                            0 };
+                    int64_t *connectRequest = (int64_t *) OICMalloc(
+                            g_ESEasySetupResource.numRequest * sizeof(int64_t));
+                    if (!connectRequest)
+                    {
+                        OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+                        return NULL;
+                    }
 
-            OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS, g_ESEasySetupResource.status);
-            OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE, g_ESEasySetupResource.lastErrCode);
+                    for (int i = 0; i < g_ESEasySetupResource.numRequest; ++i)
+                    {
+                        connectRequest[i] = g_ESEasySetupResource.connectRequest[i];
+                    }
 
-            if (g_ESEasySetupResource.numRequest > 0)
-            {
-                size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_ESEasySetupResource.numRequest, 0, 0};
-                int64_t *connectRequest = (int64_t *)OICMalloc(g_ESEasySetupResource.numRequest  * sizeof(int64_t));
-                if (!connectRequest)
+                    bool b = OCRepPayloadSetIntArrayAsOwner(payload, OC_RSRVD_ES_CONNECT,
+                            (int64_t *) connectRequest, dimensions);
+                    if (!b)
+                    {
+                        OIC_LOG(ERROR, ES_RH_TAG, "Failed to set array value for Connect property");
+                        OICFree(connectRequest);
+                    }
+                }
+                else
                 {
-                    OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
-                    return NULL;
+                    OIC_LOG(DEBUG, ES_RH_TAG, "g_ESEasySetupResource.numRequest is 0");
+                    size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0, 0, 0 };
+                    OCRepPayloadSetIntArrayAsOwner(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
                 }
 
-                for(int i = 0 ; i < g_ESEasySetupResource.numRequest  ; ++i)
+                if (gWriteUserdataCb)
                 {
-                    connectRequest[i] = g_ESEasySetupResource.connectRequest[i];
+                    gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_EASYSETUP);
                 }
 
-                bool b = OCRepPayloadSetIntArrayAsOwner(payload, OC_RSRVD_ES_CONNECT, (int64_t *)connectRequest, dimensions);
-                if (!b)
+#ifdef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+                if (linkArrConstructed)
                 {
-                    OIC_LOG(ERROR, ES_RH_TAG, "Failed to set array value for Connect property");
-                    OICFree(connectRequest);
+#endif
+                    size_t dimensions[MAX_REP_ARRAY_DEPTH] = { arraySize, 0, 0 };
+                    OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_LINKS,
+                            (const OCRepPayload **) linkArr, dimensions);
+                    for (size_t i = 0; i < arraySize; ++i)
+                    {
+                        OCRepPayloadDestroy(linkArr[i]);
+                    }
+#ifdef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
                 }
+#endif
             }
-            else
+            else // link list interface
             {
-                OIC_LOG(DEBUG, ES_RH_TAG, "g_ESEasySetupResource.numRequest is 0");
-                size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
-                OCRepPayloadSetIntArrayAsOwner(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
-            }
-
-            if (gWriteUserdataCb)
-            {
-                gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_EASYSETUP);
+#ifdef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+                if (linkArrConstructed)
+                {
+#endif
+                    uint16_t acceptVersion = 0;
+                    OCPayloadFormat contentFormat; // not used
+                    OCGetRequestPayloadVersion(ehRequest, &contentFormat, &acceptVersion);
+                    // acceptVersion("OCF-Accept-Content-Format-Version") is present for OCF Request
+                    if (acceptVersion != 0)
+                    {
+                        for (size_t i = 0; i < arraySize - 1; ++i)
+                        {
+                            linkArr[i]->next = linkArr[i + 1];
+                        }
+                        // payload is directly the linkArr array, free earlier allocated memory.
+                        OCRepPayloadDestroy(payload);
+                        payload = linkArr[0];
+                    }
+                    else // for backward compatibility with OIC
+                    {
+                        size_t dimensions[MAX_REP_ARRAY_DEPTH] = { arraySize, 0, 0 };
+                        OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_LINKS,
+                                (const OCRepPayload **) linkArr, dimensions);
+                        for (size_t i = 0; i < arraySize; ++i)
+                        {
+                            OCRepPayloadDestroy(linkArr[i]);
+                        }
+                    }
+#ifdef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
+                }
+#endif
             }
-
-            OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_ES_LINKS, arrayPayload, dimensions);
-        }
-        else    // link list interface
-        {
-            OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_ES_LINKS, arrayPayload, dimensions);
+#ifndef ES_IGNORE_OCLinksPayloadArrayCreate_FAILIURE
         }
-    } else if (
-        ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
-
+#endif
+        OICFree(linkArr);
+    }
+    else if (ehRequest->query
+            && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
     {
         OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res (Batch Interface)");
         OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_EASYSETUP);
@@ -1266,8 +1188,8 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest)
             return NULL;
         }
 
-        size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {3, 0, 0};
-        char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+        size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = { 3, 0, 0 };
+        char **interfaces = (char **) OICMalloc(3 * sizeof(char*));
         if (!interfaces)
         {
             OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
@@ -1278,10 +1200,11 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest)
         interfaces[1] = OICStrdup(OC_RSRVD_INTERFACE_LL);
         interfaces[2] = OICStrdup(OC_RSRVD_INTERFACE_BATCH);
 
-        OCRepPayloadSetStringArray(repPayload, OC_RSRVD_ES_INTERFACE, (const char **)interfaces, interfacesDimensions);
+        OCRepPayloadSetStringArray(repPayload, OC_RSRVD_ES_INTERFACE, (const char **) interfaces,
+                interfacesDimensions);
 
-        size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {2, 0, 0};
-        char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+        size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = { 2, 0, 0 };
+        char **resourceTypes = (char **) OICMalloc(2 * sizeof(char*));
         if (!resourceTypes)
         {
             OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
@@ -1291,26 +1214,30 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest)
         resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_EASYSETUP);
         resourceTypes[1] = OICStrdup(OC_RSRVD_ES_RES_TYPE_COL);
 
-        OCRepPayloadSetStringArray(repPayload, OC_RSRVD_ES_RES_TYPE, (const char **)resourceTypes, resourceTypesDimensions);
+        OCRepPayloadSetStringArray(repPayload, OC_RSRVD_ES_RES_TYPE, (const char **) resourceTypes,
+                resourceTypesDimensions);
 
         OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_PROVSTATUS, g_ESEasySetupResource.status);
-        OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_LAST_ERRORCODE, g_ESEasySetupResource.lastErrCode);
+        OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_LAST_ERRORCODE,
+                g_ESEasySetupResource.lastErrCode);
         if (g_ESEasySetupResource.numRequest > 0)
         {
-            size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_ESEasySetupResource.numRequest, 0, 0};
-            int64_t *connectRequest = (int64_t *)OICMalloc(g_ESEasySetupResource.numRequest  * sizeof(int64_t));
+            size_t dimensions[MAX_REP_ARRAY_DEPTH] = { g_ESEasySetupResource.numRequest, 0, 0 };
+            int64_t *connectRequest = (int64_t *) OICMalloc(
+                    g_ESEasySetupResource.numRequest * sizeof(int64_t));
             if (!connectRequest)
             {
                 OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
                 return NULL;
             }
 
-            for (int i = 0 ; i < g_ESEasySetupResource.numRequest  ; ++i)
+            for (int i = 0; i < g_ESEasySetupResource.numRequest; ++i)
             {
                 connectRequest[i] = g_ESEasySetupResource.connectRequest[i];
             }
 
-            bool b = OCRepPayloadSetIntArrayAsOwner(repPayload, OC_RSRVD_ES_CONNECT, (int64_t *)connectRequest, dimensions);
+            bool b = OCRepPayloadSetIntArrayAsOwner(repPayload, OC_RSRVD_ES_CONNECT,
+                    (int64_t *) connectRequest, dimensions);
             if (!b)
             {
                 OIC_LOG(ERROR, ES_RH_TAG, "Failed to set array value for Connect property");
@@ -1320,7 +1247,7 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest)
         else
         {
             OIC_LOG(DEBUG, ES_RH_TAG, "g_ESEasySetupResource.numRequest is 0");
-            size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
+            size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0, 0, 0 };
             OCRepPayloadSetIntArrayAsOwner(repPayload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
         }
 
@@ -1330,37 +1257,32 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest)
         }
 
         OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
-    }
-
-    if (ehRequest->query)
-    {
-        if (CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
-        {// When Provisioning resource has a GET with BatchInterface
-            OCRepPayload* head = payload;
-            OCRepPayload* nextPayload = NULL;
 
-            nextPayload = constructResponseOfWiFiConf(OC_RSRVD_INTERFACE_BATCH);
-            if (nextPayload != NULL)
-            {
-                payload->next = nextPayload;
-                payload = payload->next;
-            }
+        OCRepPayload* head = payload;
+        OCRepPayload* nextPayload = NULL;
 
-            nextPayload = constructResponseOfCoapCloudConf(OC_RSRVD_INTERFACE_BATCH);
-            if (nextPayload != NULL)
-            {
-                payload->next = nextPayload;
-                payload = payload->next;
-            }
+        nextPayload = constructResponseOfWiFiConf(OC_RSRVD_INTERFACE_BATCH);
+        if (nextPayload != NULL)
+        {
+            payload->next = nextPayload;
+            payload = payload->next;
+        }
 
-            nextPayload = constructResponseOfDevConf(OC_RSRVD_INTERFACE_BATCH);
-            if (nextPayload != NULL)
-            {
-                payload->next = nextPayload;
-            }
+        nextPayload = constructResponseOfCoapCloudConf(OC_RSRVD_INTERFACE_BATCH);
+        if (nextPayload != NULL)
+        {
+            payload->next = nextPayload;
+            payload = payload->next;
+        }
 
-            payload = head;
+        nextPayload = constructResponseOfDevConf(OC_RSRVD_INTERFACE_BATCH);
+        if (nextPayload != NULL)
+        {
+            payload->next = nextPayload;
         }
+
+        payload = head;
+
     }
 
     return payload;