Implementation of response of group action (for remote resources)
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Fri, 19 Dec 2014 07:59:41 +0000 (16:59 +0900)
committerHyunJun Kim <hyunjun2.kim@samsung.com>
Fri, 19 Dec 2014 07:59:41 +0000 (16:59 +0900)
There is no response when resource client send message[POST]
to a group with GROUP_INTERFACE, so client cannot receive any message.

We provide logic about the aggregation of children' response.
Then, merged response will be delivered to client.

Additionally, regarding Sudarshan Prasad's comment of previous commit.
We change the definition of GROUP_INTERFACE.

Change-Id: I6c2550472d1e02cd2606317fcb1796e59e004b78
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
resource/csdk/stack/include/internal/ocresource.h
resource/csdk/stack/src/occollection.c
resource/csdk/stack/src/oicgroup.c
resource/examples/groupclient.cpp [new file with mode: 0755]
resource/examples/groupserver.cpp [new file with mode: 0755]
resource/examples/lightserver.cpp [new file with mode: 0755]
resource/examples/makefile [changed mode: 0644->0755]

index 01611c1..bbd652b 100755 (executable)
@@ -53,16 +53,16 @@ typedef enum {
     STACK_IF_INVALID
 } OCStackIfTypes;
 
-// following structure will be create in occollection.
+// following structure will be created in occollection.
 typedef struct occapability {
     struct occapability* next;
 
     char *capability;           // It is a name about resource capability.
-    char *status;               //
+    char *status;               // It is mean status of capability.
 } OCCapability;
 
 
-// following structure will be create in occollection.
+// following structure will be created in occollection.
 typedef struct ocaction {
     struct ocaction *next;
 
@@ -71,7 +71,6 @@ typedef struct ocaction {
     char *resourceUri;
 
     OCCapability* head;
-    
 } OCAction;
 
 // following structure will be created in occollection.
@@ -150,8 +149,7 @@ typedef struct rsrc_t {
     /* method_t methods; */
     // Sequence number for observable resources. Per the CoAP standard it is a 24 bit value.
     uint32_t sequenceNum;
-
-       // Pointer of ActionSet which to support group action.
+    // Pointer of ActionSet which to support group action.
     OCActionSet *actionsetHead;
 } OCResource;
 
index 23980ba..5d486bf 100755 (executable)
@@ -31,9 +31,7 @@
 
 #define WITH_GROUPACTION 1
 
-#ifdef WITH_GROUPACTION
 #include "oicgroup.h"
-#endif
 
 #define TAG PCF("occollection")
 
@@ -418,11 +416,9 @@ OCStackResult DefaultCollectionEntityHandler (OCEntityHandlerFlag flag,
                 ((OCServerRequest *)ehRequest->requestHandle)->numResponses =
                         GetNumOfResourcesInCollection((OCResource *)ehRequest->resource) + 1;
                 return HandleBatchInterface(ehRequest);
-#ifdef WITH_GROUPACTION
             case STACK_IF_GROUP:
-                return BuildCollectionGroupActionJSONResponse(OC_REST_GET/*flag*/, (OCResource *)ehRequest->resource,
-                                ehRequest);
-#endif  // WITH_GROUPACTION
+                return BuildCollectionGroupActionJSONResponse(OC_REST_GET/*flag*/,
+                        (OCResource *) ehRequest->resource, ehRequest);
             default:
                 return OC_STACK_ERROR;
         }
@@ -443,35 +439,33 @@ OCStackResult DefaultCollectionEntityHandler (OCEntityHandlerFlag flag,
                         GetNumOfResourcesInCollection((OCResource *)ehRequest->resource) + 1;
                 return HandleBatchInterface(ehRequest);
 
-
-#ifdef WITH_GROUPACTION
             case STACK_IF_GROUP:
             {
-                OC_LOG_V(INFO, TAG, "IF_COLLECTION PUT with request ::\n%s\n ", ehRequest->reqJSONPayload);
-                printf("PUT ::\n%s\n", ehRequest->reqJSONPayload);
-                return BuildCollectionGroupActionJSONResponse(OC_REST_PUT/*flag*/, (OCResource *)ehRequest->resource, ehRequest);
+                OC_LOG_V(INFO, TAG, "IF_COLLECTION PUT with request ::\n%s\n ",
+                        ehRequest->reqJSONPayload);
+                return BuildCollectionGroupActionJSONResponse(OC_REST_PUT/*flag*/,
+                        (OCResource *) ehRequest->resource, ehRequest);
             }
-#endif // WITH_GROUPACTION
             default:
                 return OC_STACK_ERROR;
         }
     }
-#ifdef WITH_GROUPACTION
-    else if(ehRequest->method == OC_REST_POST) {
+    else if (ehRequest->method == OC_REST_POST)
+    {
 
-        switch(ifQueryParam)
+        switch (ifQueryParam)
         {
             case STACK_IF_GROUP:
             {
-                OC_LOG_V(INFO, TAG, "IF_COLLECTION POST with request :: \n%s\n ", ehRequest->reqJSONPayload);
-                printf("POST ::\n%s\n", ehRequest->reqJSONPayload);
-                return BuildCollectionGroupActionJSONResponse(OC_REST_POST/*flag*/, (OCResource *)ehRequest->resource, ehRequest);
+                OC_LOG_V(INFO, TAG, "IF_COLLECTION POST with request :: \n%s\n ",
+                        ehRequest->reqJSONPayload);
+                return BuildCollectionGroupActionJSONResponse(OC_REST_POST/*flag*/,
+                        (OCResource *) ehRequest->resource, ehRequest);
             }
             default:
                 return OC_STACK_ERROR;
         }
     }
-#endif // WITH_GROUPACTION
     return result;
 }
 
index 35819d8..b9f70ac 100755 (executable)
 #define ACTION_DELIMITER "*"
 #define ATTR_DELIMITER "|"
 
