Update Sample application for group action.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Thu, 16 Apr 2015 05:18:53 +0000 (14:18 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 17 Apr 2015 08:05:13 +0000 (08:05 +0000)
Update c sample application for group action.
It is show what we can use group action without SDK.

Change-Id: I06c149b9f12da6187b5d385e880008343a99052d
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/751
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
resource/examples/groupclient.cpp

index 821d663..be06d61 100644 (file)
 #include <iostream>
 #include <mutex>
 
+#define DO_ACTION               "DoAction"
+#define GET_ACTIONSET           "GetActionSet"
+#define ACTIONSET               "ActionSet"
+#define DELETE_ACTIONSET        "DelActionSet"
+
 using namespace std;
 using namespace OC;
 namespace PH = std::placeholders;
@@ -135,11 +140,15 @@ void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, con
     }
 }
 
-string buildActionSetDesc()
+string buildActionSetDesc(unsigned int delay = 0, unsigned int type = 0)
 {
     string actionsetDesc = "";
     actionsetDesc = "allbulboff";
     actionsetDesc.append("*");
+    actionsetDesc.append(std::to_string(delay));        // Set delay time.
+    actionsetDesc.append(" ");
+    actionsetDesc.append(std::to_string(type));         // Set action type.
+    actionsetDesc.append("*");
     for (auto iter = lights.begin(); iter != lights.end(); ++iter)
     {
         actionsetDesc.append("uri=").append((*iter));
@@ -259,7 +268,7 @@ int main(int argc, char* argv[])
                     }
                     break;
                 case 2:
-                    rep.setValue("DoAction", std::string("allbulboff"));
+                    rep.setValue(DO_ACTION, std::string("allbulboff"));
                     if (g_resource)
                     {
                         g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
@@ -267,7 +276,7 @@ int main(int argc, char* argv[])
                      }
                      break;
                 case 3:
-                    rep.setValue("GetActionSet", std::string("allbulboff"));
+                    rep.setValue(GET_ACTIONSET, std::string("allbulboff"));
                     if (g_resource)
                     {
                         g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),