+typedef struct aggregatehandleinfo
+{
+    OCServerRequest *ehRequest;
+    OCDoHandle required;
+    OCResource *collResource;
+
+    struct aggregatehandleinfo *next;
+} ClientRequstInfo;
+
+// unsigned int nHandleIdx = 0;
+// ClientRequstInfo g_AggregateResponseHandle[10];
+
+ClientRequstInfo *clientRequstList = NULL;
+
+void AddClientRequestInfo(ClientRequstInfo **head, ClientRequstInfo* add)
+{
+    ClientRequstInfo *tmp = NULL;
+
+    if (*head != NULL)
+    {
+        tmp = *head;
+
+        while (tmp->next)
+        {
+            tmp = tmp->next;
+        }
+        tmp->next = add;
+    }
+    else
+    {
+        *head = add;
+    }
+}
+
+ClientRequstInfo* GetClientRequestInfo(ClientRequstInfo *head, OCDoHandle handle)
+{
+    ClientRequstInfo *tmp = NULL;
+
+    tmp = head;
+
+    if (tmp)
+    {
+        while (tmp)
+        {
+//            printf("%p :: %p\n", tmp->required, handle);
+            if (tmp->required == handle)
+            {
+                break;
+            }
+
+            tmp = tmp->next;
+        }
+
+        return tmp;
+    }
+    return NULL;
+}
+
+void RemoveClientRequestInfo(ClientRequstInfo **head, ClientRequstInfo* del)
+{
+    ClientRequstInfo *tmp = NULL;
+
+    if (*head == del)
+    {
+        *head = (*head)->next;
+    }
+    else
+    {
+        tmp = *head;
+        while (tmp->next && (tmp->next != del))
+        {
+            tmp = tmp->next;
+        }
+        if (tmp->next)
+        {
+            tmp->next = del->next;
+        }
+    }
+}
+
+
+
 void AddCapability(OCCapability** head, OCCapability* node)
 {
     OCCapability *pointer = *head;
@@ -209,7 +291,6 @@ OCStackResult GetActionSet(const char *actionName, OCActionSet *head, OCActionSe
 
     while (pointer)
     {
-        //printf("%s :: %s\n", pointer->actionsetName, actionsetName);
         if (strcmp(pointer->actionsetName, actionName) == 0)
         {
             *actionset = pointer;
@@ -264,10 +345,10 @@ OCStackResult GetActionSetFromString(OCResource **resource, unsigned char *reque
                 iterToken = (char *) strtok_r(NULL, DESC_DELIMITER, &iterTokenPtr); // it is body of action description.
                 // printf("%s\n", iterToken);
 
-                printf("DESC :: %s\n", iterToken);
+                // printf("DESC :: %s\n", iterToken);
                 description = (char *) OCMalloc(strlen(iterToken) + 1);
                 strncpy(description, iterToken, strlen(iterToken) + 1);
-                printf("DESC Copied :: %s\n", description);
+                // printf("DESC Copied :: %s\n", description);
 
                 // Find the action name from description.
                 iterDescPtr = NULL;
@@ -277,17 +358,17 @@ OCStackResult GetActionSetFromString(OCResource **resource, unsigned char *reque
                 {
                     if (*actionsetName != NULL)
                     {
-                        printf("ERROR :: ACTIONSET NAME as ActionSet(%s)\n", iterToken);
+                        // printf("ERROR :: ACTIONSET NAME as ActionSet(%s)\n", iterToken);
                         return OC_STACK_ERROR; // ERROR OCCURED.
                     }
                     else
                     {
                         //  Actionset name.
-                        printf("ACTION SET NAME :: %s\n", iterToken);
+                        // printf("ACTION SET NAME :: %s\n", iterToken);
                         *actionsetName = (char *) OCMalloc(strlen(iterToken) + 1);
 
                         strncpy(*actionsetName, iterToken, strlen(iterToken) + 1);
-                        printf("ACTION SET NAME :: %s\n", *actionsetName);
+                        // printf("ACTION SET NAME :: %s\n", *actionsetName);
                         // break;
                     }
 
@@ -306,17 +387,17 @@ OCStackResult GetActionSetFromString(OCResource **resource, unsigned char *reque
                 memset(actionset, 0, sizeof(OCActionSet));
                 actionset->actionsetName = (char *) OCMalloc(strlen(*actionsetName) + 1);
                 strncpy(actionset->actionsetName, *actionsetName, strlen(*actionsetName) + 1);
-                printf("ACTION SET NAME :: %s\n", actionset->actionsetName);
+                // printf("ACTION SET NAME :: %s\n", actionset->actionsetName);
 
                 while (iterToken != NULL)
                 {
                     action = (OCAction *) OCMalloc(sizeof(OCAction));
                     memset(action, 0, sizeof(OCAction));
 
-                    printf("ATTR Copied :: %s\n", iterToken);
+                    // printf("ATTR Copied :: %s\n", iterToken);
                     attributes = (char *) OCMalloc(strlen(iterToken) + 1);
                     strncpy(attributes, iterToken, strlen(iterToken) + 1);
-                    printf("ATTR Copied :: %s\n", attributes);
+                    // printf("ATTR Copied :: %s\n", attributes);
 
                     iterToken = (char *) strtok_r(attributes, ATTR_DELIMITER, &iterAttrbutesPtr);
                     while (iterToken != NULL)
@@ -331,7 +412,7 @@ OCStackResult GetActionSetFromString(OCResource **resource, unsigned char *reque
                             if (strcmp(iterToken, "uri") == 0)
                             {
                                 iterToken = (char *) strtok_r(NULL, "=", &iterAttrPtr);
-                                printf("uri :: %s\n", iterToken);
+                                //printf("uri :: %s\n", iterToken);
                                 action->resourceUri = (char *) OCMalloc(strlen(iterToken) + 1);
                                 strncpy(action->resourceUri, iterToken, strlen(iterToken) + 1);
                             }
@@ -339,11 +420,11 @@ OCStackResult GetActionSetFromString(OCResource **resource, unsigned char *reque
                             {
                                 OCCapability* capa = (OCCapability*) OCMalloc(sizeof(OCCapability));
                                 memset(capa, 0, sizeof(OCCapability));
-                                printf("%s :: ", iterToken);
+                                //printf("%s :: ", iterToken);
                                 capa->capability = (char *) OCMalloc(strlen(iterToken) + 1);
                                 strncpy(capa->capability, iterToken, strlen(iterToken) + 1);
                                 iterToken = (char *) strtok_r(NULL, "=", &iterAttrPtr);
-                                printf("%s\n", iterToken);
+                                //printf("%s\n", iterToken);
                                 capa->status = (char *) OCMalloc(strlen(iterToken) + 1);
                                 strncpy(capa->status, iterToken, strlen(iterToken) + 1);
 
@@ -386,17 +467,17 @@ OCStackResult GetActionSetFromString(OCResource **resource, unsigned char *reque
                 {
                     if (*actionsetName != NULL)
                     {
-                        printf("ERROR :: ACTIONSET NAME as ActionSet(%s)\n", iterToken);
+                        // printf("ERROR :: ACTIONSET NAME as ActionSet(%s)\n", iterToken);
                         return OC_STACK_ERROR; // ERROR OCCURED.
                     }
                     else
                     {
                         //  Actionset name.
-                        printf("ACTION SET NAME :: %s\n", iterToken);
+                        // printf("ACTION SET NAME :: %s\n", iterToken);
                         *actionsetName = (char *) OCMalloc(strlen(iterToken) + 1);
 
                         strncpy(*actionsetName, iterToken, strlen(iterToken) + 1);
-                        printf("ACTION SET NAME :: %s\n", *actionsetName);
+                        // printf("ACTION SET NAME :: %s\n", *actionsetName);
                     }
 
                     iterToken = (char *) strtok_r(NULL, ACTION_DELIMITER, &iterDescPtr);
@@ -489,9 +570,41 @@ OCStackResult GetStringFromActionSet(OCActionSet* actionset, char** desc)
 OCStackApplicationResult ActionSetCB(void* context, OCDoHandle handle,
         OCClientResponse* clientResponse)
 {
+    printf("\n\n\tcallback is called\n\n");
+
+    ClientRequstInfo *info = GetClientRequestInfo(clientRequstList, handle);
+
+    if (info)
+    {
+        int idx;
+
+        unsigned char *responseJson;
+        responseJson = (unsigned char *) OCMalloc(
+                (unsigned int) (strlen((char *) clientResponse->resJSONPayload) + 1));
+
+        // We need the body of response.
+        // Copy the body from the response
+        strcpy((char *) responseJson, ((char *) clientResponse->resJSONPayload
+                + OC_JSON_PREFIX_LEN));
+        idx = strlen((char *) responseJson) - OC_JSON_SUFFIX_LEN;
+        // And insert NULL at the end of body.
+        (responseJson[idx]) = 0;
+
+        OCEntityHandlerResponse response = { 0 };
+        response.ehResult = OC_EH_OK;
+        response.payload = responseJson;
+        response.payloadSize = (unsigned int) strlen((char *) responseJson) + 1;
+        response.persistentBufferFlag = 0;
+        response.requestHandle = (OCRequestHandle) info->ehRequest;
+        response.resourceHandle = (OCResourceHandle) info->collResource;
+
+        OCDoResponse(&response);
+
+        RemoveClientRequestInfo(&clientRequstList, info);
+        OCFree(responseJson);
+    }
 
-    // printf("\n\n\tcallback is called\n\n");
-    // printf("\t\tresponse JSON : %s\n", clientResponse->resJSONPayload);
+    // g_AggregateResponseHandle
 
     return OC_STACK_KEEP_TRANSACTION;
 }
@@ -541,7 +654,22 @@ OCStackResult BuildActionJSON(OCAction* action, unsigned char* bufferPtr, uint16
     return ret;
 }
 
-OCStackResult SendAction(const char *targetUri, const unsigned char *action)
+unsigned int GetNumOfTargetResource(OCAction *actionset)
+{
+    int numOfREsource = 0;
+
+    OCAction *pointerAction = actionset;
+
+    while (pointerAction != NULL)
+    {
+        numOfREsource++;
+        pointerAction = pointerAction->next;
+    }
+
+    return numOfREsource;
+}
+
+OCStackResult SendAction(OCDoHandle *handle, const char *targetUri, const unsigned char *action)
 {
     OCCallbackData cbdata =
     { 0 };
@@ -549,8 +677,7 @@ OCStackResult SendAction(const char *targetUri, const unsigned char *action)
     cbdata.cd = &ActionSetCD;
     cbdata.context = (void *) 0x99;
 
-    OCDoHandle handle;
-    return OCDoResource(&handle, OC_REST_PUT, targetUri,
+    return OCDoResource(handle, OC_REST_PUT, targetUri,
     //temp->rsrcType->resourcetypename,
             NULL, (char *) action, OC_NA_QOS, &cbdata, NULL, 0);
 }
@@ -559,7 +686,6 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
         OCResource *resource, OCEntityHandlerRequest *ehRequest)
 {
     OCStackResult stackRet = OC_STACK_ERROR;
-    // OCEntityHandlerResult ehRet = OC_EH_ERROR;
 
     OC_LOG(INFO, TAG, PCF("Group Action is requested."));
     // if (stackRet == OC_STACK_OK)
@@ -568,7 +694,6 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
         char *doWhat = NULL;
         char *actionName = NULL;
 
-        // uint16_t remaining = MAX_RESPONSE_LENGTH;
         size_t bufferLength = 0;
         unsigned char buffer[MAX_RESPONSE_LENGTH] =
         { 0 };
@@ -577,45 +702,58 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
         bufferPtr = buffer;
 
         OCResource * collResource = (OCResource *) ehRequest->resource;
-        // OCResourceHandle origResourceHandle = ehRequest->resource;
 
         char *jsonResponse;
 
-        cJSON *json = cJSON_CreateObject();
+        cJSON *json;
         cJSON *format;
 
-        cJSON_AddStringToObject(json, "href", resource->uri);
-        cJSON_AddItemToObject(json, "rep", format = cJSON_CreateObject());
-
-        if (method == OC_REST_GET)
-        {
-            OC_LOG(INFO, TAG, PCF("Group Action[GET]."));
-        }
-        else if (method == OC_REST_PUT)
+        if (method == OC_REST_PUT)
         {
+            json = cJSON_CreateObject();
+            cJSON_AddStringToObject(json, "href", resource->uri);
+            cJSON_AddItemToObject(json, "rep", format = cJSON_CreateObject());
+
             OC_LOG(INFO, TAG, PCF("Group Action[PUT]."));
 
             unsigned char *actionPtr = (unsigned char *) ehRequest->reqJSONPayload;
-
             GetActionSetFromString(&resource, actionPtr, &doWhat, &actionName);
 
             if (strcmp(doWhat, "DelActionSet") == 0)
             {
                 if (FindAndDeleteActionSet(&resource, actionName) == OC_STACK_OK)
                 {
+                    stackRet = OC_STACK_OK;
                 }
                 else
                 {
+                    stackRet = OC_STACK_ERROR;
                 }
             }
-            else
+
+            jsonResponse = cJSON_Print(json);
+            cJSON_Delete(json);
+
+            strcat((char *) bufferPtr, jsonResponse);
+
+            bufferLength = strlen((const char *) buffer);
+            if (bufferLength > 0)
             {
+                OCEntityHandlerResponse response =
+                { 0 };
+                response.ehResult = OC_EH_OK;
+                response.payload = buffer;
+                response.payloadSize = bufferLength + 1;
+                response.persistentBufferFlag = 0;
+                response.requestHandle = (OCRequestHandle) ehRequest->requestHandle;
+                response.resourceHandle = (OCResourceHandle) collResource;
+                stackRet = OCDoResponse(&response);
             }
 
             stackRet = OC_STACK_OK;
-
         }
-        else if (method == OC_REST_POST)
+
+        if (method == OC_REST_POST)
         {
             OC_LOG(INFO, TAG, PCF("Group Action[POST]."));
 
@@ -624,6 +762,9 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
 
             GetActionSetFromString(&resource, actionPtr, &doWhat, &actionName);
 
+            json = cJSON_CreateObject();
+            cJSON_AddStringToObject(json, "href", resource->uri);
+
             if (strcmp(doWhat, "DoAction") == 0)
             {
                 if (GetActionSet(actionName, resource->actionsetHead, &actionset) != OC_STACK_OK)
@@ -636,17 +777,22 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
                 {
                     OC_LOG(INFO, TAG, PCF("ERROR"));
                     stackRet = OC_STACK_ERROR;
-                } else {
-
-                    // printf("Execute ActionSet :: %s\n", actionset->actionsetName);
+                }
+                else
+                {
 
                     OCAction *pointerAction = actionset->head;
+
+                    unsigned int num = GetNumOfTargetResource(pointerAction);
+
+                    ((OCServerRequest *) ehRequest->requestHandle)->ehResponseHandler =
+                            HandleAggregateResponse;
+                    ((OCServerRequest *) ehRequest->requestHandle)->numResponses = num + 1;
+
+//                    printf("ActionSet Name :: %s\n", actionset->actionsetName);
                     while (pointerAction != NULL)
                     {
-                        // printf("Action Target :: %s\n", pointerAction->resourceUri);
-
-                        unsigned char actionDesc[MAX_RESPONSE_LENGTH] =
-                        { 0 };
+                        unsigned char actionDesc[MAX_RESPONSE_LENGTH] = { 0 };
                         unsigned char* actionDescPtr = actionDesc;
                         uint16_t remaining = MAX_RESPONSE_LENGTH;
 
@@ -654,10 +800,22 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
                         BuildActionJSON(pointerAction, actionDescPtr, &remaining);
                         strcat((char *) actionDescPtr, (const char *) OC_JSON_SUFFIX);
 
-                        SendAction(pointerAction->resourceUri, actionDescPtr);
+                        ClientRequstInfo *info = (ClientRequstInfo *) OCMalloc(
+                                sizeof(ClientRequstInfo));
+                        memset(info, 0, sizeof(ClientRequstInfo));
+
+                        info->collResource = resource;
+                        info->ehRequest = (OCServerRequest *) ehRequest->requestHandle;
+
+                        SendAction(&info->required, pointerAction->resourceUri, actionDescPtr);
+
+                        AddClientRequestInfo(&clientRequstList, info);
+
 
                         pointerAction = pointerAction->next;
                     }
+
+
                     stackRet = OC_STACK_OK;
                 }
             }
@@ -666,57 +824,41 @@ OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHa
                 char *plainText = NULL;
                 OCActionSet *actionset = NULL;
 
-                // char *jsonResponse;
-
+                cJSON_AddItemToObject(json, "rep", format = cJSON_CreateObject());
                 GetActionSet(actionName, resource->actionsetHead, &actionset);
-                if(actionset != NULL)
+                if (actionset != NULL)
                 {
                     GetStringFromActionSet(actionset, &plainText);
 
                     if (plainText != NULL)
                     {
                         cJSON_AddStringToObject(format, "ActionSet", plainText);
-
-                        // jsonResponse = cJSON_Print(json);
-                        // cJSON_Delete(json);
-
-                        // strcat((char *)bufferPtr, jsonResponse);
                     }
 
                     stackRet = OC_STACK_OK;
                 }
             }
-            else if (actionName == NULL)
-            {
-                // printf("Cannot find actionname\n");
-                return OC_STACK_ERROR;
-            }
-        }
 
-        jsonResponse = cJSON_Print(json);
-        cJSON_Delete(json);
+            jsonResponse = cJSON_Print(json);
+            cJSON_Delete(json);
 
-        strcat((char *) bufferPtr, jsonResponse);
+            strcat((char *) bufferPtr, jsonResponse);
 
-        // printf("\n\tRESONSE ::\n%s\n", buffer);
-        bufferLength = strlen((const char *) buffer);
-        if (bufferLength > 0)
-        {
-            OCEntityHandlerResponse response =
-            { 0 };
-            response.ehResult = OC_EH_OK;
-            response.payload = buffer;
-            response.payloadSize = bufferLength + 1;
-            response.persistentBufferFlag = 0;
-            response.requestHandle = (OCRequestHandle) ehRequest->requestHandle;
-            response.resourceHandle = (OCResourceHandle) collResource;
-            stackRet = OCDoResponse(&response);
+            bufferLength = strlen((const char *) buffer);
+            if (bufferLength > 0)
+            {
+                OCEntityHandlerResponse response =
+                { 0 };
+                response.ehResult = OC_EH_OK;
+                response.payload = buffer;
+                response.payloadSize = bufferLength + 1;
+                response.persistentBufferFlag = 0;
+                response.requestHandle = (OCRequestHandle) ehRequest->requestHandle;
+                response.resourceHandle = (OCResourceHandle) collResource;
+                stackRet = OCDoResponse(&response);
+            }
         }
-
-        // ehRequest->resource = origResourceHandle;
     }
 
     return stackRet;
-
-    //return OC_STACK_OK;
 }
diff --git a/resource/examples/groupclient.cpp b/resource/examples/groupclient.cpp
new file mode 100755 (executable)
index 0000000..11afb80
--- /dev/null
@@ -0,0 +1,234 @@
+//******************************************************************
+//
+// Copyright 2014 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "OCPlatform.h"
+#include "OCApi.h"
+
+#include <functional>
+#include <pthread.h>
+#include <iostream>
+
+using namespace std;
+using namespace OC;
+namespace PH = std::placeholders;
+
+OCResourceHandle resourceHandle;
+
+shared_ptr< OCResource > g_resource;
+vector< string > lights;
+
+bool isReady = false;
+
+void onGet(const HeaderOptions& opt, const OCRepresentation &rep, const int eCode);
+
+void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);
+
+void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);
+
+void foundResource(std::shared_ptr< OCResource > resource)
+{
+    std::string resourceURI;
+    std::string hostAddress;
+
+    try
+    {
+        cout << "FOUND Resource" << endl;
+
+        if (resource)
+        {
+            string resourceURI = resource->uri();
+            cout << resourceURI << endl;
+            if (resourceURI == "/core/a/collection")
+            {
+                g_resource = resource;
+            }
+
+            g_resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), onGet);
+            printf("HOST :: %s\n", resource->host().c_str());
+        }
+    }
+    catch (std::exception& e)
+    {
+        std::cout << "" << std::endl;
+    }
+}
+
+void onGet(const HeaderOptions& opt, const OCRepresentation &rep, const int eCode)
+{
+    // printf("onGet\n");
+
+    std::vector< OCRepresentation > children = rep.getChildren();
+
+    cout << "\n\n\nCHILD RESOURCE OF GROUP" << endl;
+    for (auto iter = children.begin(); iter != children.end(); ++iter)
+    {
+        lights.push_back((*iter).getUri());
+        cout << "\tURI :: " << (*iter).getUri() << endl;
+    }
+
+    isReady = true;
+}
+
+void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+{
+    printf("\nonPut\n");
+}
+
+void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+{
+    printf("\nonPost\n");
+
+    std::vector< OCRepresentation > children = rep.getChildren();
+
+    cout << "\n\n\nCHILD RESOURCE OF GROUP" << endl;
+    for (auto iter = children.begin(); iter != children.end(); ++iter)
+    {
+        std::string power;
+        (*iter).getValue("power", power);
+
+        cout << "\tURI :: " << (*iter).getUri() << endl;
+        cout << "\t\tpower :: " << power << endl;
+    }
+
+    if (rep.hasAttribute("ActionSet"))
+    {
+        std::string plainText;
+
+        rep.getValue("ActionSet", plainText);
+
+        printf("\tPlain Text :: %s\n", plainText.c_str());
+    }
+    else
+    {
+        printf("Not found ActionSet\n");
+    }
+}
+
+int main()
+{
+    PlatformConfig config
+    { OC::ServiceType::InProc, ModeType::Client, "0.0.0.0", 0, OC::QualityOfService::LowQos };
+
+    bool isRun = true;
+
+    try
+    {
+        OCPlatform::Configure(config);
+
+        string resourceTypeName = "a.collection";
+        OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=a.collection", &foundResource);
+
+        isReady = false;
+
+        while (isRun)
+        {
+            usleep(100);
+            while (isReady)
+            {
+                int n;
+
+                cout << endl
+                        << "1 :: CREATE ACTIONSET 2 :: EXECUTE ACTION SET 3 :: GET ACTIONSET\n";
+                cout << "4 :: DELETE ACTIONSET 5 :: Quit\n";
+
+                cin >> n;
+                if (n == 1)
+                {
+                    string actionsetDesc;
+                    //"movieTime*uri=coap://10.251.44.228:49858/a/light|power=10*uri=coap://10.251.44.228:49858/a/light|power=10|";
+
+                    actionsetDesc = "allbulboff";
+                    actionsetDesc.append("*");
+                    for (auto iter = lights.begin(); iter != lights.end(); ++iter)
+                    {
+                        actionsetDesc.append("uri=").append((*iter));
+                        actionsetDesc.append("|");
+                        actionsetDesc.append("power=");
+                        actionsetDesc.append("off");
+                        if ((iter + 1) != lights.end())
+                        {
+                            actionsetDesc.append("*");
+                        }
+                    }
+
+                    cout << "ActionSet :: " << actionsetDesc << endl;
+
+                    OCRepresentation rep;
+                    rep.setValue("ActionSet", actionsetDesc);
+
+                    if (g_resource)
+                    {
+                        g_resource->put("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
+                                &onPut);
+                    }
+                }
+                else if (n == 2)
+                {
+                    OCRepresentation rep;
+
+                    rep.setValue("DoAction", std::string("allbulboff"));
+
+                    if (g_resource)
+                    {
+                        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
+                                &onPost);
+                    }
+                }
+                else if (n == 3)
+                {
+                    OCRepresentation rep;
+
+                    rep.setValue("GetActionSet", std::string("allbulboff"));
+
+                    if (g_resource)
+                    {
+                        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
+                                &onPost);
+                    }
+                }
+                else if (n == 4)
+                {
+                    OCRepresentation rep;
+
+                    rep.setValue("DelActionSet", std::string("allbulboff"));
+
+                    if (g_resource)
+                    {
+                        g_resource->put("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
+                                &onPut);
+                    }
+                }
+                else if (n == 5)
+                {
+                    isRun = false;
+                    break;
+                }
+
+                fflush(stdin);
+            }
+        }
+    }
+    catch (OCException& e)
+    {
+        cout << e.what() << endl;
+    }
+
+    return 0;
+}
diff --git a/resource/examples/groupserver.cpp b/resource/examples/groupserver.cpp
new file mode 100755 (executable)
index 0000000..4cebd44
--- /dev/null
@@ -0,0 +1,129 @@
+//******************************************************************
+//
+// Copyright 2014 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "OCPlatform.h"
+#include "OCApi.h"
+
+#include <functional>
+#include <pthread.h>
+#include <iostream>
+
+using namespace std;
+using namespace OC;
+
+namespace PH = std::placeholders;
+
+OCResourceHandle resourceHandle;
+std::vector< OCResourceHandle > resourceHandleVector;
+
+void foundResource(std::shared_ptr< OCResource > resource)
+{
+
+    std::string resourceURI;
+    std::string hostAddress;
+
+    try
+    {
+        cout << "FOUND RESOURCE" << endl;
+
+        if (resource)
+        {
+            resourceURI = resource->uri();
+            hostAddress = resource->host();
+
+            cout << "\tResource URI : " << resourceURI << endl;
+            cout << "\tResource Host : " << hostAddress << endl;
+            cout << "\tResource Interfaces : " << resource->getResourceInterfaces().front() << endl;
+            cout << "\tResource Type : " << resource->getResourceTypes().front() << endl;
+            if (resourceURI == "/a/light" || resourceURI == "/a/fan")
+            {
+                OCResourceHandle foundResourceHandle;
+                OCStackResult result = OCPlatform::registerResource(foundResourceHandle, resource);
+                cout << "\tresource registed!" << endl;
+                if (result == OC_STACK_OK)
+                {
+                    OCPlatform::bindResource(resourceHandle, foundResourceHandle);
+                    resourceHandleVector.push_back(foundResourceHandle);
+                }
+                else
+                {
+                    cout << "\tresource Error!" << endl;
+                }
+            }
+
+            // p_platform.bindResource(resourceHandle, foundResourceHandle);
+
+        }
+    }
+    catch (std::exception& e)
+    {
+        std::cout << "" << std::endl;
+    }
+
+}
+
+int main()
+{
+    PlatformConfig config
+    { OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
+
+    try
+    {
+        string resourceURI = "/core/a/collection";
+        string resourceTypeName = "a.collection";
+        string resourceInterface = BATCH_INTERFACE;
+        OCPlatform::Configure(config);
+
+        // EntityHandler cb = std::bind(, PH::_1, PH::_2);
+
+        OCPlatform::registerResource(resourceHandle, resourceURI, resourceTypeName,
+                resourceInterface,
+                NULL,
+                //&entityHandler, // entityHandler
+                OC_DISCOVERABLE);
+
+        cout << "registerResource is called." << endl;
+
+        OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light", &foundResource);
+        OCPlatform::bindInterfaceToResource(resourceHandle, GROUP_INTERFACE);
+        OCPlatform::bindInterfaceToResource(resourceHandle, DEFAULT_INTERFACE);
+
+        int selectedMenu;
+        while (true)
+        {
+            std::cin >> selectedMenu;
+
+            if (selectedMenu == 1)
+            {
+                for (unsigned int i = 0; i < resourceHandleVector.size(); ++i)
+                {
+                    OCPlatform::unregisterResource(resourceHandleVector.at(i));
+                }
+            }
+
+        }
+    }
+    catch (OCException& e)
+    {
+
+    }
+
+    return 0;
+}
diff --git a/resource/examples/lightserver.cpp b/resource/examples/lightserver.cpp
new file mode 100755 (executable)
index 0000000..f95722d
--- /dev/null
@@ -0,0 +1,334 @@
+//******************************************************************
+//
+// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+// Copyright 2014 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+///
+/// This sample provides steps to define an interface for a resource
+/// (properties and methods) and host this resource on the server.
+///
+
+#include <functional>
+
+#include <pthread.h>
+#include <mutex>
+#include <condition_variable>
+
+#include "OCPlatform.h"
+#include "OCApi.h"
+
+using namespace OC;
+using namespace std;
+namespace PH = std::placeholders;
+
+int gObservation = 0;
+void * ChangeLightRepresentation (void *param);
+void * handleSlowResponse (void *param, std::shared_ptr<OCResourceRequest> pRequest);
+
+// Specifies secure or non-secure
+// false: non-secure resource
+// true: secure resource
+bool isSecure = false;
+
+/// Specifies whether Entity handler is going to do slow response or not
+bool isSlowResponse = false;
+
+// Forward declaring the entityHandler
+
+/// This class represents a single resource named 'lightResource'. This resource has
+/// two simple properties named 'state' and 'power'
+
+class LightResource
+{
+
+public:
+    /// Access this property from a TB client
+    std::string m_power;
+    std::string m_lightUri;
+    OCResourceHandle m_resourceHandle;
+    OCRepresentation m_lightRep;
+
+public:
+    /// Constructor
+    LightResource()
+        :m_power(""), m_lightUri("/a/light") {
+        // Initialize representation
+        m_lightRep.setUri(m_lightUri);
+
+        m_lightRep.setValue("power", m_power);
+    }
+
+    /* Note that this does not need to be a member function: for classes you do not have
+    access to, you can accomplish this with a free function: */
+
+    /// This function internally calls registerResource API.
+    void createResource()
+    {
+        std::string resourceURI = m_lightUri; //URI of the resource
+        std::string resourceTypeName = "core.light"; //resource type name. In this case, it is light
+        std::string resourceInterface = DEFAULT_INTERFACE; // resource interface.
+
+        EntityHandler cb = std::bind(&LightResource::entityHandler, this,PH::_1);
+
+        // This will internally create and register the resource.
+        OCStackResult result = OCPlatform::registerResource(
+                                    m_resourceHandle, resourceURI, resourceTypeName,
+                                    resourceInterface, cb, OC_DISCOVERABLE | OC_OBSERVABLE);
+
+        if (OC_STACK_OK != result)
+        {
+            cout << "Resource creation was unsuccessful\n";
+        }
+    }
+
+    OCResourceHandle getHandle()
+    {
+        return m_resourceHandle;
+    }
+
+    // Puts representation.
+    // Gets values from the representation and
+    // updates the internal state
+    void put(OCRepresentation& rep)
+    {
+        try {
+            if (rep.getValue("power", m_power))
+            {
+                cout << "\t\t\t\t" << "power: " << m_power << endl;
+            }
+            else
+            {
+                cout << "\t\t\t\t" << "power not found in the representation" << endl;
+            }
+        }
+        catch (exception& e)
+        {
+            cout << e.what() << endl;
+        }
+
+    }
+
+    // Post representation.
+    // Post can create new resource or simply act like put.
+    // Gets values from the representation and
+    // updates the internal state
+    OCRepresentation post(OCRepresentation& rep)
+    {
+        put(rep);
+        return get();
+    }
+
+
+    // gets the updated representation.
+    // Updates the representation with latest internal state before
+    // sending out.
+    OCRepresentation get()
+    {
+        m_lightRep.setValue("power", m_power);
+
+        return m_lightRep;
+    }
+
+    void addType(const std::string& type) const
+    {
+        OCStackResult result = OCPlatform::bindTypeToResource(m_resourceHandle, type);
+        if (OC_STACK_OK != result)
+        {
+            cout << "Binding TypeName to Resource was unsuccessful\n";
+        }
+    }
+
+    void addInterface(const std::string& interface) const
+    {
+        OCStackResult result = OCPlatform::bindInterfaceToResource(m_resourceHandle, interface);
+        if (OC_STACK_OK != result)
+        {
+            cout << "Binding TypeName to Resource was unsuccessful\n";
+        }
+    }
+
+private:
+// This is just a sample implementation of entity handler.
+// Entity handler can be implemented in several ways by the manufacturer
+OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
+{
+    cout << "\tIn Server CPP entity handler:\n";
+    OCEntityHandlerResult ehResult = OC_EH_ERROR;
+    if(request)
+    {
+        // Get the request type and request flag
+        std::string requestType = request->getRequestType();
+        int requestFlag = request->getRequestHandlerFlag();
+
+        if(requestFlag & RequestHandlerFlag::InitFlag)
+        {
+            cout << "\t\trequestFlag : Init\n";
+
+            // entity handler to perform resource initialization operations
+        }
+        if(requestFlag & RequestHandlerFlag::RequestFlag)
+        {
+            cout << "\t\trequestFlag : Request\n";
+            auto pResponse = std::make_shared<OC::OCResourceResponse>();
+            pResponse->setRequestHandle(request->getRequestHandle());
+            pResponse->setResourceHandle(request->getResourceHandle());
+
+            // If the request type is GET
+            if(requestType == "GET")
+            {
+                cout << "\t\t\trequestType : GET\n";
+                if(isSlowResponse) // Slow response case
+                {
+                    static int startedThread = 0;
+                    if(!startedThread)
+                    {
+                        std::thread t(handleSlowResponse, (void *)this, request);
+                        startedThread = 1;
+                        t.detach();
+                    }
+                    ehResult = OC_EH_SLOW;
+                }
+                else // normal response case.
+                {
+                    pResponse->setErrorCode(200);
+                    pResponse->setResponseResult(OC_EH_OK);
+                    pResponse->setResourceRepresentation(get());
+                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                    {
+                        ehResult = OC_EH_OK;
+                    }
+                }
+            }
+            else if(requestType == "PUT")
+            {
+                cout << "\t\t\trequestType : PUT\n";
+                OCRepresentation rep = request->getResourceRepresentation();
+
+                // Do related operations related to PUT request
+                // Update the lightResource
+                put(rep);
+                pResponse->setErrorCode(200);
+                pResponse->setResponseResult(OC_EH_OK);
+                pResponse->setResourceRepresentation(get());
+                if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                {
+                    ehResult = OC_EH_OK;
+                }
+            }
+            else if(requestType == "POST")
+            {
+                cout << "\t\t\trequestType : POST\n";
+
+                OCRepresentation rep = request->getResourceRepresentation();
+
+                // Do related operations related to POST request
+                OCRepresentation rep_post = post(rep);
+                pResponse->setResourceRepresentation(rep_post);
+                pResponse->setErrorCode(200);
+                if(rep_post.hasAttribute("createduri"))
+                {
+                    pResponse->setResponseResult(OC_EH_RESOURCE_CREATED);
+                    pResponse->setNewResourceUri(rep_post.getValue<std::string>("createduri"));
+                }
+
+                if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                {
+                    ehResult = OC_EH_OK;
+                }
+            }
+            else if(requestType == "DELETE")
+            {
+                // DELETE request operations
+            }
+        }
+    }
+    else
+    {
+        std::cout << "Request invalid" << std::endl;
+    }
+
+    return ehResult;
+}
+};
+
+void * handleSlowResponse (void *param, std::shared_ptr<OCResourceRequest> pRequest)
+{
+    // This function handles slow response case
+    LightResource* lightPtr = (LightResource*) param;
+    // Induce a case for slow response by using sleep
+    std::cout << "SLOW response" << std::endl;
+    sleep (10);
+
+    auto pResponse = std::make_shared<OC::OCResourceResponse>();
+    pResponse->setRequestHandle(pRequest->getRequestHandle());
+    pResponse->setResourceHandle(pRequest->getResourceHandle());
+    pResponse->setResourceRepresentation(lightPtr->get());
+    pResponse->setErrorCode(200);
+    pResponse->setResponseResult(OC_EH_OK);
+
+    // Set the slow response flag back to false
+    isSlowResponse = false;
+    OCPlatform::sendResponse(pResponse);
+    return NULL;
+}
+
+
+int main(int argc, char* argv[])
+{
+    // Create PlatformConfig object
+    PlatformConfig cfg {
+        OC::ServiceType::InProc,
+        OC::ModeType::Server,
+        "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces
+        0,         // Uses randomly available port
+        OC::QualityOfService::LowQos
+    };
+
+    OCPlatform::Configure(cfg);
+    try
+    {
+        // Create the instance of the resource class
+        // (in this case instance of class 'LightResource').
+        LightResource myLight;
+
+        // Invoke createResource function of class light.
+        myLight.createResource();
+
+        myLight.addType(std::string("core.brightlight"));
+        myLight.addInterface(std::string("oc.mi.ll"));
+
+        // A condition variable will free the mutex it is given, then do a non-
+        // intensive block until 'notify' is called on it.  In this case, since we
+        // don't ever call cv.notify, this should be a non-processor intensive version
+        // of while(true);
+        std::mutex blocker;
+        std::condition_variable cv;
+        std::unique_lock<std::mutex> lock(blocker);
+        cv.wait(lock);
+    }
+    catch(OCException e)
+    {
+        //log(e.what());
+    }
+
+    // No explicit call to stop the platform.
+    // When OCPlatform::destructor is invoked, internally we do platform cleanup
+
+    return 0;
+}
old mode 100644 (file)
new mode 100755 (executable)
index 6347a6d..ec87ec7
@@ -19,7 +19,7 @@
 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 #
 # override with `make BUILD=release`
-# default to release build
+# default to release build+
 BUILD    := release
 PLATFORM  := linux
 CXX          := g++
@@ -43,11 +43,11 @@ LIB_OC_LOGGER := ../oc_logger/lib/oc_logger.a
 CXX_LIBS  := ../$(BUILD)/obj/liboc.a ../csdk/$(PLATFORM)/$(BUILD)/liboctbstack.a $(LIB_OC_LOGGER)
 
 # Force metatargets to build:
-all.PHONY: prep_dirs oc_cpp_sdk simpleserver simpleserverHQ simpleclient simpleclientHQ simpleclientserver roomserver roomclient presenceserver presenceclient garageserver garageclient fridgeserver fridgeclient ocicuc_target threadingsample devicediscoveryserver devicediscoveryclient
+all.PHONY: prep_dirs oc_cpp_sdk simpleserver simpleserverHQ simpleclient simpleclientHQ simpleclientserver roomserver roomclient presenceserver presenceclient garageserver garageclient fridgeserver fridgeclient ocicuc_target threadingsample devicediscoveryserver devicediscoveryclient groupserver groupclient lightserver
 
-apps.PHONY: prep_dirs oc_cpp_sdk simpleserver simpleserverHQ simpleclient simpleclientHQ simpleclientserver roomserver roomclient presenceserver presenceclient garageserver garageclient fridgeserver fridgeclient threadingsample devicediscoveryserver devicediscoveryclient
+apps.PHONY: prep_dirs oc_cpp_sdk simpleserver simpleserverHQ simpleclient simpleclientHQ simpleclientserver roomserver roomclient presenceserver presenceclient garageserver garageclient fridgeserver fridgeclient threadingsample devicediscoveryserver devicediscoveryclient groupserver groupclient lightserver
 
-buildScript_all.PHONY: prep_dirs simpleserver simpleserverHQ simpleclient simpleclientHQ simpleclientserver roomserver roomclient presenceserver presenceclient garageserver garageclient fridgeserver fridgeclient threadingsample devicediscoveryserver devicediscoveryclient
+buildScript_all.PHONY: prep_dirs simpleserver simpleserverHQ simpleclient simpleclientHQ simpleclientserver roomserver roomclient presenceserver presenceclient garageserver garageclient fridgeserver fridgeclient threadingsample devicediscoveryserver devicediscoveryclient groupserver groupclient lightserver
 
 all: all.PHONY
 
@@ -103,11 +103,22 @@ garageclient: garageclient.cpp
 threadingsample: threadingsample.cpp
        $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ threadingsample.cpp $(CXX_INC) $(CXX_LIBS)
 
+groupserver: groupserver.cpp
+       $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ groupserver.cpp $(CXX_INC) $(CXX_LIBS)
+
+groupclient: groupclient.cpp
+       $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ groupclient.cpp $(CXX_INC) $(CXX_LIBS)
+
+lightserver: lightserver.cpp
+       $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ lightserver.cpp $(CXX_INC) $(CXX_LIBS)
+
 devicediscoveryserver: devicediscoveryserver.cpp
        $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ devicediscoveryserver.cpp $(CXX_INC) $(CXX_LIBS)
 
 devicediscoveryclient: devicediscoveryclient.cpp
        $(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ devicediscoveryclient.cpp $(CXX_INC) $(CXX_LIBS)
+       
+       
 
 ocicuc_target:
        cd ocicuc && $(MAKE) apps