Merge Things Manager codes CA and Master branch.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Thu, 2 Apr 2015 08:53:41 +0000 (17:53 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 9 Apr 2015 04:06:03 +0000 (04:06 +0000)
It was modified base on CA for preparing for official merge.

Change-Id: If3cb90d9a1a03a8d79d95952f5dfabb07c526634
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/632
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
30 files changed:
extlibs/timer/timer.c [new file with mode: 0755]
extlibs/timer/timer.h [new file with mode: 0755]
service/things-manager/SConscript [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.h [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.h [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/FactorySetCollection.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/FactorySetCollection.h [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/SConscript [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/bootstrapserver.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/con-client.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/con-server.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupaction/SConscript
service/things-manager/sampleapp/linux/groupaction/groupserver.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupsyncaction/SConscript
service/things-manager/sampleapp/linux/groupsyncaction/group.cpp
service/things-manager/sampleapp/linux/groupsyncaction/phone.cpp
service/things-manager/sdk/inc/ActionSet.h [changed mode: 0644->0755]
service/things-manager/sdk/inc/ThingsManager.h [changed mode: 0644->0755]
service/things-manager/sdk/src/ActionSet.cpp [new file with mode: 0755]
service/things-manager/sdk/src/GroupManager.cpp [changed mode: 0644->0755]
service/things-manager/sdk/src/GroupManager.h
service/things-manager/sdk/src/GroupSynchronization.cpp
service/things-manager/sdk/src/GroupSynchronization.h
service/things-manager/sdk/src/ThingsConfiguration.cpp [changed mode: 0644->0755]
service/things-manager/sdk/src/ThingsConfiguration.h [changed mode: 0644->0755]
service/things-manager/sdk/src/ThingsDiagnostics.cpp [changed mode: 0644->0755]
service/things-manager/sdk/src/ThingsDiagnostics.h [changed mode: 0644->0755]
service/things-manager/sdk/src/ThingsManager.cpp

diff --git a/extlibs/timer/timer.c b/extlibs/timer/timer.c
new file mode 100755 (executable)
index 0000000..0dccd4e
--- /dev/null
@@ -0,0 +1,354 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+
+
+#define _BSD_SOURCE
+
+#ifndef WITH_ARDUINO
+#include <pthread.h>
+#include <unistd.h>
+#include <memory.h>
+#include <stdlib.h>
+#endif
+
+#include <string.h>
+#include <stdio.h>
+
+#include "timer.h"
+
+#define SECOND (1)
+
+#define TIMEOUTS 10
+
+#define TIMEOUT_USED   1
+#define TIMEOUT_UNUSED  2
+
+#ifndef WITH_ARDUINO
+pthread_t thread_id = 0; // 0: initial thread id (meaningless)
+#endif
+
+struct timelist_t
+{
+    int timeout_state;
+    time_t timeout_seconds;
+    time_t timeout_time;
+    void (*cb)();
+} timeout_list[TIMEOUTS];
+
+/*
+ * Return the number of seconds between before and after, (after - before).
+ * This must be async-signal safe, so it cannot use difftime().
+ */
+time_t timespec_diff(const time_t after, const time_t before)
+{
+    return after - before;
+}
+
+/*
+ * Add positive seconds to a timespec, nothing if seconds is negative.
+ */
+void timespec_add(time_t * to, const time_t seconds)
+{
+    if (to && seconds > 0)
+    {
+        (*to) += seconds;
+    }
+}
+
+#ifndef WITH_ARDUINO
+
+long int getSeconds(struct tm* tp)
+{
+    long int nInterval = 0;
+
+    nInterval = (tp->tm_hour * SECS_PER_HOUR);
+    nInterval += (tp->tm_min * SECS_PER_MIN);
+    nInterval += (tp->tm_sec * SECOND);
+
+    printf("%ld", nInterval);
+
+    return nInterval;
+}
+
+long int getRelativeSecondsOfDayofweek(int ia, int ib)
+{
+    if( ia > ib )
+        return (((long int)(7 - (ib - ia))) * SECS_PER_DAY);
+
+    return (((long int)((ib - ia))) * SECS_PER_DAY);
+}
+
+long int getRelativeIntervalOfWeek(struct tm* tp)
+{
+    time_t current_time;
+    struct tm* current, *midnight;
+    time_t delayed_time = 0;
+
+    time(&current_time);
+    current = localtime(&current_time);
+    midnight = (struct tm* )malloc(sizeof(struct tm));
+    memcpy(midnight, current, sizeof(struct tm));
+
+    midnight->tm_hour = 0;
+    midnight->tm_min = 0;
+    midnight->tm_sec = 0;
+
+    // Seconds.
+    // Seconds from midnight.
+    delayed_time = current_time - mktime(midnight);
+    delayed_time = getRelativeSecondsOfDayofweek(current->tm_wday, tp->tm_wday) - delayed_time;
+    delayed_time = delayed_time + getSeconds(tp);
+
+    return delayed_time;
+}
+
+long int getSecondsFromAbsTime(struct tm* tp)
+{
+   time_t current_time;
+   time_t delayed_time = 0;
+
+   time(&current_time);
+   localtime(&current_time);
+
+   delayed_time = mktime(tp) - current_time;
+
+   return delayed_time;
+}
+
+time_t registerTimer(const time_t seconds, int *id, void *cb)
+{
+    time_t now, then;
+    time_t next;
+    int i, idx;
+
+    if (0 == thread_id)
+    {
+        initThread();
+    }
+
+    if (seconds <= 0)
+        return -1 ;
+
+    // get the current time
+    time(&now);
+
+    for (idx = 0; idx < TIMEOUTS; ++idx)
+        if (!((timeout_list[idx].timeout_state & TIMEOUT_USED) & TIMEOUT_USED))
+            break;
+
+    if (TIMEOUTS == idx) // reach to end of timer list
+        return -1;
+
+    // idx th timeout will be used.
+    // Reset and set state of the timer
+    timeout_list[idx].timeout_state = 0;
+    timeout_list[idx].timeout_state |= TIMEOUT_USED;
+
+    // calculate when the timeout should fire
+    then = now;
+    timespec_add(&then, seconds);
+
+    timeout_list[idx].timeout_time = then;
+    timeout_list[idx].timeout_seconds = seconds;
+
+    // printf( "\nbefore timeout_list[idx].cb = %X\n", timeout_list[idx].cb);
+    timeout_list[idx].cb = cb;
+    // printf( " after timeout_list[idx].cb = %X\n", timeout_list[idx].cb);
+
+    // How long till the next timeout?
+    next = seconds;
+    for (i = 0; i < TIMEOUTS; i++)
+    {
+        if ((timeout_list[i].timeout_state & (TIMEOUT_USED | TIMEOUT_UNUSED)) == TIMEOUT_USED)
+        {
+            const time_t secs = timespec_diff(timeout_list[i].timeout_time, now);
+
+            if (secs >= 0 && secs < next)
+                next = secs;
+        }
+    }
+
+    *id = idx;
+    /* Return the timeout number. */
+    return timeout_list[idx].timeout_time;
+}
+
+void unregisterTimer(int idx)
+{
+    if( 0 <= idx && idx <= TIMEOUTS)
+        timeout_list[idx].timeout_state = TIMEOUT_UNUSED;
+}
+
+void checkTimeout()
+{
+    time_t now;
+    int i;
+
+    time(&now);
+
+    /* Check all timeouts that are used and armed, but not passed yet. */
+    for (i = 0; i < TIMEOUTS; i++)
+    {
+        if ((timeout_list[i].timeout_state & (TIMEOUT_USED | TIMEOUT_UNUSED)) == TIMEOUT_USED)
+        {
+            const time_t seconds = timespec_diff(timeout_list[i].timeout_time, now);
+
+            if (seconds <= 0)
+            {
+                /* timeout [i] fires! */
+                timeout_list[i].timeout_state = TIMEOUT_UNUSED;
+                if (timeout_list[i].cb)
+                {
+                    timeout_list[i].cb();
+                }
+            }
+        }
+    }
+}
+
+void *loop(void *threadid)
+{
+    while (1)
+    {
+        sleep(SECOND);
+        checkTimeout();
+    }
+
+    return NULL ;
+}
+
+int initThread()
+{
+    int res;
+    long t = 0;
+
+    res = pthread_create(&thread_id, NULL, loop, (void *) t);
+
+    if (res)
+    {
+        printf("ERROR; return code from pthread_create() is %d\n", res);
+        return -1;
+    }
+
+    return 0;
+}
+#else   // WITH_ARDUINO
+time_t timeToSecondsFromNow(tmElements_t *t_then)
+{
+    time_t t, then;
+
+    t = now();
+    then = makeTime((*t_then));
+
+    return (time_t) (then - t);
+}
+
+time_t registerTimer(const time_t seconds, int *id,  void (*cb)())
+{
+    time_t t, then;
+    time_t next;
+    int i, idx;
+
+    if (seconds <= 0)
+    return -1;
+
+    // get the current time
+    t = now();
+
+    for (idx = 0; idx < TIMEOUTS; ++idx)
+    if (!((timeout_list[idx].timeout_state & TIMEOUT_USED) & TIMEOUT_USED))
+    break;
+
+    if (TIMEOUTS == idx)// reach to end of timer list
+    return -1;
+
+    // idx th timeout will be used.
+    // Reset and set state of the timer
+    timeout_list[idx].timeout_state = 0;
+    timeout_list[idx].timeout_state |= TIMEOUT_USED;
+
+    // calculate when the timeout should fire
+    then = t;
+    timespec_add(&then, seconds);
+
+    timeout_list[idx].timeout_time = then;
+    timeout_list[idx].timeout_seconds = seconds;
+
+    // printf( "\nbefore timeout_list[idx].cb = %X\n", timeout_list[idx].cb);
+    timeout_list[idx].cb = cb;
+    // printf( " after timeout_list[idx].cb = %X\n", timeout_list[idx].cb);
+
+    // How long till the next timeout?
+    next = seconds;
+    for (i = 0; i < TIMEOUTS; i++)
+    {
+        if ((timeout_list[i].timeout_state & (TIMEOUT_USED | TIMEOUT_UNUSED))
+                == TIMEOUT_USED)
+        {
+            const time_t secs = timespec_diff(timeout_list[i].timeout_time,
+                    t);
+
+            if (secs >= 0 && secs < next)
+            next = secs;
+        }
+    }
+
+    *id = idx;
+    /* Return the timeout number. */
+    return timeout_list[idx].timeout_time;
+}
+
+void unregisterTimer(int idx)
+{
+    if( 0 <= idx && idx <= TIMEOUTS)
+        timeout_list[idx].timeout_state = TIMEOUT_UNUSED;
+}
+
+void checkTimeout()
+{
+    time_t t;
+    int i;
+
+    t = now();
+
+    /* Check all timeouts that are used and armed, but not passed yet. */
+    for (i = 0; i < TIMEOUTS; i++)
+    {
+        if ((timeout_list[i].timeout_state & (TIMEOUT_USED | TIMEOUT_UNUSED))
+                == TIMEOUT_USED)
+        {
+            const time_t seconds = timespec_diff(timeout_list[i].timeout_time,
+                    t);
+
+            if (seconds <= 0)
+            {
+                /* timeout [i] fires! */
+                timeout_list[i].timeout_state = TIMEOUT_UNUSED;
+                if (timeout_list[i].cb)
+                {
+                    timeout_list[i].cb();
+                }
+            }
+        }
+    }
+}
+
+#endif
diff --git a/extlibs/timer/timer.h b/extlibs/timer/timer.h
new file mode 100755 (executable)
index 0000000..3ecff36
--- /dev/null
@@ -0,0 +1,74 @@
+//******************************************************************
+//
+// 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef TIMER_H_
+#define TIMER_H_
+
+#ifndef WITH_ARDUINO
+#include <sys/time.h>
+#else
+#include <Time.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <math.h>
+
+#ifndef WITH_ARDUINO
+#define SECS_PER_MIN  (60L)
+#define SECS_PER_HOUR (SECS_PER_MIN * 60L)
+#define SECS_PER_DAY  (SECS_PER_HOUR * 24L)
+#define DAYS_PER_WEEK (7L)
+#define SECS_PER_WEEK (SECS_PER_DAY * DAYS_PER_WEEK)
+#define SECS_PER_YEAR (SECS_PER_WEEK * 52L)
+#define SECS_YR_2000  (946684800L)
+#endif
+
+time_t timespec_diff(const time_t after, const time_t before);
+void timespec_add(time_t * to, const time_t seconds);
+void checkTimeout();
+
+#ifndef WITH_ARDUINO
+long int getSeconds(struct tm* tp);
+long int getRelativeIntervalOfWeek(struct tm* tp);
+long int getSecondsFromAbsTime(struct tm* tp);
+
+int initThread();
+void *loop(void *threadid);
+time_t registerTimer(const time_t seconds, int *id, void *cb);
+void unregisterTimer(int id);
+
+#else
+
+time_t timeToSecondsFromNow(tmElements_t *t);
+time_t registerTimer(const time_t seconds, int *id,  void (*cb)());
+void unregisterTimer(int id);
+
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* TIMER_H_ */
+
old mode 100644 (file)
new mode 100755 (executable)
index 9e80dcc..f3239ea
@@ -33,7 +33,7 @@ target_os = env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
-things_manager_env.AppendUnique(CPPPATH = ['sdk/inc', 'sdk/src'])
+things_manager_env.AppendUnique(CPPPATH = ['../../extlibs/timer', 'sdk/inc', 'sdk/src'])
 
 if target_os not in ['windows', 'winrt']:
        things_manager_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
@@ -46,7 +46,14 @@ if target_os == 'android':
 ######################################################################
 # Source files and Targets
 ######################################################################
-tgm_src = env.Glob('sdk/src/*.cpp')
+# tgm_src = env.Glob(['sdk/src/*.cpp', '../../extlibs/timer/timer.c'])
+tgm_src = ['../../extlibs/timer/timer.c', 
+                       'sdk/src/GroupManager.cpp',
+                       'sdk/src/ActionSet.cpp',
+                       'sdk/src/GroupSynchronization.cpp',
+                       'sdk/src/ThingsConfiguration.cpp',
+                       'sdk/src/ThingsDiagnostics.cpp',
+                       'sdk/src/ThingsManager.cpp']
 tgmsdk = things_manager_env.StaticLibrary('TGMSDKLibrary', tgm_src)
 
 things_manager_env.InstallTarget(tgmsdk, 'libTGMSDK')
old mode 100644 (file)
new mode 100755 (executable)
index 7ee28d1..1096799
@@ -33,7 +33,7 @@
 using namespace OC;
 
 /// This function internally calls registerResource API.
-void ConfigurationCollection::createResources(ResourceEntityHandler callback)
+void ConfigurationResource::createResources(ResourceEntityHandler callback)
 {
     using namespace OC::OCPlatform;
 
@@ -53,539 +53,57 @@ void ConfigurationCollection::createResources(ResourceEntityHandler callback)
         std::cout << "Resource creation (configuration) was unsuccessful\n";
     }
 
-    result = bindInterfaceToResource(m_configurationHandle, m_configurationInterfaces[1]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_configurationHandle, m_configurationInterfaces[2]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = registerResource(m_regionHandle, m_regionUri, m_regionTypes[0], m_regionInterfaces[0],
-            callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (region) was unsuccessful\n";
-    }
-
-    result = registerResource(m_timeHandle, m_timeUri, m_timeTypes[0], m_timeInterfaces[0],
-            callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (time) was unsuccessful\n";
-    }
-
-    result = registerResource(m_networkHandle, m_networkUri, m_networkTypes[0],
-            m_networkInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (network) was unsuccessful\n";
-    }
-
-    result = registerResource(m_securityHandle, m_securityUri, m_securityTypes[0],
-            m_securityInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (security) was unsuccessful\n";
-    }
-
-    result = bindResource(m_configurationHandle, m_regionHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding region resource to room was unsuccessful\n";
-    }
-
-    result = bindResource(m_configurationHandle, m_timeHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding time resource to room was unsuccessful\n";
-    }
-
-    result = bindResource(m_configurationHandle, m_networkHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding network resource to room was unsuccessful\n";
-    }
-
-    result = bindResource(m_configurationHandle, m_securityHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding security resource to room was unsuccessful\n";
-    }
-
-    std::cout << "Configuration Collection is Created!(URI: " << m_configurationUri << ") \n";
-
-    myTimeCollection->createResources(callback);
-    myNetworkCollection->createResources(callback);
-    mySecurityCollection->createResources(callback);
-
+    std::cout << "Configuration Resource is Created!(URI: " << m_configurationUri << ") \n";
 }
 
-void ConfigurationCollection::setConfigurationRepresentation(OCRepresentation& rep)
+void ConfigurationResource::setConfigurationRepresentation(OCRepresentation& rep)
 {
     string value;
 
-    if (rep.getValue("value", value))
+    if (rep.getValue("loc", value))
     {
-        m_configurationValue = value;
-
-        std::cout << "\t\t\t\t" << "m_configurationValue: " << m_configurationValue << std::endl;
+        m_location = value;
+        std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
     }
-}
-
-void ConfigurationCollection::setTimeRepresentation(OCRepresentation& rep)
-{
-    string value;
 
-    if (rep.getValue("link", value))
+    if (rep.getValue("st", value))
     {
-        // NOT ALLOWED
-
-        std::cout << "\t\t\t\t" << "link: " << m_timeLink << std::endl;
+        std::cout << "\t\t\t\t" << "SystemTime is not allowed to be written." << std::endl;
     }
-}
-
-void ConfigurationCollection::setNetworkRepresentation(OCRepresentation& rep)
-{
-    string value;
 
-    if (rep.getValue("link", value))
+    if (rep.getValue("c", value))
     {
-        // NOT ALLOWED
-
-        std::cout << "\t\t\t\t" << "link: " << m_networkLink << std::endl;
+        m_currency = value;
+        std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
     }
-}
 
-void ConfigurationCollection::setSecurityRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("link", value))
+    if (rep.getValue("r", value))
     {
-        // NOT ALLOWED
-
-        std::cout << "\t\t\t\t" << "link: " << m_securityLink << std::endl;
+        m_region = value;
+        std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
     }
 }
 
-void ConfigurationCollection::setRegionRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("value", value))
-    {
-        m_regionValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_regionValue << std::endl;
-    }
-}
-
-OCRepresentation ConfigurationCollection::getTimeRepresentation()
-{
-    m_timeRep.setValue("link", m_timeLink);
-
-    return m_timeRep;
-}
-
-OCRepresentation ConfigurationCollection::getNetworkRepresentation()
-{
-    m_networkRep.setValue("link", m_networkLink);
-
-    return m_networkRep;
-}
-
-OCRepresentation ConfigurationCollection::getSecurityRepresentation()
+OCRepresentation ConfigurationResource::getConfigurationRepresentation()
 {
-    m_securityRep.setValue("link", m_securityLink);
-
-    return m_securityRep;
-}
-
-OCRepresentation ConfigurationCollection::getRegionRepresentation()
-{
-    m_regionRep.setValue("value", m_regionValue);
-
-    return m_regionRep;
-}
-
-OCRepresentation ConfigurationCollection::getConfigurationRepresentation()
-{
-    m_configurationRep.clearChildren();
-
-    m_configurationRep.addChild(getRegionRepresentation());
-    m_configurationRep.addChild(getTimeRepresentation());
-    m_configurationRep.addChild(getNetworkRepresentation());
-    m_configurationRep.addChild(getSecurityRepresentation());
-
-    m_configurationRep.setValue("value", m_configurationValue);
+    m_configurationRep.setValue("loc", m_location);
+    m_configurationRep.setValue("st", m_systemTime);
+    m_configurationRep.setValue("c", m_currency);
+    m_configurationRep.setValue("r", m_region);
 
     return m_configurationRep;
 }
 
-std::string ConfigurationCollection::getConfigurationUri()
+std::string ConfigurationResource::getUri()
 {
     return m_configurationUri;
 }
 
-std::string ConfigurationCollection::getTimeUri()
-{
-    return m_timeUri;
-}
-
-std::string ConfigurationCollection::getNetworkUri()
-{
-    return m_networkUri;
-}
-
-std::string ConfigurationCollection::getSecurityUri()
-{
-    return m_securityUri;
-}
-
-std::string ConfigurationCollection::getRegionUri()
-{
-    return m_regionUri;
-}
-
-void ConfigurationCollection::factoryReset()
-{
-    m_configurationValue = defaultConfigurationValue;
-    m_regionValue = defaultRegionValue;
-    m_timeLink = defaultTimeLink;
-    m_networkLink = defaultNetworkLink;
-    m_securityLink = defaultSecurityLink;
-
-    myTimeCollection->factoryReset();
-    myNetworkCollection->factoryReset();
-    mySecurityCollection->factoryReset();
-}
-
-/// This function internally calls registerResource API.
-void TimeCollection::createResources(ResourceEntityHandler callback)
-{
-    using namespace OC::OCPlatform;
-
-    if (callback == NULL)
-    {
-        std::cout << "callback should be binded\t";
-        return;
-    }
-
-    // This will internally create and register the resource.
-    OCStackResult result = registerResource(m_timeHandle, m_timeUri, m_timeTypes[0],
-            m_timeInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (time) was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_timeHandle, m_timeInterfaces[1]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_timeHandle, m_timeInterfaces[2]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = registerResource(m_currentTimeHandle, m_currentTimeUri, m_currentTimeTypes[0],
-            m_currentTimeInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (currentTime) was unsuccessful\n";
-    }
-
-    result = bindResource(m_timeHandle, m_currentTimeHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding currentTime resource to room was unsuccessful\n";
-    }
-
-    std::cout << "Time Collection is Created!(URI: " << m_timeUri << ") \n";
-}
-
-void TimeCollection::setTimeRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("value", value))
-    {
-        m_timeValue = value;
-
-        std::cout << "\t\t\t\t" << "m_timeValue: " << m_timeValue << std::endl;
-    }
-}
-
-void TimeCollection::setCurrentTimeRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("currentTime", value))
-    {
-        m_currentTimeValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_currentTimeValue << std::endl;
-    }
-}
-
-OCRepresentation TimeCollection::getCurrentTimeRepresentation()
-{
-    m_currentTimeRep.setValue("value", m_currentTimeValue);
-
-    return m_currentTimeRep;
-}
-
-OCRepresentation TimeCollection::getTimeRepresentation()
-{
-    m_timeRep.clearChildren();
-
-    m_timeRep.addChild(getCurrentTimeRepresentation());
-
-    m_timeRep.setValue("value", m_timeValue);
-
-    return m_timeRep;
-}
-
-std::string TimeCollection::getTimeUri()
-{
-    return m_timeUri;
-}
-
-std::string TimeCollection::getCurrentTimeUri()
-{
-    return m_currentTimeUri;
-}
-
-void TimeCollection::factoryReset()
-{
-    m_timeValue = defaultTimeValue;
-    m_currentTimeValue = defaultCurrentTimeValue;
-}
-
-/// This function internally calls registerResource API.
-void NetworkCollection::createResources(ResourceEntityHandler callback)
-{
-    using namespace OC::OCPlatform;
-
-    if (callback == NULL)
-    {
-        std::cout << "callback should be binded\t";
-        return;
-    }
-
-    // This will internally create and register the resource.
-    OCStackResult result = registerResource(m_networkHandle, m_networkUri, m_networkTypes[0],
-            m_networkInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (network) was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_networkHandle, m_networkInterfaces[1]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_networkHandle, m_networkInterfaces[2]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = registerResource(m_IPAddressHandle, m_IPAddressUri, m_IPAddressTypes[0],
-            m_IPAddressInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (IPAddress) was unsuccessful\n";
-    }
-
-    result = bindResource(m_networkHandle, m_IPAddressHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding IPAddress resource to room was unsuccessful\n";
-    }
-
-    std::cout << "Network Collection is Created!(URI: " << m_networkUri << ") \n";
-}
-
-void NetworkCollection::setNetworkRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("value", value))
-    {
-        m_networkValue = value;
-
-        std::cout << "\t\t\t\t" << "m_networkValue: " << m_networkValue << std::endl;
-    }
-}
-
-void NetworkCollection::setIPAddressRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("IPAddress", value))
-    {
-        m_IPAddressValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_IPAddressValue << std::endl;
-    }
-}
-OCRepresentation NetworkCollection::getIPAddressRepresentation()
-{
-    m_IPAddressRep.setValue("value", m_IPAddressValue);
-
-    return m_IPAddressRep;
-}
-
-OCRepresentation NetworkCollection::getNetworkRepresentation()
-{
-    m_networkRep.clearChildren();
-
-    m_networkRep.addChild(getIPAddressRepresentation());
-
-    m_networkRep.setValue("value", m_networkValue);
-
-    return m_networkRep;
-}
-
-std::string NetworkCollection::getNetworkUri()
-{
-    return m_networkUri;
-}
-
-std::string NetworkCollection::getIPAddressUri()
-{
-    return m_IPAddressUri;
-}
-
-void NetworkCollection::factoryReset()
-{
-    m_networkValue = defaultNetworkValue;
-    m_IPAddressValue = defaultIPAddressValue;
-}
-
-/// This function internally calls registerResource API.
-void SecurityCollection::createResources(ResourceEntityHandler callback)
-{
-    using namespace OC::OCPlatform;
-
-    if (callback == NULL)
-    {
-        std::cout << "callback should be binded\t";
-        return;
-    }
-
-    // This will internally create and register the resource.
-    OCStackResult result = registerResource(m_securityHandle, m_securityUri, m_securityTypes[0],
-            m_securityInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (security) was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_securityHandle, m_securityInterfaces[1]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_securityHandle, m_securityInterfaces[2]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = registerResource(m_modeHandle, m_modeUri, m_modeTypes[0], m_modeInterfaces[0],
-            callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (mode) was unsuccessful\n";
-    }
-
-    result = bindResource(m_securityHandle, m_modeHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding mode resource to room was unsuccessful\n";
-    }
-
-    std::cout << "Security Collection is Created!(URI: " << m_securityUri << ") \n";
-}
-
-void SecurityCollection::setSecurityRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("value", value))
-    {
-        m_securityValue = value;
-
-        std::cout << "\t\t\t\t" << "m_securityValue: " << m_securityValue << std::endl;
-    }
-}
-
-void SecurityCollection::setModeRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("mode", value))
-    {
-        m_modeValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_modeValue << std::endl;
-    }
-}
-
-OCRepresentation SecurityCollection::getModeRepresentation()
-{
-    m_modeRep.setValue("value", m_modeValue);
-
-    return m_modeRep;
-}
-
-OCRepresentation SecurityCollection::getSecurityRepresentation()
-{
-    m_securityRep.clearChildren();
-
-    m_securityRep.addChild(getModeRepresentation());
-
-    m_securityRep.setValue("value", m_securityValue);
-
-    return m_securityRep;
-}
-
-std::string SecurityCollection::getSecurityUri()
-{
-    return m_securityUri;
-}
-
-std::string SecurityCollection::getModeUri()
-{
-    return m_modeUri;
-}
-
-void SecurityCollection::factoryReset()
+void ConfigurationResource::factoryReset()
 {
-    m_securityValue = defaultSecurityValue;
-    m_modeValue = defaultModeValue;
+    m_location = defaultLocation;
+    m_systemTime = defaultSystemTime;
+    m_currency = defaultCurrency;
+    m_region = defaultRegion;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index cbc1db5..2dc3bbf
 
 using namespace OC;
 
-typedef std::function< OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
+typedef std::function<
+    OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
 
 static std::string defaultURIPrefix = "/oic/con";
 static std::string defaultResourceTypePrefix = "oic.con";
 
-extern std::string defaultTimeValue;
-extern std::string defaultCurrentTimeValue;
+extern std::string defaultLocation;
+extern std::string defaultSystemTime;
+extern std::string defaultCurrency;
+extern std::string defaultRegion;
 
-class TimeCollection
+class ConfigurationResource
 {
 public:
-
-    // diagnostics members
-    std::string m_timeUri;
-    std::string m_timeValue;
-    std::vector< std::string > m_timeTypes;
-    std::vector< std::string > m_timeInterfaces;
-    OCResourceHandle m_timeHandle;
-    OCRepresentation m_timeRep;
-
-    // factory reset members
-    std::string m_currentTimeUri;
-    std::string m_currentTimeValue;
-    std::vector< std::string > m_currentTimeTypes;
-    std::vector< std::string > m_currentTimeInterfaces;
-    OCResourceHandle m_currentTimeHandle;
-    OCRepresentation m_currentTimeRep;
-
-public:
-    /// Constructor
-    TimeCollection() :
-            m_timeValue(defaultTimeValue), m_currentTimeValue(defaultCurrentTimeValue)
-    {
-        m_currentTimeUri = defaultURIPrefix + "/time/0/currentTime"; // URI of the resource
-        m_currentTimeTypes.push_back("oic.con.time.currentTime"); // resource type name.
-        m_currentTimeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_currentTimeRep.setUri(m_currentTimeUri);
-        m_currentTimeRep.setResourceTypes(m_currentTimeTypes);
-        m_currentTimeRep.setResourceInterfaces(m_currentTimeInterfaces);
-        m_currentTimeRep.setValue("value", m_currentTimeValue);
-        m_currentTimeHandle = NULL;
-
-        m_timeUri = defaultURIPrefix + "/time"; // URI of the resource
-        m_timeTypes.push_back("oic.con.time"); // resource type name.
-        m_timeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_timeInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_timeInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_timeRep.setValue("value", m_timeValue);
-        m_timeRep.setUri(m_timeUri);
-        m_timeRep.setResourceTypes(m_timeTypes);
-        m_timeRep.setResourceInterfaces(m_timeInterfaces);
-        m_timeHandle = NULL;
-    }
-    ;
-
-    /// Constructor
-    TimeCollection(std::string URIPrefix, std::string ResourceTypePrefix) :
-            m_timeValue(defaultTimeValue), m_currentTimeValue(defaultCurrentTimeValue)
-    {
-        m_currentTimeUri = URIPrefix + "/time/0/currentTime"; // URI of the resource
-        m_currentTimeTypes.push_back(ResourceTypePrefix + ".time.currentTime"); // type name.
-        m_currentTimeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_currentTimeRep.setUri(m_currentTimeUri);
-        m_currentTimeRep.setResourceTypes(m_currentTimeTypes);
-        m_currentTimeRep.setResourceInterfaces(m_currentTimeInterfaces);
-        m_currentTimeRep.setValue("value", m_currentTimeValue);
-        m_currentTimeHandle = NULL;
-
-        m_timeUri = URIPrefix + "/time"; // URI of the resource
-        m_timeTypes.push_back(ResourceTypePrefix + ".time"); // resource type name.
-        m_timeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_timeInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_timeInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_timeRep.setValue("value", m_timeValue);
-        m_timeRep.setUri(m_timeUri);
-        m_timeRep.setResourceTypes(m_timeTypes);
-        m_timeRep.setResourceInterfaces(m_timeInterfaces);
-        m_timeHandle = NULL;
-    }
-    ;
-
-    /// This function internally calls registerResource API.
-    void createResources(ResourceEntityHandler callback);
-
-    void setTimeRepresentation(OCRepresentation& rep);
-    void setCurrentTimeRepresentation(OCRepresentation& rep);
-
-    OCRepresentation getTimeRepresentation();
-    OCRepresentation getCurrentTimeRepresentation();
-
-    std::string getTimeUri();
-    std::string getCurrentTimeUri();
-
-    void factoryReset();
-
-};
-
-extern std::string defaultNetworkValue;
-extern std::string defaultIPAddressValue;
-
-class NetworkCollection
-{
-public:
-
-    // diagnostics members
-    std::string m_networkUri;
-    std::string m_networkValue;
-    std::vector< std::string > m_networkTypes;
-    std::vector< std::string > m_networkInterfaces;
-    OCResourceHandle m_networkHandle;
-    OCRepresentation m_networkRep;
-
-    // factory reset members
-    std::string m_IPAddressUri;
-    std::string m_IPAddressValue;
-    std::vector< std::string > m_IPAddressTypes;
-    std::vector< std::string > m_IPAddressInterfaces;
-    OCResourceHandle m_IPAddressHandle;
-    OCRepresentation m_IPAddressRep;
-
-public:
-
-    /// Constructor
-    NetworkCollection() :
-            m_networkValue(defaultNetworkValue), m_IPAddressValue(defaultIPAddressValue)
-    {
-        m_IPAddressUri = defaultURIPrefix + "/network/0/IPAddress"; // URI of the resource
-        m_IPAddressTypes.push_back("oic.con.network.IPAddress"); // resource type name.
-        m_IPAddressInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_IPAddressRep.setUri(m_IPAddressUri);
-        m_IPAddressRep.setResourceTypes(m_IPAddressTypes);
-        m_IPAddressRep.setResourceInterfaces(m_IPAddressInterfaces);
-        m_IPAddressRep.setValue("value", m_IPAddressValue);
-        m_IPAddressHandle = NULL;
-
-        m_networkUri = defaultURIPrefix + "/network"; // URI of the resource
-        m_networkTypes.push_back("oic.con.network"); // resource type name.
-        m_networkInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_networkInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_networkInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_networkRep.setValue("value", m_networkValue);
-        m_networkRep.setUri(m_networkUri);
-        m_networkRep.setResourceTypes(m_networkTypes);
-        m_networkRep.setResourceInterfaces(m_networkInterfaces);
-        m_networkHandle = NULL;
-    }
-    ;
-
-    /// Constructor
-    NetworkCollection(std::string URIPrefix, std::string ResourceTypePrefix) :
-            m_networkValue(defaultNetworkValue), m_IPAddressValue(defaultIPAddressValue)
-    {
-        m_IPAddressUri = URIPrefix + "/network/0/IPAddress"; // URI of the resource
-        m_IPAddressTypes.push_back(ResourceTypePrefix + "network.IPAddress"); // resource type name.
-        m_IPAddressInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_IPAddressRep.setUri(m_IPAddressUri);
-        m_IPAddressRep.setResourceTypes(m_IPAddressTypes);
-        m_IPAddressRep.setResourceInterfaces(m_IPAddressInterfaces);
-        m_IPAddressRep.setValue("value", m_IPAddressValue);
-        m_IPAddressHandle = NULL;
-
-        m_networkUri = URIPrefix + "/network"; // URI of the resource
-        m_networkTypes.push_back(ResourceTypePrefix + ".network"); // resource type name.
-        m_networkInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_networkInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_networkInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_networkRep.setValue("value", m_networkValue);
-        m_networkRep.setUri(m_networkUri);
-        m_networkRep.setResourceTypes(m_networkTypes);
-        m_networkRep.setResourceInterfaces(m_networkInterfaces);
-        m_networkHandle = NULL;
-    }
-    ;
-
-    /// This function internally calls registerResource API.
-    void createResources(ResourceEntityHandler callback);
-
-    void setNetworkRepresentation(OCRepresentation& rep);
-    void setIPAddressRepresentation(OCRepresentation& rep);
-
-    OCRepresentation getNetworkRepresentation();
-    OCRepresentation getIPAddressRepresentation();
-
-    std::string getNetworkUri();
-    std::string getIPAddressUri();
-
-    void factoryReset();
-
-};
-
-extern std::string defaultSecurityValue;
-extern std::string defaultModeValue;
-
-class SecurityCollection
-{
-public:
-
-    // diagnostics members
-    std::string m_securityUri;
-    std::string m_securityValue;
-    std::vector< std::string > m_securityTypes;
-    std::vector< std::string > m_securityInterfaces;
-    OCResourceHandle m_securityHandle;
-    OCRepresentation m_securityRep;
-
-    // factory reset members
-    std::string m_modeUri;
-    std::string m_modeValue;
-    std::vector< std::string > m_modeTypes;
-    std::vector< std::string > m_modeInterfaces;
-    OCResourceHandle m_modeHandle;
-    OCRepresentation m_modeRep;
-
-public:
-    /// Constructor
-    SecurityCollection() :
-            m_securityValue(defaultSecurityValue), m_modeValue(defaultModeValue)
-    {
-        m_modeUri = defaultURIPrefix + "/security/0/mode"; // URI of the resource
-        m_modeTypes.push_back("oic.con.security.mode"); // resource type name.
-        m_modeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_modeRep.setUri(m_modeUri);
-        m_modeRep.setResourceTypes(m_modeTypes);
-        m_modeRep.setResourceInterfaces(m_modeInterfaces);
-        m_modeRep.setValue("value", m_modeValue);
-        m_modeHandle = NULL;
-
-        m_securityUri = defaultURIPrefix + "/security"; // URI of the resource
-        m_securityTypes.push_back("oic.con.security"); // resource type name.
-        m_securityInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_securityInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_securityInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_securityRep.setValue("value", m_securityValue);
-        m_securityRep.setUri(m_securityUri);
-        m_securityRep.setResourceTypes(m_securityTypes);
-        m_securityRep.setResourceInterfaces(m_securityInterfaces);
-        m_securityHandle = NULL;
-    }
-    ;
-
-    /// Constructor
-    SecurityCollection(std::string URIPrefix, std::string ResourceTypePrefix) :
-            m_securityValue(defaultSecurityValue), m_modeValue(defaultModeValue)
-    {
-        m_modeUri = URIPrefix + "/security/0/mode"; // URI of the resource
-        m_modeTypes.push_back(ResourceTypePrefix + ".security.mode"); // resource type name.
-        m_modeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_modeRep.setUri(m_modeUri);
-        m_modeRep.setResourceTypes(m_modeTypes);
-        m_modeRep.setResourceInterfaces(m_modeInterfaces);
-        m_modeRep.setValue("value", m_modeValue);
-        m_modeHandle = NULL;
-
-        m_securityUri = URIPrefix + "/security"; // URI of the resource
-        m_securityTypes.push_back(ResourceTypePrefix + ".security"); // resource type name.
-        m_securityInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_securityInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_securityInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_securityRep.setValue("value", m_securityValue);
-        m_securityRep.setUri(m_securityUri);
-        m_securityRep.setResourceTypes(m_securityTypes);
-        m_securityRep.setResourceInterfaces(m_securityInterfaces);
-        m_securityHandle = NULL;
-    }
-    ;
-
-    /// This function internally calls registerResource API.
-    void createResources(ResourceEntityHandler callback);
-
-    void setSecurityRepresentation(OCRepresentation& rep);
-    void setModeRepresentation(OCRepresentation& rep);
-
-    OCRepresentation getSecurityRepresentation();
-    OCRepresentation getModeRepresentation();
-
-    std::string getSecurityUri();
-    std::string getModeUri();
-
-    void factoryReset();
-
-};
-
-extern std::string defaultConfigurationValue;
-extern std::string defaultRegionValue;
-static std::string defaultTimeLink = "/con/con/0/time";
-static std::string defaultNetworkLink = "/con/con/0/network";
-static std::string defaultSecurityLink = "/con/con/0/security";
-
-class ConfigurationCollection
-{
-public:
-    TimeCollection *myTimeCollection;
-    NetworkCollection *myNetworkCollection;
-    SecurityCollection *mySecurityCollection;
-
-public:
     // Configuration members
     std::string m_configurationUri;
-    std::string m_configurationValue;
+    std::string m_location;
+    std::string m_systemTime;
+    std::string m_currency;
+    std::string m_region;
     std::vector< std::string > m_configurationTypes;
     std::vector< std::string > m_configurationInterfaces;
     OCResourceHandle m_configurationHandle;
     OCRepresentation m_configurationRep;
 
-    // Security members
-    std::string m_regionUri;
-    std::string m_regionValue;
-    std::vector< std::string > m_regionTypes;
-    std::vector< std::string > m_regionInterfaces;
-    OCResourceHandle m_regionHandle;
-    OCRepresentation m_regionRep;
-
-    // Time members
-    std::string m_timeUri;
-    std::string m_timeLink;
-    std::vector< std::string > m_timeTypes;
-    std::vector< std::string > m_timeInterfaces;
-    OCResourceHandle m_timeHandle;
-    OCRepresentation m_timeRep;
-
-    // Network members
-    std::string m_networkUri;
-    std::string m_networkLink;
-    std::vector< std::string > m_networkTypes;
-    std::vector< std::string > m_networkInterfaces;
-    OCResourceHandle m_networkHandle;
-    OCRepresentation m_networkRep;
-
-    // Security members
-    std::string m_securityUri;
-    std::string m_securityLink;
-    std::vector< std::string > m_securityTypes;
-    std::vector< std::string > m_securityInterfaces;
-    OCResourceHandle m_securityHandle;
-    OCRepresentation m_securityRep;
-
 public:
     /// Constructor
-    ConfigurationCollection() :
-            m_configurationValue(defaultConfigurationValue), m_regionValue(defaultRegionValue), m_timeLink(
-                    defaultTimeLink), m_networkLink(defaultNetworkLink), m_securityLink(
-                    defaultSecurityLink)
+    ConfigurationResource() :
+            m_location(defaultLocation), m_systemTime(defaultSystemTime), m_currency(
+                    defaultCurrency), m_region(defaultRegion)
     {
-        m_regionUri = defaultURIPrefix + "/0/region"; // URI of the resource
-        m_regionTypes.push_back(defaultResourceTypePrefix + ".region"); // resource type name.
-        m_regionInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_regionRep.setUri(m_regionUri);
-        m_regionRep.setResourceTypes(m_regionTypes);
-        m_regionRep.setResourceInterfaces(m_regionInterfaces);
-        m_regionRep.setValue("value", m_regionValue);
-        m_regionHandle = NULL;
-
-        m_timeUri = defaultURIPrefix + "/0/time"; // URI of the resource
-        m_timeTypes.push_back(defaultResourceTypePrefix + ".time"); // resource type name.
-        m_timeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_timeRep.setUri(m_timeUri);
-        m_timeRep.setResourceTypes(m_timeTypes);
-        m_timeRep.setResourceInterfaces(m_timeInterfaces);
-        m_timeRep.setValue("link", m_timeLink);
-        m_timeHandle = NULL;
-
-        m_networkUri = defaultURIPrefix + "/0/net"; // URI of the resource
-        m_networkTypes.push_back(defaultResourceTypePrefix + ".net"); // resource type name.
-        m_networkInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_networkRep.setUri(m_networkUri);
-        m_networkRep.setResourceTypes(m_networkTypes);
-        m_networkRep.setResourceInterfaces(m_networkInterfaces);
-        m_networkRep.setValue("link", m_networkLink);
-        m_networkHandle = NULL;
-
-        m_securityUri = defaultURIPrefix + "/0/sec"; // URI of the resource
-        m_securityTypes.push_back(defaultResourceTypePrefix + ".sec"); // resource type name.
-        m_securityInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_securityRep.setUri(m_securityUri);
-        m_securityRep.setResourceTypes(m_securityTypes);
-        m_securityRep.setResourceInterfaces(m_securityInterfaces);
-        m_securityRep.setValue("link", m_securityLink);
-        m_securityHandle = NULL;
-
-        m_configurationUri = defaultURIPrefix + ""; // URI of the resource
-        m_configurationTypes.push_back(defaultResourceTypePrefix + ""); // resource type name.
+        m_configurationUri = "/oic/con"; // URI of the resource
+        m_configurationTypes.push_back("oic.con"); // resource type name.
         m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_configurationInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_configurationInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_configurationRep.setValue("value", m_configurationValue);
+        //m_configurationInterfaces.push_back(BATCH_INTERFACE); // resource interface.
+        //m_configurationInterfaces.push_back(LINK_INTERFACE); // resource interface.
+        m_configurationRep.setValue("loc", m_location);
+        m_configurationRep.setValue("st", m_systemTime);
+        m_configurationRep.setValue("c", m_currency);
+        m_configurationRep.setValue("r", m_region);
         m_configurationRep.setUri(m_configurationUri);
         m_configurationRep.setResourceTypes(m_configurationTypes);
         m_configurationRep.setResourceInterfaces(m_configurationInterfaces);
         m_configurationHandle = NULL;
-
-        myTimeCollection = new TimeCollection();
-        myNetworkCollection = new NetworkCollection();
-        mySecurityCollection = new SecurityCollection();
     }
     ;
 
-    /// Constructor
-    ConfigurationCollection(std::string URIPrefix, std::string ResourceTypePrefix) :
-            m_configurationValue(defaultConfigurationValue), m_regionValue(defaultRegionValue), m_timeLink(
-                    defaultTimeLink), m_networkLink(defaultNetworkLink), m_securityLink(
-                    defaultSecurityLink)
+    ~ConfigurationResource()
     {
-        m_regionUri = URIPrefix + "/0/region"; // URI of the resource
-        m_regionTypes.push_back(ResourceTypePrefix + ".region"); // type name.
-        m_regionInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_regionRep.setUri(m_regionUri);
-        m_regionRep.setResourceTypes(m_regionTypes);
-        m_regionRep.setResourceInterfaces(m_regionInterfaces);
-        m_regionRep.setValue("value", m_regionValue);
-        m_regionHandle = NULL;
-
-        m_timeUri = URIPrefix + "/0/time"; // URI of the resource
-        m_timeTypes.push_back(ResourceTypePrefix + ".time"); // resource type name.
-        m_timeInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_timeRep.setUri(m_timeUri);
-        m_timeRep.setResourceTypes(m_timeTypes);
-        m_timeRep.setResourceInterfaces(m_timeInterfaces);
-        m_timeRep.setValue("link", m_timeLink);
-        m_timeHandle = NULL;
-
-        m_networkUri = URIPrefix + "/0/net"; // URI of the resource
-        m_networkTypes.push_back(ResourceTypePrefix + ".net"); // resource type name.
-        m_networkInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
 
-        m_networkRep.setUri(m_networkUri);
-        m_networkRep.setResourceTypes(m_networkTypes);
-        m_networkRep.setResourceInterfaces(m_networkInterfaces);
-        m_networkRep.setValue("link", m_networkLink);
-        m_networkHandle = NULL;
-
-        m_securityUri = URIPrefix + "/0/sec"; // URI of the resource
-        m_securityTypes.push_back(ResourceTypePrefix + ".sec"); // resource type name.
-        m_securityInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_securityRep.setUri(m_securityUri);
-        m_securityRep.setResourceTypes(m_securityTypes);
-        m_securityRep.setResourceInterfaces(m_securityInterfaces);
-        m_securityRep.setValue("link", m_securityLink);
-        m_securityHandle = NULL;
-
-        m_configurationUri = URIPrefix + ""; // URI of the resource
-        m_configurationTypes.push_back(ResourceTypePrefix + ""); // resource type name.
-        m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_configurationInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_configurationInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_configurationRep.setValue("value", m_configurationValue);
-        m_configurationRep.setUri(m_configurationUri);
-        m_configurationRep.setResourceTypes(m_configurationTypes);
-        m_configurationRep.setResourceInterfaces(m_configurationInterfaces);
-        m_configurationHandle = NULL;
-
-        myTimeCollection = new TimeCollection(URIPrefix, ResourceTypePrefix);
-        myNetworkCollection = new NetworkCollection(URIPrefix, ResourceTypePrefix);
-        mySecurityCollection = new SecurityCollection(URIPrefix, ResourceTypePrefix);
-    }
-    ;
-
-    ~ConfigurationCollection()
-    {
-        free(myTimeCollection);
-        free(myNetworkCollection);
-        free(mySecurityCollection);
     }
 
     /// This function internally calls registerResource API.
     void createResources(ResourceEntityHandler callback);
-
     void setConfigurationRepresentation(OCRepresentation& rep);
-    void setTimeRepresentation(OCRepresentation& rep);
-    void setNetworkRepresentation(OCRepresentation& rep);
-    void setSecurityRepresentation(OCRepresentation& rep);
-    void setRegionRepresentation(OCRepresentation& rep);
-
-    OCRepresentation getTimeRepresentation();
-    OCRepresentation getNetworkRepresentation();
-    OCRepresentation getSecurityRepresentation();
-    OCRepresentation getRegionRepresentation();
     OCRepresentation getConfigurationRepresentation();
-
-    std::string getConfigurationUri();
-    std::string getTimeUri();
-    std::string getNetworkUri();
-    std::string getSecurityUri();
-    std::string getRegionUri();
+    std::string getUri();
 
     void factoryReset();
 
old mode 100644 (file)
new mode 100755 (executable)
index 31eaf1e..7809396
@@ -33,7 +33,7 @@
 using namespace OC;
 
 /// This function internally calls registerResource API.
-void DiagnosticsCollection::createResources(ResourceEntityHandler callback)
+void DiagnosticsResource::createResources(ResourceEntityHandler callback)
 {
     using namespace OC::OCPlatform;
 
@@ -53,192 +53,72 @@ void DiagnosticsCollection::createResources(ResourceEntityHandler callback)
         std::cout << "Resource creation (diagnostics) was unsuccessful\n";
     }
 
-    result = bindInterfaceToResource(m_diagnosticsHandle, m_diagnosticsInterfaces[1]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_diagnosticsHandle, m_diagnosticsInterfaces[2]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = registerResource(m_factoryResetHandle, m_factoryResetUri, m_factoryResetTypes[0],
-            m_factoryResetInterfaces[0], callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (factoryReset) was unsuccessful\n";
-    }
-
-    result = registerResource(m_rebootHandle, m_rebootUri, m_rebootTypes[0], m_rebootInterfaces[0],
-            callback, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (reboot) was unsuccessful\n";
-    }
-
-    result = registerResource(m_startCollectionHandle, m_startCollectionUri,
-            m_startCollectionTypes[0], m_startCollectionInterfaces[0], callback,
-            OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Resource creation (startCollection) was unsuccessful\n";
-    }
-
-    result = bindResource(m_diagnosticsHandle, m_factoryResetHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding installedLocation resource to room was unsuccessful\n";
-    }
-
-    result = bindResource(m_diagnosticsHandle, m_rebootHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding time resource to room was unsuccessful\n";
-    }
-
-    result = bindResource(m_diagnosticsHandle, m_startCollectionHandle);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding network resource to room was unsuccessful\n";
-    }
-
     thread exec(
             std::function< void(int second) >(
-                    std::bind(&DiagnosticsCollection::diagnosticsMonitor, this,
+                    std::bind(&DiagnosticsResource::diagnosticsMonitor, this,
                             std::placeholders::_1)), 10); // every 10 seconds
     exec.detach();
 
-    std::cout << "Diagnostics Collection is Created!\n";
-}
-
-void DiagnosticsCollection::setDiagnosticsRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("value", value))
-    {
-        m_diagnosticsValue = value;
-
-        std::cout << "\t\t\t\t" << "m_diagnosticsValue: " << m_diagnosticsValue << std::endl;
-    }
+    std::cout << "Diagnostics Resource is Created!\n";
 }
 
-void DiagnosticsCollection::setFactoryResetRepresentation(OCRepresentation& rep)
+void DiagnosticsResource::setDiagnosticsRepresentation(OCRepresentation& rep)
 {
     string value;
 
-    if (rep.getValue("value", value))
+    if (rep.getValue("fr", value))
     {
-        m_factoryResetValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_factoryResetValue << std::endl;
+        m_factoryReset = value;
+        std::cout << "\t\t\t\t" << "m_factoryReset: " << m_factoryReset << std::endl;
     }
-}
-
-void DiagnosticsCollection::setRebootRepresentation(OCRepresentation& rep)
-{
-    string value;
 
-    if (rep.getValue("value", value))
+    if (rep.getValue("rb", value))
     {
-        m_rebootValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_rebootValue << std::endl;
+        m_reboot = value;
+        std::cout << "\t\t\t\t" << "m_reboot: " << m_reboot << std::endl;
     }
-}
-
-void DiagnosticsCollection::setStartCollectionRepresentation(OCRepresentation& rep)
-{
-    string value;
 
-    if (rep.getValue("value", value))
+    if (rep.getValue("ssc", value))
     {
-        m_startCollectionValue = value;
-
-        std::cout << "\t\t\t\t" << "value: " << m_startCollectionValue << std::endl;
+        m_startStatCollection = value;
+        std::cout << "\t\t\t\t" << "m_startStatCollection: " << m_startStatCollection << std::endl;
     }
 }
 
-OCRepresentation DiagnosticsCollection::getFactoryResetRepresentation()
-{
-    m_factoryResetRep.setValue("value", m_factoryResetValue);
-
-    return m_factoryResetRep;
-}
-
-OCRepresentation DiagnosticsCollection::getRebootRepresentation()
+OCRepresentation DiagnosticsResource::getDiagnosticsRepresentation()
 {
-    m_rebootRep.setValue("value", m_rebootValue);
-
-    return m_rebootRep;
-}
-
-OCRepresentation DiagnosticsCollection::getStartCollectionRepresentation()
-{
-    m_startCollectionRep.setValue("value", m_startCollectionValue);
-
-    return m_startCollectionRep;
-}
-
-OCRepresentation DiagnosticsCollection::getDiagnosticsRepresentation()
-{
-    m_diagnosticsRep.clearChildren();
-
-    m_diagnosticsRep.addChild(getFactoryResetRepresentation());
-    m_diagnosticsRep.addChild(getRebootRepresentation());
-    m_diagnosticsRep.addChild(getStartCollectionRepresentation());
-
-    m_diagnosticsRep.setValue("value", m_diagnosticsValue);
+    m_diagnosticsRep.setValue("fr", m_factoryReset);
+    m_diagnosticsRep.setValue("rb", m_reboot);
+    m_diagnosticsRep.setValue("ssc", m_startStatCollection);
 
     return m_diagnosticsRep;
 }
 
-std::string DiagnosticsCollection::getDiagnosticsUri()
+std::string DiagnosticsResource::getUri()
 {
     return m_diagnosticsUri;
 }
 
-std::string DiagnosticsCollection::getFactoryResetUri()
-{
-    return m_factoryResetUri;
-}
-
-std::string DiagnosticsCollection::getRebootUri()
-{
-    return m_rebootUri;
-}
-
-std::string DiagnosticsCollection::getStartCollectionUri()
-{
-    return m_startCollectionUri;
-}
-
-void DiagnosticsCollection::diagnosticsMonitor(int second)
+void DiagnosticsResource::diagnosticsMonitor(int second)
 {
     while (1)
     {
         sleep(second);
 
-        if (m_rebootValue == "true")
+        if (m_reboot == "true")
         {
             int res;
             std::cout << "Reboot will be soon..." << std::endl;
-            m_rebootValue = defaultReboot;
+            m_reboot = defaultReboot;
             res = system("sudo reboot"); // System reboot
 
             std::cout << "return: " << res << std::endl;
 
         }
-        else if (m_factoryResetValue == "true")
+        else if (m_factoryReset == "true")
         {
             std::cout << "Factory Reset will be soon..." << std::endl;
-            m_factoryResetValue = defaultFactoryReset;
+            m_factoryReset = defaultFactoryReset;
             factoryReset();
         }
     }
old mode 100644 (file)
new mode 100755 (executable)
index df4c83e..27f91a4
 
 using namespace OC;
 
-typedef std::function< OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
+typedef std::function<
+    OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
 
-static std::string defaultDiagnosticsValue = "false";
 static std::string defaultFactoryReset = "false";
 static std::string defaultReboot = "false";
-static std::string defaultStartCollection = "false";
+static std::string defaultStartStatCollection = "false";
 
-class DiagnosticsCollection
+class DiagnosticsResource
 {
 public:
 
     // diagnostics members
     std::string m_diagnosticsUri;
-    std::string m_diagnosticsValue;
+    std::string m_factoryReset;
+    std::string m_reboot;
+    std::string m_startStatCollection;
     std::vector< std::string > m_diagnosticsTypes;
     std::vector< std::string > m_diagnosticsInterfaces;
     OCResourceHandle m_diagnosticsHandle;
     OCRepresentation m_diagnosticsRep;
 
-    // factory reset members
-    std::string m_factoryResetUri;
-    std::string m_factoryResetValue;
-    std::vector< std::string > m_factoryResetTypes;
-    std::vector< std::string > m_factoryResetInterfaces;
-    OCResourceHandle m_factoryResetHandle;
-    OCRepresentation m_factoryResetRep;
-
-    // reboot members
-    std::string m_rebootUri;
-    std::string m_rebootValue;
-    std::vector< std::string > m_rebootTypes;
-    std::vector< std::string > m_rebootInterfaces;
-    OCResourceHandle m_rebootHandle;
-    OCRepresentation m_rebootRep;
-
-    // startcollection members
-    std::string m_startCollectionUri;
-    std::string m_startCollectionValue;
-    std::vector< std::string > m_startCollectionTypes;
-    std::vector< std::string > m_startCollectionInterfaces;
-    OCResourceHandle m_startCollectionHandle;
-    OCRepresentation m_startCollectionRep;
-
 public:
     /// Constructor
-    DiagnosticsCollection() :
-            m_diagnosticsValue(defaultDiagnosticsValue), m_factoryResetValue(defaultFactoryReset), m_rebootValue(
-                    defaultReboot), m_startCollectionValue(defaultStartCollection)
+    DiagnosticsResource() :
+           m_factoryReset(defaultFactoryReset), m_reboot(defaultReboot),
+            m_startStatCollection(defaultStartStatCollection)
     {
-        m_factoryResetUri = "/oic/diag/0/factoryReset"; // URI of the resource
-        m_factoryResetTypes.push_back("oic.diag.factoryReset"); // resource type name.
-        m_factoryResetInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_factoryResetRep.setUri(m_factoryResetUri);
-        m_factoryResetRep.setResourceTypes(m_factoryResetTypes);
-        m_factoryResetRep.setResourceInterfaces(m_factoryResetInterfaces);
-        m_factoryResetRep.setValue("value", m_factoryResetValue);
-        m_factoryResetHandle = NULL;
-
-        m_rebootUri = "/oic/diag/0/reboot"; // URI of the resource
-        m_rebootTypes.push_back("oic.diag.reboot"); // resource type name.
-        m_rebootInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_rebootRep.setUri(m_rebootUri);
-        m_rebootRep.setResourceTypes(m_rebootTypes);
-        m_rebootRep.setResourceInterfaces(m_rebootInterfaces);
-        m_rebootRep.setValue("value", m_rebootValue);
-        m_rebootHandle = NULL;
-
-        m_startCollectionUri = "/oic/diag/0/startCollection"; // URI of the resource
-        m_startCollectionTypes.push_back("oic.diag.startCollection"); // resource type name.
-        m_startCollectionInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_startCollectionRep.setUri(m_startCollectionUri);
-        m_startCollectionRep.setResourceTypes(m_startCollectionTypes);
-        m_startCollectionRep.setResourceInterfaces(m_startCollectionInterfaces);
-        m_startCollectionRep.setValue("value", m_startCollectionValue);
-        m_startCollectionHandle = NULL;
-
         m_diagnosticsUri = "/oic/diag"; // URI of the resource
         m_diagnosticsTypes.push_back("oic.diag"); // resource type name.
         m_diagnosticsInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_diagnosticsInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_diagnosticsInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_diagnosticsRep.setValue("value", m_diagnosticsValue);
+        m_diagnosticsRep.setValue("fr", m_factoryReset);
+        m_diagnosticsRep.setValue("rb", m_reboot);
+        m_diagnosticsRep.setValue("ssc", m_startStatCollection);
         m_diagnosticsRep.setUri(m_diagnosticsUri);
         m_diagnosticsRep.setResourceTypes(m_diagnosticsTypes);
         m_diagnosticsRep.setResourceInterfaces(m_diagnosticsInterfaces);
@@ -129,19 +77,10 @@ public:
     void createResources(ResourceEntityHandler callback);
 
     void setDiagnosticsRepresentation(OCRepresentation& rep);
-    void setFactoryResetRepresentation(OCRepresentation& rep);
-    void setRebootRepresentation(OCRepresentation& rep);
-    void setStartCollectionRepresentation(OCRepresentation& rep);
 
     OCRepresentation getDiagnosticsRepresentation();
-    OCRepresentation getFactoryResetRepresentation();
-    OCRepresentation getRebootRepresentation();
-    OCRepresentation getStartCollectionRepresentation();
-
-    std::string getDiagnosticsUri();
-    std::string getFactoryResetUri();
-    std::string getRebootUri();
-    std::string getStartCollectionUri();
+
+    std::string getUri();
 
     void diagnosticsMonitor(int second);
 
old mode 100644 (file)
new mode 100755 (executable)
index d050096..36c4d93
 
 using namespace OC;
 
+FactorySetResource::FactorySetResource()
+{
+    m_configurationUri = "/factorySet"; // URI of the resource
+    m_configurationTypes.clear();
+    m_configurationTypes.push_back("factorySet"); // resource type name.
+    m_configurationRep.setUri(m_configurationUri);
+    m_configurationRep.setResourceTypes(m_configurationTypes);
+}
+
+FactorySetResource::~FactorySetResource(){}
+
 /// This function internally calls registerResource API.
-void FactorySetCollection::createResources(ResourceEntityHandler callback)
+void FactorySetResource::createResources(ResourceEntityHandler callback)
 {
     using namespace OC::OCPlatform;
 
@@ -44,8 +55,8 @@ void FactorySetCollection::createResources(ResourceEntityHandler callback)
     }
 
     // This will internally create and register the resource.
-    OCStackResult result = registerResource(m_factorySetHandle, m_factorySetUri,
-            m_factorySetTypes[0], m_factorySetInterfaces[0], callback,
+    OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
+            m_configurationTypes[0], m_configurationInterfaces[0], callback,
             OC_DISCOVERABLE | OC_OBSERVABLE);
 
     if (OC_STACK_OK != result)
@@ -53,89 +64,49 @@ void FactorySetCollection::createResources(ResourceEntityHandler callback)
         std::cout << "Resource creation (configuration) was unsuccessful\n";
     }
 
-    result = bindInterfaceToResource(m_factorySetHandle, m_factorySetInterfaces[1]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
-
-    result = bindInterfaceToResource(m_factorySetHandle, m_factorySetInterfaces[2]);
-    if (OC_STACK_OK != result)
-    {
-        std::cout << "Binding TypeName to Resource was unsuccessful\n";
-    }
+    std::cout << "FactorySet Resource is Created!\n";
+}
 
-    result = registerResource(m_configurationCollectionHandle, m_configurationCollectionUri,
-            m_configurationCollectionTypes[0], m_configurationCollectionInterfaces[0], callback,
-            OC_DISCOVERABLE | OC_OBSERVABLE);
+void FactorySetResource::setFactorySetRepresentation(OCRepresentation& rep)
+{
+    string value;
 
-    if (OC_STACK_OK != result)
+    if (rep.getValue("loc", value))
     {
-        std::cout << "Resource creation (installedLocation) was unsuccessful\n";
+        m_location = value;
+        std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
     }
 
-    result = bindResource(m_factorySetHandle, m_configurationCollectionHandle);
-    if (OC_STACK_OK != result)
+    if (rep.getValue("st", value))
     {
-        std::cout << "Binding installedLocation resource to room was unsuccessful\n";
+        std::cout << "\t\t\t\t" << "SystemTime is not allowed to be written." << std::endl;
     }
 
-    defaultConfigurationCollection = new ConfigurationCollection(defaultConfigurationURIPrefix,
-            defaultConfigurationResourceTypePrefix);
-    //defaultConfigurationCollection->bindEntityHander(callback);
-    defaultConfigurationCollection->createResources(callback);
-
-    std::cout << "FactorySet Collection is Created!\n";
-}
-
-void FactorySetCollection::setFactorySetRepresentation(OCRepresentation& rep)
-{
-    string value;
-
-    if (rep.getValue("value", value))
+    if (rep.getValue("c", value))
     {
-        m_factorySetValue = value;
-
-        std::cout << "\t\t\t\t" << "m_factorySetValue: " << m_factorySetValue << std::endl;
+        m_currency = value;
+        std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
     }
-}
-
-void FactorySetCollection::setConfigurationCollectionRepresentation(OCRepresentation& rep)
-{
-    string value;
 
-    if (rep.getValue("link", value))
+    if (rep.getValue("r", value))
     {
-        // NOT ALLOWED
-
-        std::cout << "\t\t\t\t" << "link: " << m_configurationCollectionLink << std::endl;
+        m_region = value;
+        std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
     }
 }
 
-OCRepresentation FactorySetCollection::getConfigurationCollectionRepresentation()
+OCRepresentation FactorySetResource::getFactorySetRepresentation()
 {
-    m_configurationCollectionRep.setValue("link", m_configurationCollectionLink);
+    m_configurationRep.setValue("loc", m_location);
+    m_configurationRep.setValue("st", m_systemTime);
+    m_configurationRep.setValue("c", m_currency);
+    m_configurationRep.setValue("r", m_region);
 
-    return m_configurationCollectionRep;
+    return m_configurationRep;
 }
 
-OCRepresentation FactorySetCollection::getFactorySetRepresentation()
+std::string FactorySetResource::getUri()
 {
-    m_factorySetRep.clearChildren();
-
-    m_factorySetRep.addChild(getConfigurationCollectionRepresentation());
-
-    m_factorySetRep.setValue("value", m_factorySetValue);
-
-    return m_factorySetRep;
+    return m_configurationUri;
 }
 
-std::string FactorySetCollection::getFactorySetUri()
-{
-    return m_factorySetUri;
-}
-
-std::string FactorySetCollection::getConfigurationCollectionUri()
-{
-    return m_configurationCollectionUri;
-}
old mode 100644 (file)
new mode 100755 (executable)
index bc20a71..15b5f3f
 
 using namespace OC;
 
-typedef std::function< OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
+typedef std::function<
+    OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
 
-extern std::string defaultFactorySetValue;
-static std::string defaultConfigurationCollectionLink = "/factorySet/oic/con";
-
-static std::string defaultConfigurationURIPrefix = "/factorySet/oic/con";
-static std::string defaultConfigurationResourceTypePrefix = "factorySet.oic.con";
-
-class FactorySetCollection
+class FactorySetResource : public ConfigurationResource
 {
 public:
-
-    ConfigurationCollection *defaultConfigurationCollection;
-
-public:
-
-    // diagnostics members
-    std::string m_factorySetUri;
-    std::string m_factorySetValue;
-    std::vector< std::string > m_factorySetTypes;
-    std::vector< std::string > m_factorySetInterfaces;
-    OCResourceHandle m_factorySetHandle;
-    OCRepresentation m_factorySetRep;
-
-    // Configuration members
-    std::string m_configurationCollectionUri;
-    std::string m_configurationCollectionLink;
-    std::vector< std::string > m_configurationCollectionTypes;
-    std::vector< std::string > m_configurationCollectionInterfaces;
-    OCResourceHandle m_configurationCollectionHandle;
-    OCRepresentation m_configurationCollectionRep;
-
-public:
     /// Constructor
-    FactorySetCollection() :
-            m_factorySetValue(defaultFactorySetValue), m_configurationCollectionLink(
-                    defaultConfigurationCollectionLink)
-    {
-        m_configurationCollectionUri = "/factorySet/0/con"; // URI of the resource
-        m_configurationCollectionTypes.push_back("factorySet.con"); // resource type name.
-        m_configurationCollectionInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-
-        m_configurationCollectionRep.setUri(m_configurationCollectionUri);
-        m_configurationCollectionRep.setResourceTypes(m_configurationCollectionTypes);
-        m_configurationCollectionRep.setResourceInterfaces(m_configurationCollectionInterfaces);
-        m_configurationCollectionRep.setValue("link", m_configurationCollectionLink);
-        m_configurationCollectionHandle = NULL;
-
-        m_factorySetUri = "/factorySet"; // URI of the resource
-        m_factorySetTypes.push_back("factorySet"); // resource type name.
-        m_factorySetInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_factorySetInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        m_factorySetInterfaces.push_back(LINK_INTERFACE); // resource interface.
-        m_factorySetRep.setValue("value", m_factorySetValue);
-        m_factorySetRep.setUri(m_factorySetUri);
-        m_factorySetRep.setResourceTypes(m_factorySetTypes);
-        m_factorySetRep.setResourceInterfaces(m_factorySetInterfaces);
-        m_factorySetHandle = NULL;
-
-        defaultConfigurationCollection = NULL;
-    }
-    ;
+    FactorySetResource();
 
-    ~FactorySetCollection()
-    {
-        if (defaultConfigurationCollection != NULL)
-            free(defaultConfigurationCollection);
-    }
-    ;
+    ~FactorySetResource();
 
     /// This function internally calls registerResource API.
     void createResources(ResourceEntityHandler callback);
-
     void setFactorySetRepresentation(OCRepresentation& rep);
-    void setConfigurationCollectionRepresentation(OCRepresentation& rep);
-
     OCRepresentation getFactorySetRepresentation();
-    OCRepresentation getConfigurationCollectionRepresentation();
-
-    std::string getFactorySetUri();
-    std::string getConfigurationCollectionUri();
 
+    std::string getUri();
 };
 
old mode 100644 (file)
new mode 100755 (executable)
index 33dcd5f..b768c08
@@ -33,6 +33,7 @@ linux_sample_env = lib_env.Clone()
 # Build flags
 ######################################################################
 linux_sample_env.AppendUnique(CPPPATH = ['include'])
+linux_sample_env.AppendUnique(CPPPATH = ['../../../../../extlibs/timer'])
 linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/inc'])
 linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/src'])
 linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
@@ -62,4 +63,3 @@ Alias("BootstrapServerApp", bootstrapserver)
 env.AppendTarget('ConServerApp')
 env.AppendTarget('ConClientApp')
 env.AppendTarget('BootstrapServerApp')
-
old mode 100644 (file)
new mode 100755 (executable)
index e53f61c..5bc8141
@@ -37,15 +37,11 @@ bool prepareResponse(std::shared_ptr< OCResourceRequest > request);
 OCStackResult sendResponse(std::shared_ptr< OCResourceRequest > pRequest);
 OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request);
 
-#define DefaultConfigurationValue "Configuration Collection"
-#define DefaultRegionValue "Seoul, Korea"
-#define DefaultTimeValue "Time Collection"
-#define DefaultCurrentTimeValue "00:00:00"
-#define DefaultNetworkValue "Network Collection"
-#define DefaultIPAddressValue "192.168.0.2"
-#define DefaultSecurityValue "SecurityValue"
-#define DefaultModeValue "NoSec"
-#define DefaultFactorySetValue "FactorySet Value"
+#define DefaultRegion "Seoul, Korea"
+#define DefaultSystemTime "00:00:00"
+#define DefaultLocation "37.256616, 127.052806"
+#define DefaultCurrency "Won"
+
 
 class BootstrapResource
 {
@@ -92,15 +88,10 @@ public:
 
     OCRepresentation getBootstrapRepresentation()
     {
-        m_bootstrapRep.setValue< std::string >("regionValue", DefaultRegionValue);
-        m_bootstrapRep.setValue< std::string >("timeValue", DefaultTimeValue);
-        m_bootstrapRep.setValue< std::string >("currentTimeValue", DefaultCurrentTimeValue);
-        m_bootstrapRep.setValue< std::string >("networkValue", DefaultNetworkValue);
-        m_bootstrapRep.setValue< std::string >("IPAddressValue", DefaultIPAddressValue);
-        m_bootstrapRep.setValue< std::string >("securityValue", DefaultSecurityValue);
-        m_bootstrapRep.setValue< std::string >("modeValue", DefaultModeValue);
-        m_bootstrapRep.setValue< std::string >("configurationValue", DefaultConfigurationValue);
-        m_bootstrapRep.setValue< std::string >("factorySetValue", DefaultFactorySetValue);
+        m_bootstrapRep.setValue< std::string >("r", DefaultRegion);
+        m_bootstrapRep.setValue< std::string >("st", DefaultSystemTime);
+        m_bootstrapRep.setValue< std::string >("loc", DefaultLocation);
+        m_bootstrapRep.setValue< std::string >("c", DefaultCurrency);
 
         return m_bootstrapRep;
     }
old mode 100644 (file)
new mode 100755 (executable)
index bdfc7cd..5099ae1
@@ -35,6 +35,8 @@ using namespace OIC;
 int g_Steps = 0;
 int isWaiting = 0; //0: none to wait, 1: wait for the response of "getConfigurationValue"
 
+const int SUCCESS_RESPONSE = 0;
+
 static ThingsManager* g_thingsmanager;
 
 OCResourceHandle configurationCollectionHandle;
@@ -62,61 +64,84 @@ typedef std::function<
 typedef std::string ConfigurationName;
 typedef std::string ConfigurationValue;
 
+void timeCheck(int timeSec)
+{
+    sleep(timeSec);
+    isWaiting = 0;
+}
+
 void onReboot(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
 {
-    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+    isWaiting = 0;
 
-    std::cout << "\t\tReboot:" << rep.getValue< std::string >("value") << std::endl;
+    if (eCode != SUCCESS_RESPONSE)
+    {
+        return ;
+    }
 
-    isWaiting = 0;
+    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+    std::cout << "\t\tReboot:" << rep.getValue< std::string >("value") << std::endl;
 }
 
 void onFactoryReset(const HeaderOptions& headerOptions, const OCRepresentation& rep,
         const int eCode)
 {
-    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+    isWaiting = 0;
+
+    if (eCode != SUCCESS_RESPONSE)
+    {
+       return ;
+    }
 
+    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
     std::cout << "\t\tFactoryReset:" << rep.getValue< std::string >("value") << std::endl;
-    isWaiting = 0;
 }
 
 void onUpdate(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
 {
-    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+    isWaiting = 0;
 
-    std::cout << "\t\tvalue:" << rep.getValue< std::string >("value") << std::endl;
+    if (eCode != SUCCESS_RESPONSE)
+    {
+        return ;
+    }
 
-    isWaiting = 0;
+    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+
+    if (rep.hasAttribute("loc"))
+        std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl;
+    if (rep.hasAttribute("st"))
+        std::cout << "\t\tSystemTime:" << rep.getValue< std::string >("st") << std::endl;
+    if (rep.hasAttribute("c"))
+        std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl;
+    if (rep.hasAttribute("r"))
+        std::cout << "\t\tRegion:" << rep.getValue< std::string >("r") << std::endl;
 }
 
 void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
 {
-    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
-    if (rep.hasAttribute("value"))
-        std::cout << "\t\tvalue:" << rep.getValue< std::string >("value") << std::endl;
-    else if (rep.hasAttribute("link"))
-        std::cout << "\t\tlink:" << rep.getValue< std::string >("link") << std::endl;
-
-    std::vector< OCRepresentation > children = rep.getChildren();
+    isWaiting = 0;
 
-    for (auto oit = children.begin(); oit != children.end(); ++oit)
+    if (eCode != SUCCESS_RESPONSE)
     {
-        std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
-
-        if (oit->hasAttribute("value"))
-            std::cout << "\t\tvalue:" << oit->getValue< std::string >("value") << std::endl;
-        else if (oit->hasAttribute("link"))
-            std::cout << "\t\tlink:" << oit->getValue< std::string >("link") << std::endl;
+        return ;
     }
 
-    isWaiting = 0;
+    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+
+    if (rep.hasAttribute("loc"))
+        std::cout << "\t\tLocation:" << rep.getValue< std::string >("loc") << std::endl;
+    if (rep.hasAttribute("st"))
+        std::cout << "\t\tSystemTime:" << rep.getValue< std::string >("st") << std::endl;
+    if (rep.hasAttribute("c"))
+        std::cout << "\t\tCurrency:" << rep.getValue< std::string >("c") << std::endl;
+    if (rep.hasAttribute("r"))
+        std::cout << "\t\tRegion:" << rep.getValue< std::string >("r") << std::endl;
 }
 
 // Callback to found collection resource
 void onFoundCollectionResource(std::vector< std::shared_ptr< OCResource > > resources)
 {
-
     std::string resourceURI;
     std::string hostAddress;
     try
@@ -153,20 +178,16 @@ void onFoundCollectionResource(std::vector< std::shared_ptr< OCResource > > reso
         //log(e.what());
     }
 
-    if (g_configurationCollection != NULL && g_diagnosticsCollection != NULL
-            && g_setCollection != NULL)
-        isWaiting = 0;
+    isWaiting = 0;
 }
 
 // Callback to found resources
-void onFoundCandidateCollection(std::vector< std::shared_ptr< OCResource > > resources)
+void onFoundCandidateResource(std::vector< std::shared_ptr< OCResource > > resources)
 {
 
     std::string resourceURI;
     std::string hostAddress;
 
-    static bool flagForCon = false, flagForDiag = false, flagForSet = false;
-
     try
     {
         // Do some operations with resource object.
@@ -194,7 +215,6 @@ void onFoundCandidateCollection(std::vector< std::shared_ptr< OCResource > > res
                     {
                         if (resource->uri() == "/oic/con")
                         {
-                            flagForCon = true;
                             OCPlatform::bindResource(configurationCollectionHandle,
                                     foundResourceHandle);
                             if (g_configurationResource == NULL)
@@ -202,7 +222,6 @@ void onFoundCandidateCollection(std::vector< std::shared_ptr< OCResource > > res
                         }
                         else if (resource->uri() == "/oic/diag")
                         {
-                            flagForDiag = true;
                             OCPlatform::bindResource(diagnosticsCollectionHandle,
                                     foundResourceHandle);
                             if (g_diagnosticsResource == NULL)
@@ -210,7 +229,6 @@ void onFoundCandidateCollection(std::vector< std::shared_ptr< OCResource > > res
                         }
                         else if (resource->uri() == "/factorySet")
                         {
-                            flagForSet = true;
                             OCPlatform::bindResource(setCollectionHandle, foundResourceHandle);
                             if (g_setResource == NULL)
                                 g_setResource = resource;
@@ -239,12 +257,12 @@ void onFoundCandidateCollection(std::vector< std::shared_ptr< OCResource > > res
         //log(e.what());
     }
 
-    if (flagForCon && flagForDiag && flagForSet)
-        isWaiting = 0;
+    isWaiting = 0;
 }
 
 int main(int argc, char* argv[])
 {
+    std::string str_steps;
 
     //**************************************************************
     // STEP 0
@@ -267,100 +285,96 @@ int main(int argc, char* argv[])
         cout << endl << endl << "(0) Quit" << std::endl;
         cout << "(1) Find all resources(URI: /oic/con, /oic/diag, /factoryset)" << std::endl;
         cout << "(2) Find all groups" << std::endl;
-        cout << "(3) Get a new value (of \"Configuration\" Collection)" << std::endl;
-        cout << "(4) Update a value (of \"Region\" Resource)" << std::endl;
-        cout << "(5) Get a value (for \"Region\" Resource)" << std::endl;
-        cout << "(6) FactoryReset (for the group)" << std::endl;
-        cout << "(7) Reboot (for the group)" << std::endl;
+        cout << "(3) Get a Configuration resource" << std::endl;
+        cout << "(4) Update a region attribute value" << std::endl;
+        cout << "(5) FactoryReset (for the group)" << std::endl;
+        cout << "(6) Reboot (for the group)" << std::endl;
         cout << "(10) Show Configuration Units" << std::endl;
 
-        cin >> g_Steps;
-        //
+        try
+        {
+            std::getline (std::cin, str_steps);
+
+            if(str_steps == "")
+                continue;
+            else
+                g_Steps = std::stoi(str_steps);
+        }
+        catch(std::invalid_argument&)
+        {
+            std::cout << "Please put a digit, not string" << std::endl;
+            continue;
+        }
+
         if (g_Steps == 0)
             break;
         else if (g_Steps == 1)
         {
             std::vector< std::string > types;
-            { // For Registering a collection resource for configuration resources
 
+            // For Registering a collection resource for configuration resources
+            if (configurationCollectionHandle == NULL)
+            {
                 string resourceURI = "/core/a/configuration/resourceset";
                 string resourceTypeName = "core.configuration.resourceset";
                 string resourceInterface = BATCH_INTERFACE;
 
-                if (configurationCollectionHandle != NULL)
-                {
-                    std::cout << "already exists" << std::endl;
-                    continue;
-                }
-
                 OCPlatform::registerResource(configurationCollectionHandle, resourceURI,
-                        resourceTypeName, resourceInterface, NULL,
-                        //&entityHandler, // entityHandler
-                        OC_DISCOVERABLE);
+                    resourceTypeName, resourceInterface, NULL,
+                    //&entityHandler, // entityHandler
+                    OC_DISCOVERABLE);
 
                 OCPlatform::bindInterfaceToResource(configurationCollectionHandle, GROUP_INTERFACE);
                 OCPlatform::bindInterfaceToResource(configurationCollectionHandle,
-                        DEFAULT_INTERFACE);
-
-                // instead of registration
-                types.push_back("oic.con");
-                std::cout << "Finding Configuration Resource... " << std::endl;
+                    DEFAULT_INTERFACE);
             }
 
-            { // For Registering a collection resource for diagnostics resources
-
+            // For Registering a collection resource for diagnostics resources
+            if (diagnosticsCollectionHandle == NULL)
+            {
                 string resourceURI = "/core/a/diagnostics/resourceset";
                 string resourceTypeName = "core.diagnostics.resourceset";
                 string resourceInterface = BATCH_INTERFACE;
 
-                if (diagnosticsCollectionHandle != NULL)
-                {
-                    std::cout << "already exists" << std::endl;
-                    continue;
-                }
-
                 OCPlatform::registerResource(diagnosticsCollectionHandle, resourceURI,
-                        resourceTypeName, resourceInterface, NULL,
-                        //&entityHandler, // entityHandler
-                        OC_DISCOVERABLE);
+                    resourceTypeName, resourceInterface, NULL,
+                    //&entityHandler, // entityHandler
+                    OC_DISCOVERABLE);
 
                 OCPlatform::bindInterfaceToResource(diagnosticsCollectionHandle, GROUP_INTERFACE);
                 OCPlatform::bindInterfaceToResource(diagnosticsCollectionHandle, DEFAULT_INTERFACE);
-
-                // instead of registration
-                types.push_back("oic.diag");
-                std::cout << "Finding Diagnostics Resource... " << std::endl;
-
             }
 
-            { // For Registering a collection resource for set resources
-
+            // For Registering a collection resource for set resources
+            if (setCollectionHandle == NULL)
+            {
                 string resourceURI = "/core/a/factoryset/resourceset";
                 string resourceTypeName = "core.factoryset.resourceset";
                 string resourceInterface = BATCH_INTERFACE;
 
-                if (setCollectionHandle != NULL)
-                {
-                    std::cout << "already exists" << std::endl;
-                    continue;
-                }
-
                 OCPlatform::registerResource(setCollectionHandle, resourceURI, resourceTypeName,
-                        resourceInterface, NULL,
-                        //&entityHandler, // entityHandler
-                        OC_DISCOVERABLE);
+                    resourceInterface, NULL,
+                    //&entityHandler, // entityHandler
+                    OC_DISCOVERABLE);
 
                 OCPlatform::bindInterfaceToResource(setCollectionHandle, GROUP_INTERFACE);
                 OCPlatform::bindInterfaceToResource(setCollectionHandle, DEFAULT_INTERFACE);
-
-                // instead of registration
-                types.push_back("factorySet");
-                std::cout << "Finding Set Resource... " << std::endl;
             }
 
-            g_thingsmanager->findCandidateResources(types, &onFoundCandidateCollection, 5);
+            types.push_back("oic.con");
+            types.push_back("oic.diag");
+            types.push_back("factorySet");
+
+            std::cout << "Finding Configuration Resource... " << std::endl;
+            std::cout << "Finding Diagnostics Resource... " << std::endl;
+            std::cout << "Finding Set Resource... " << std::endl;
+
+            g_thingsmanager->findCandidateResources(types, &onFoundCandidateResource, 5);
 
             isWaiting = 1;
+
+            thread t(&timeCheck, 5);
+            t.join();       // After 5 seconds, isWaiting value will be 0.
         }
         else if (g_Steps == 2) // make a group with found things
         {
@@ -372,30 +386,39 @@ int main(int argc, char* argv[])
             g_thingsmanager->findCandidateResources(types, &onFoundCollectionResource, 5);
 
             std::cout << "Finding Collection resource... " << std::endl;
+
             isWaiting = 1;
 
+            thread t(&timeCheck, 5);
+            t.join();       // After 5 seconds, isWaiting value will be 0.
         }
         else if (g_Steps == 3)
         {
             // get a value
 
-            ConfigurationName name = "configuration";
+            ConfigurationName name = "all";
 
-            std::cout << "For example, get configuration collection's value" << std::endl;
+            std::cout << "For example, get configuration resources's value" << std::endl;
 
             std::vector< ConfigurationName > configurations;
 
             configurations.push_back(name);
 
-            if (g_thingsmanager->getConfigurations(g_configurationResource, configurations, &onGet)
+            if (g_thingsmanager->getConfigurations(g_configurationCollection, configurations, &onGet)
                     != OC_STACK_ERROR)
                 isWaiting = 1;
         }
         else if (g_Steps == 4)
         {
-            ConfigurationName name = "region";
+            ConfigurationName name = "r";
             ConfigurationValue value = "U.S.A (new region)";
 
+            if(g_configurationCollection == NULL)
+            {
+                std::cout<<"Note that you first create a group to use this command." << std::endl;
+                continue;
+            }
+
             std::cout << "For example, change region resource's value" << std::endl;
             std::cout << g_configurationCollection->uri() << std::endl;
 
@@ -409,30 +432,26 @@ int main(int argc, char* argv[])
         }
         else if (g_Steps == 5)
         {
-            // get a value
-
-            ConfigurationName name = "region";
-
-            std::cout << "For example, get region resource's value" << std::endl;
-
-            std::vector< ConfigurationName > configurations;
-
-            configurations.push_back(name);
-
-            if (g_thingsmanager->getConfigurations(g_configurationCollection, configurations,
-                    &onGet) != OC_STACK_ERROR)
-                isWaiting = 1;
-        }
-        else if (g_Steps == 6)
-        {
             // factory reset
+            if(g_diagnosticsCollection == NULL)
+            {
+                std::cout<<"Note that you first create a group to use this command." << std::endl;
+                continue;
+            }
+
             if (g_thingsmanager->factoryReset(g_diagnosticsCollection, &onFactoryReset)
                     != OC_STACK_ERROR)
                 isWaiting = 1;
         }
-        else if (g_Steps == 7)
+        else if (g_Steps == 6)
         {
             // reboot
+            if(g_diagnosticsCollection == NULL)
+            {
+                std::cout<<"Note that you first create a group to use this command." << std::endl;
+                continue;
+            }
+
             if (g_thingsmanager->reboot(g_diagnosticsCollection, &onReboot) != OC_STACK_ERROR)
                 isWaiting = 1;
         }
@@ -447,4 +466,3 @@ int main(int argc, char* argv[])
     return 0;
 }
 
-
old mode 100644 (file)
new mode 100755 (executable)
index 402d2f4..bb68bfd
@@ -41,16 +41,11 @@ int isWaiting = 0;
 
 // Default system configuration value's variables
 // The variable's names should be same as the names of "extern" variables defined in
-// "ConfigurationCollection.h"
-std::string defaultRegionValue;
-std::string defaultTimeValue;
-std::string defaultCurrentTimeValue;
-std::string defaultNetworkValue;
-std::string defaultIPAddressValue;
-std::string defaultSecurityValue;
-std::string defaultModeValue;
-std::string defaultConfigurationValue;
-std::string defaultFactorySetValue;
+// "ConfigurationResource.h"
+std::string defaultLocation;
+std::string defaultRegion;
+std::string defaultSystemTime;
+std::string defaultCurrency;
 
 static ThingsManager* g_thingsmanager;
 
@@ -59,9 +54,9 @@ bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request);
 OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest);
 OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
 
-ConfigurationCollection *myConfigurationCollection;
-DiagnosticsCollection *myDiagnosticsCollection;
-FactorySetCollection *myFactorySetCollection;
+ConfigurationResource *myConfigurationResource;
+DiagnosticsResource *myDiagnosticsResource;
+FactorySetResource *myFactorySetResource;
 
 typedef std::function< void(OCRepresentation&) > putFunc;
 typedef std::function< OCRepresentation(void) > getFunc;
@@ -70,33 +65,15 @@ getFunc getGetFunction(std::string uri)
 {
     getFunc res = NULL;
 
-    if (uri == myConfigurationCollection->getTimeUri())
+    if (uri == myConfigurationResource->getUri())
     {
-        res = std::bind(&ConfigurationCollection::getTimeRepresentation, myConfigurationCollection);
+        res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
+                myConfigurationResource);
     }
-    else if (uri == myConfigurationCollection->getConfigurationUri())
+    else if (uri == myDiagnosticsResource->getUri())
     {
-        res = std::bind(&ConfigurationCollection::getConfigurationRepresentation,
-                myConfigurationCollection);
-    }
-    else if (uri == myConfigurationCollection->myTimeCollection->getCurrentTimeUri())
-    {
-        res = std::bind(&TimeCollection::getCurrentTimeRepresentation,
-                myConfigurationCollection->myTimeCollection);
-    }
-    else if (uri == myConfigurationCollection->getRegionUri())
-    {
-        res = std::bind(&ConfigurationCollection::getRegionRepresentation,
-                myConfigurationCollection);
-    }
-    else if (uri == myDiagnosticsCollection->getFactoryResetUri())
-    {
-        res = std::bind(&DiagnosticsCollection::getFactoryResetRepresentation,
-                myDiagnosticsCollection);
-    }
-    else if (uri == myDiagnosticsCollection->getRebootUri())
-    {
-        res = std::bind(&DiagnosticsCollection::getRebootRepresentation, myDiagnosticsCollection);
+        res = std::bind(&DiagnosticsResource::getDiagnosticsRepresentation,
+                myDiagnosticsResource);
     }
 
     return res;
@@ -106,25 +83,15 @@ putFunc getPutFunction(std::string uri)
 {
     putFunc res = NULL;
 
-    if (uri == myConfigurationCollection->getRegionUri())
-    {
-        res = std::bind(&ConfigurationCollection::setRegionRepresentation,
-                myConfigurationCollection, std::placeholders::_1);
-    }
-    else if (uri == myConfigurationCollection->myTimeCollection->getCurrentTimeUri())
+    if (uri == myConfigurationResource->getUri())
     {
-        res = std::bind(&TimeCollection::setCurrentTimeRepresentation,
-                myConfigurationCollection->myTimeCollection, std::placeholders::_1);
+        res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
+                myConfigurationResource, std::placeholders::_1);
     }
-    else if (uri == myDiagnosticsCollection->getFactoryResetUri())
+    else if (uri == myDiagnosticsResource->getUri())
     {
-        res = std::bind(&DiagnosticsCollection::setFactoryResetRepresentation,
-                myDiagnosticsCollection, std::placeholders::_1);
-    }
-    else if (uri == myDiagnosticsCollection->getRebootUri())
-    {
-        res = std::bind(&DiagnosticsCollection::setRebootRepresentation, myDiagnosticsCollection,
-                std::placeholders::_1);
+        res = std::bind(&DiagnosticsResource::setDiagnosticsRepresentation,
+                myDiagnosticsResource, std::placeholders::_1);
     }
 
     return res;
@@ -231,6 +198,8 @@ OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceReques
     std::cout << "\tIn Server CPP (entityHandlerForResource) entity handler:\n";
     OCEntityHandlerResult ehResult = OC_EH_ERROR;
 
+    QueryParamsMap test = request->getQueryParameters();
+
     if (prepareResponseForResource(request))
     {
         if (OC_STACK_OK == sendResponseForResource(request))
@@ -252,38 +221,27 @@ OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceReques
 // callback handler on GET request
 void onBootstrap(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
 {
-    if (eCode == SUCCESS_RESPONSE)
-    {
-        std::cout << "\n\nGET request was successful" << std::endl;
-        std::cout << "\tResource URI: " << rep.getUri() << std::endl;
-
-        defaultRegionValue = rep.getValue< std::string >("regionValue");
-        defaultTimeValue = rep.getValue< std::string >("timeValue");
-        defaultCurrentTimeValue = rep.getValue< std::string >("currentTimeValue");
-        defaultNetworkValue = rep.getValue< std::string >("networkValue");
-        defaultIPAddressValue = rep.getValue< std::string >("IPAddressValue");
-        defaultSecurityValue = rep.getValue< std::string >("securityValue");
-        defaultModeValue = rep.getValue< std::string >("modeValue");
-        defaultConfigurationValue = rep.getValue< std::string >("configurationValue");
-        defaultFactorySetValue = rep.getValue< std::string >("factorySetValue");
-
-        std::cout << "\tregionValue : " << defaultRegionValue << std::endl;
-        std::cout << "\ttimeValue : " << defaultTimeValue << std::endl;
-        std::cout << "\tcurrentTimeValue : " << defaultCurrentTimeValue << std::endl;
-        std::cout << "\tnetworkValue : " << defaultNetworkValue << std::endl;
-        std::cout << "\tIPAddressValue : " << defaultIPAddressValue << std::endl;
-        std::cout << "\tsecurityValue : " << defaultSecurityValue << std::endl;
-        std::cout << "\tmodeValue : " << defaultModeValue << std::endl;
-        std::cout << "\tconfigurationValue : " << defaultConfigurationValue << std::endl;
-        std::cout << "\tfactorySetValue : " << defaultFactorySetValue << std::endl;
+    isWaiting = 0;
 
-    }
-    else
+    if (eCode != SUCCESS_RESPONSE)
     {
         std::cout << "onGET Response error: " << eCode << std::endl;
-        std::exit(-1);
+        return ;
     }
-    isWaiting = 0;
+
+    std::cout << "\n\nGET request was successful" << std::endl;
+    std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+
+    defaultRegion = rep.getValue< std::string >("r");
+    defaultSystemTime = rep.getValue< std::string >("st");
+    defaultCurrency = rep.getValue< std::string >("c");
+    defaultLocation = rep.getValue< std::string >("loc");
+
+    std::cout << "\tLocation : " << defaultLocation << std::endl;
+    std::cout << "\tSystemTime : " << defaultSystemTime << std::endl;
+    std::cout << "\tCurrency : " << defaultCurrency << std::endl;
+    std::cout << "\tRegion : " << defaultRegion << std::endl;
+
 }
 
 int main()
@@ -332,17 +290,19 @@ int main()
             }
             else if (g_Steps == 2)
             {
-                myConfigurationCollection = new ConfigurationCollection();
-                myConfigurationCollection->createResources(&entityHandlerForResource);
+                myConfigurationResource = new ConfigurationResource();
+                myConfigurationResource->createResources(&entityHandlerForResource);
 
-                myDiagnosticsCollection = new DiagnosticsCollection();
-                myDiagnosticsCollection->createResources(&entityHandlerForResource);
+                myDiagnosticsResource = new DiagnosticsResource();
+                myDiagnosticsResource->createResources(&entityHandlerForResource);
+
+
+                myFactorySetResource = new FactorySetResource();
+                myFactorySetResource->createResources(&entityHandlerForResource);
+                myDiagnosticsResource->factoryReset = std::function < void()
+                        > (std::bind(&ConfigurationResource::factoryReset,
+                                myConfigurationResource));
 
-                myFactorySetCollection = new FactorySetCollection();
-                myFactorySetCollection->createResources(&entityHandlerForResource);
-                myDiagnosticsCollection->factoryReset = std::function < void()
-                        > (std::bind(&ConfigurationCollection::factoryReset,
-                                myConfigurationCollection));
                 isWaiting = 1;
             }
         }
@@ -356,4 +316,3 @@ int main()
     // When OCPlatform destructor is invoked, internally we do platform cleanup
 }
 
-
index bc2797d..3d550ce 100644 (file)
@@ -33,18 +33,17 @@ linux_sample_env = lib_env.Clone()
 # Build flags
 ######################################################################
 linux_sample_env.AppendUnique(CPPPATH = ['include'])
+linux_sample_env.AppendUnique(CPPPATH = ['../../../../../extlibs/timer'])
 linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/inc'])
 linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/src'])
-linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-DLINUX', '-pthread'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
-                                                                               'connectivity_abstraction',
-                                                                               'libcoap', 'liboc_logger', 'dl', 'pthread'])
-
+                                      'connectivity_abstraction',
+                                      'libcoap', 'liboc_logger', 'dl', 'pthread'])
 if env.get('SECURED') == '1':
-       linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-
+    linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
 linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
 
 # On some platforms link order can miss functions so librt needs to be
@@ -64,4 +63,3 @@ Alias("BookmarkApp", bookmark)
 env.AppendTarget('GroupServerApp')
 env.AppendTarget('LightServerApp')
 env.AppendTarget('BookmarkApp')
-
old mode 100644 (file)
new mode 100755 (executable)
index de8c84a..d7d7ca0
@@ -25,6 +25,8 @@
 #include <pthread.h>
 #include <iostream>
 
+#include "timer.h"
+
 #include <ThingsManager.h>
 
 using namespace std;
@@ -35,41 +37,46 @@ namespace PH = std::placeholders;
 bool isReady = false;
 
 OCResourceHandle resourceHandle;
-std::vector< OCResourceHandle > resourceHandleVector;
+std::vector<OCResourceHandle> resourceHandleVector;
 
-shared_ptr< OCResource > g_resource;
-vector< string > lights;
+shared_ptr<OCResource> g_resource;
+vector<string> lights;
 
 ThingsManager *thingsMgr = new ThingsManager();
 
-void onGet(const HeaderOptions& opt, const OCRepresentation &rep, const int eCode);
+void onGet(const HeaderOptions& opt, const OCRepresentation &rep,
+        const int eCode);
 
-void onPut(const HeaderOptions& headerOptions, 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 onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+        const int eCode);
 
-void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, const int& eCode,
-        const int& sequenceNumber);
+void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
+        const int& eCode, const int& sequenceNumber);
 
 void allBulbOn();
 void allBulbOff();
 
-void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResource)
+void foundResources(
+        std::vector<std::shared_ptr<OC::OCResource> > listOfResource)
 {
 
-    for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end(); ++rsrc)
+    for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end();
+            ++rsrc)
     {
         std::string resourceURI = (*rsrc)->uri();
         std::string hostAddress = (*rsrc)->host();
 
         if (resourceURI == "/a/light")
         {
-
             cout << "\tResource URI : " << resourceURI << endl;
             cout << "\tResource Host : " << hostAddress << endl;
 
             OCResourceHandle foundResourceHandle;
-            OCStackResult result = OCPlatform::registerResource(foundResourceHandle, (*rsrc));
+            OCStackResult result = OCPlatform::registerResource(
+                    foundResourceHandle, (*rsrc));
             cout << "\tresource registed!" << endl;
             if (result == OC_STACK_OK)
             {
@@ -88,7 +95,7 @@ void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResou
     isReady = true;
 }
 
-void foundResource(std::shared_ptr< OCResource > resource)
+void foundResource(std::shared_ptr<OCResource> resource)
 {
     std::string resourceURI;
     std::string hostAddress;
@@ -111,7 +118,8 @@ void foundResource(std::shared_ptr< OCResource > resource)
             }
             else if (resourceURI == "/core/bookmark")
             {
-                resource->observe(ObserveType::Observe, QueryParamsMap(), &onObserve);
+                resource->observe(ObserveType::Observe, QueryParamsMap(),
+                        &onObserve);
             }
 
             // p_platform.bindResource(resourceHandle, foundResourceHandle);
@@ -124,24 +132,28 @@ void foundResource(std::shared_ptr< OCResource > resource)
     }
 }
 
-void onGet(const HeaderOptions& opt, const OCRepresentation &rep, const int eCode)
+void onGet(const HeaderOptions& opt, const OCRepresentation &rep,
+        const int eCode)
 {
-    // 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;
-    // }
+    cout << "\nonGet" << endl;
+    if (eCode == OC_STACK_OK)
+        cout << "\tResult is OK." << endl;
+    else
+        cout << "\tInvalid parameter." << endl;
 }
 
-void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+        const int eCode)
 {
-    printf("\nonPut\n");
+    cout << "\nonPut" << endl;
+    if (eCode == OC_STACK_OK)
+        cout << "\tResult is OK." << endl;
+    else
+        cout << "\tInvalid parameter." << endl;
 }
 
-void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+        const int eCode)
 {
     printf("\nonPost\n");
 
@@ -154,17 +166,19 @@ void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, con
             ActionSet *actionset = thingsMgr->getActionSetfromString(plainText);
             if (actionset != NULL)
             {
-                cout << endl << "\tACTIONSET NAME :: " << actionset->actionsetName << endl;
+                cout << endl << "\tACTIONSET NAME :: "
+                        << actionset->actionsetName << endl;
                 for (auto actIter = actionset->listOfAction.begin();
                         actIter != actionset->listOfAction.end(); ++actIter)
                 {
                     cout << "\t\tTARGET :: " << (*actIter)->target << endl;
 
                     for (auto capaIter = (*actIter)->listOfCapability.begin();
-                            capaIter != (*actIter)->listOfCapability.end(); ++capaIter)
+                            capaIter != (*actIter)->listOfCapability.end();
+                            ++capaIter)
                     {
-                        cout << "\t\t\t" << (*capaIter)->capability << " :: " << (*capaIter)->status
-                                << endl;
+                        cout << "\t\t\t" << (*capaIter)->capability << " :: "
+                                << (*capaIter)->status << endl;
                     }
                 }
             }
@@ -195,7 +209,8 @@ void allBulbOff()
 
     if (g_resource)
     {
-        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(), &onPost);
+        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
+                &onPost);
     }
 }
 
@@ -207,12 +222,40 @@ void allBulbOn()
 
     if (g_resource)
     {
-        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(), &onPost);
+        g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
+                &onPost);
     }
 }
 
-void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, const int& eCode,
-        const int& sequenceNumber)
+void Scheduled_AllbulbOff()
+{
+    thingsMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
+}
+void Scheduled_AllbulbOffEx()
+{
+    thingsMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", 10, &onPost);
+}
+void CancelScheduled_AllBulbOff()
+{
+    thingsMgr->cancelActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
+}
+void Recursive_allBulbOn()
+{
+    thingsMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
+}
+void Recursive_allBulbOnEx()
+{
+    thingsMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", 10, &onPost);
+}
+
+void CancelRecursive_allBulbOn()
+{
+
+    thingsMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
+}
+
+void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
+        const int& eCode, const int& sequenceNumber)
 {
     if (eCode == OC_STACK_OK)
     {
@@ -259,18 +302,9 @@ void createActionSet_AllBulbOff()
         action->listOfCapability.push_back(capa);
         allBulbOff->listOfAction.push_back(action);
     }
-    // actionsetDesc = thingsMgr->getStringFromActionSet(allBulbOff);
-
-    // cout << "ActionSet :: " << actionsetDesc << endl;
-
-    // OCRepresentation rep;
-    // rep.setValue("ActionSet", actionsetDesc);
-
     if (g_resource)
     {
         thingsMgr->addActionSet(g_resource, allBulbOff, onPut);
-        // g_resource->put("a.collection", GROUP_INTERFACE, rep,
-        //     QueryParamsMap(), &onPut);
     }
 
     delete allBulbOff;
@@ -294,27 +328,96 @@ void createActionSet_AllBulbOn()
         action->listOfCapability.push_back(capa);
         allBulbOff->listOfAction.push_back(action);
     }
-    // actionsetDesc = thingsMgr->getStringFromActionSet(allBulbOff);
+    if (g_resource)
+    {
+        thingsMgr->addActionSet(g_resource, allBulbOff, onPut);
+    }
+
+    delete allBulbOff;
+}
 
-    // cout << "ActionSet :: " << actionsetDesc << endl;
+void createScheduledActionSet_AllBulbOff()
+{
+    string actionsetDesc;
+    ActionSet *allBulbOff = new ActionSet();
+    allBulbOff->type = OIC::ACTIONSET_TYPE::SCHEDULED;
+    allBulbOff->actionsetName = "AllBulbOffScheduledCall";
+
+    printf("ENTER(YYYY-MM-DD hh:mm:ss) :: ");
+    int res = scanf("%d-%d-%d %d:%d:%d", &allBulbOff->mTime.tm_year,
+            &allBulbOff->mTime.tm_mon, &allBulbOff->mTime.tm_mday,
+            &allBulbOff->mTime.tm_hour, &allBulbOff->mTime.tm_min,
+            &allBulbOff->mTime.tm_sec);
+    if( res < 0 )
+    {
+        printf("Invalid Input. try again.");
+        return;
+    }
+
+    allBulbOff->setDelay(allBulbOff->getSecondsFromAbsoluteTime());
+    printf("DELAY :: %ld\n", allBulbOff->getSecondsFromAbsoluteTime());
+
+    for (auto iter = lights.begin(); iter != lights.end(); ++iter)
+    {
+        Action *action = new Action();
+        action->target = (*iter);
 
-    // OCRepresentation rep;
-    // rep.setValue("ActionSet", actionsetDesc);
+        Capability *capa = new Capability();
+        capa->capability = "power";
+        capa->status = "off";
 
+        action->listOfCapability.push_back(capa);
+        allBulbOff->listOfAction.push_back(action);
+    }
     if (g_resource)
     {
         thingsMgr->addActionSet(g_resource, allBulbOff, onPut);
-        // g_resource->put("a.collection", GROUP_INTERFACE, rep,
-        //     QueryParamsMap(), &onPut);
     }
 
     delete allBulbOff;
 }
 
+void createRecursiveActionSet_AllBulbOn()
+{
+    string actionsetDesc;
+    ActionSet *allBulbOn = new ActionSet();
+    allBulbOn->type = OIC::ACTIONSET_TYPE::RECURSIVE;
+
+    allBulbOn->actionsetName = "AllBulbOnRecursiveCall";
+    allBulbOn->mTime.tm_year = 0;
+    allBulbOn->mTime.tm_mon = 0;
+    allBulbOn->mTime.tm_mday = 0;
+    allBulbOn->mTime.tm_hour = 0;
+    allBulbOn->mTime.tm_min = 0;
+    allBulbOn->mTime.tm_sec = 5;
+
+    allBulbOn->setDelay(allBulbOn->getSecAbsTime());
+
+    for (auto iter = lights.begin(); iter != lights.end(); ++iter)
+    {
+        Action *action = new Action();
+        action->target = (*iter);
+
+        Capability *capa = new Capability();
+        capa->capability = "power";
+        capa->status = "on";
+
+        action->listOfCapability.push_back(capa);
+        allBulbOn->listOfAction.push_back(action);
+    }
+    if (g_resource)
+    {
+        thingsMgr->addActionSet(g_resource, allBulbOn, onPut);
+    }
+
+    delete allBulbOn;
+}
+
 int main()
 {
     PlatformConfig config
-    { OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
+    { OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0,
+            OC::QualityOfService::LowQos };
 
     try
     {
@@ -324,14 +427,12 @@ int main()
         OCPlatform::Configure(config);
 
         // Find lights for group creation.
-        vector< string > types;
+        vector<string> types;
         types.push_back("core.light");
         thingsMgr->findCandidateResources(types, &foundResources, 5);
 
-        OCPlatform::registerResource(resourceHandle, resourceURI, resourceTypeName,
-                resourceInterface, NULL,
-                //&entityHandler, // entityHandler
-                OC_DISCOVERABLE);
+        OCPlatform::registerResource(resourceHandle, resourceURI,
+                resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE);
 
         cout << "registerResource is called." << endl;
 
@@ -347,81 +448,101 @@ int main()
                 int n;
 
                 cout << endl;
-                cout << "1 :: CREATE ACTIONSET 2 :: EXECUTE ACTIONSET(ALLBULBON)"
-                        << "3 :: EXECUTE ACTIONSET(ALLBULBOFF)" << endl;
-                cout << "4 :: GET ACTIONSET 5 :: DELETE ACTIONSET 6 :: QUIT" << endl;
-                cout << "9 :: FIND GROUP 0 :: FIND BOOKMARK TO OBSERVE" << endl;
+                cout << "1 :: CREATE ACTIONSET" << endl;
+                cout << "2 :: EXECUTE ACTIONSET(ALLBULBON)" << endl;
+                cout << "3 :: EXECUTE ACTIONSET(ALLBULBOFF)" << endl;
+                cout << "4 :: CREATE ACTIONSET(R_ALLBULBON)" << endl;
+                cout << "\t41 :: EXECUTE ACTIONSET 42 :: CANCEL ACTIONSET" << endl;
+                cout << "5 :: CREATE ACTIONSET(S_ALLBULBON)" << endl;
+                cout << "\t51 :: EXECUTE ACTIONSET 52 :: CANCEL ACTIONSET" << endl;
+                cout << "6 :: GET ACTIONSET" << endl;
+                cout << "7 :: DELETE ACTIONSET" << endl;
+                cout << "8 :: QUIT" << endl;
+                cout << "9 :: FIND GROUP" << endl;
+                cout << "0 :: FIND BOOKMARK TO OBSERVE"
+                        << endl;
 
                 fflush(stdin);
                 cin >> n;
 
                 if (n == 9)
                 {
-                    std::string requestURI = OC_WELL_KNOWN_QUERY;
-                    requestURI += "?rt=a.collection";
-
-                    OCPlatform::findResource("", requestURI, OC_WIFI, &foundResource);
+                    OCPlatform::findResource("",
+                            "coap://224.0.1.187/oc/core?rt=a.collection",
+                            OC_ETHERNET,
+                            &foundResource);
+                    OCPlatform::findResource("",
+                            "coap://224.0.1.187/oc/core?rt=a.collection",
+                            OC_WIFI,
+                            &foundResource);
                 }
                 else if (n == 0)
                 {
-                    std::string requestURI = OC_WELL_KNOWN_QUERY;
-                    requestURI += "?rt=core.bookmark";
-
-                    OCPlatform::findResource("", requestURI, OC_WIFI, &foundResource);
+                    OCPlatform::findResource("",
+                            "coap://224.0.1.187/oc/core?rt=core.bookmark",
+                            OC_ETHERNET,
+                            &foundResource);
+                    OCPlatform::findResource("",
+                            "coap://224.0.1.187/oc/core?rt=core.bookmark",
+                            OC_WIFI,
+                            &foundResource);
                 }
                 else if (n == 1)
                 {
-
-                    // Craete Action Set
-                    // "AllBulbOff"
-                    //"movieTime*uri=coap://10.251.44.228:49858/a/light|power=10";
                     createActionSet_AllBulbOff();
                     createActionSet_AllBulbOn();
-
                 }
                 else if (n == 2)
                 {
-
                     allBulbOn();
-                    // thingsMgr->executeActionSet(g_resource, "AllBulbOn", onPost);
-
                 }
                 else if (n == 3)
                 {
-
                     allBulbOff();
-                    // thingsMgr->executeActionSet(g_resource, "AllBulbOff", onPost);
-
                 }
                 else if (n == 4)
                 {
-                    // OCRepresentation rep;
-
-                    // rep.setValue("GetActionSet", std::string("AllBulbOff"));
-
-                    // if(g_resource)
-                    // {
-                    //     g_resource->post("a.collection", GROUP_INTERFACE, rep,
-                    //         QueryParamsMap(), &onPost);
-                    // }
-
-                    thingsMgr->getActionSet(g_resource, "AllBulbOff", onPost);
+                    createRecursiveActionSet_AllBulbOn();
+                }
+                else if (n == 41)
+                {
+                    Recursive_allBulbOn();
+                }
+                else if (n == 42)
+                {
+                    CancelRecursive_allBulbOn();
+                }
+                // Exampel of
+                else if (n == 43)
+                {
+                    Recursive_allBulbOnEx();
                 }
                 else if (n == 5)
                 {
-                    // OCRepresentation rep;
-
-                    // rep.setValue("DelActionSet", std::string("AllBulbOff"));
-
-                    // if(g_resource)
-                    // {
-                    //     g_resource->put("a.collection", GROUP_INTERFACE, rep,
-                    //         QueryParamsMap(), &onPut);
-                    // }
-                    thingsMgr->deleteActionSet(g_resource, "AllBulbOff", onPut);
+                    createScheduledActionSet_AllBulbOff();
+                }
+                else if (n == 51)
+                {
+                    Scheduled_AllbulbOff();
+                }
+                else if (n == 52)
+                {
+                    CancelScheduled_AllBulbOff();
+                }
+                else if (n == 53)
+                {
+                    Scheduled_AllbulbOffEx();
                 }
                 else if (n == 6)
                 {
+                    thingsMgr->getActionSet(g_resource, "AllBulbOff", onPost);
+                }
+                else if (n == 7)
+                {
+                    thingsMgr->deleteActionSet(g_resource, "AllBulbOff", onPut);
+                }
+                else if (n == 8)
+                {
                     isRun = false;
                     break;
                 }
@@ -430,9 +551,8 @@ int main()
     }
     catch (OCException& e)
     {
-
+        cout << "ERROR :: " << e.reason() << endl;
     }
 
     return 0;
 }
-
index 9800124..2a6546f 100644 (file)
@@ -1,23 +1,3 @@
-#******************************************************************
-#
-# 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.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
 ##
 # linux sample app  build script
 ##
@@ -33,20 +13,20 @@ linux_sample_env = lib_env.Clone()
 # Build flags
 ######################################################################
 linux_sample_env.AppendUnique(CPPPATH = ['include'])
+linux_sample_env.AppendUnique(CPPPATH = ['../../../../../extlibs/timer'])
 linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/inc'])
 linux_sample_env.AppendUnique(CPPPATH = ['../../../sdk/src'])
-linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-DLINUX', '-pthread'])
 linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
 linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
-                                        'connectivity_abstraction',
-                                        'libcoap', 'liboc_logger', 'dl', 'pthread'])
-
+                                      'connectivity_abstraction',
+                                      'libcoap', 'liboc_logger', 'dl', 'pthread'])
 if env.get('SECURED') == '1':
-       linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-
+    linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
 linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
 
+
 # On some platforms link order can miss functions so librt needs to be
 # re-scanned at the end if present. gcc 4.6 is one with this issue.
 if 'rt' in linux_sample_env.get('LIBS'):
@@ -67,4 +47,3 @@ env.AppendTarget('GroupApp')
 env.AppendTarget('MusicplayerApp')
 env.AppendTarget('PhoneApp')
 env.AppendTarget('SpeakerApp')
-
index 67cdee0..8965c4b 100644 (file)
@@ -113,10 +113,16 @@ int main(int argc, char* argv[])
             }
             else if (selectedMenu == 11)
             {
-                std::string requestURI = OC_WELL_KNOWN_QUERY;
-                requestURI += "?rt=core.musicplayer";
+                result = OCPlatform::findResource("",
+                            "coap://224.0.1.187/oc/core?rt=core.musicplayer",
+                            OC_ETHERNET,
+                            onFindResource);
+
+                result = OCPlatform::findResource("",
+                            "coap://224.0.1.187/oc/core?rt=core.musicplayer",
+                            OC_WIFI,
+                            onFindResource);
 
-                result = OCPlatform::findResource("", requestURI, OC_WIFI, onFindResource);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Finding music player was successful\n";
@@ -128,10 +134,16 @@ int main(int argc, char* argv[])
             }
             else if (selectedMenu == 12)
             {
-                std::string requestURI = OC_WELL_KNOWN_QUERY;
-                requestURI += "?rt=core.speaker";
+                result = OCPlatform::findResource("", 
+                            "coap://224.0.1.187/oc/core?rt=core.speaker",
+                            OC_ETHERNET,
+                            onFindResource);
+                
+                result = OCPlatform::findResource("", 
+                            "coap://224.0.1.187/oc/core?rt=core.speaker",
+                            OC_WIFI,
+                            onFindResource);
 
-                result = OCPlatform::findResource("", requestURI, OC_WIFI, onFindResource);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Finding speaker was successful\n";
@@ -231,4 +243,3 @@ int main(int argc, char* argv[])
     return 0;
 }
 
-
index 57494d0..177399d 100644 (file)
@@ -433,7 +433,7 @@ int main(int argc, char* argv[])
                     continue;
                 }
 
-                result = gThingManager->leaveGroup(collectionResourceType, gPhoneResourceHandle);
+                result = gThingManager->leaveGroup(gFindGroup, collectionResourceType,  gPhoneResourceHandle);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Leaving group was successful\n";
old mode 100644 (file)
new mode 100755 (executable)
index 0deba88..7c95953
 
 #include <string>
 #include <vector>
+#include <cstdio>
+#include <iostream>
+
+#include <ctime>
+
+#include <timer.h>
 
 using namespace std;
 
-namespace OIC{
-       class Capability
-    {
-    public:
-        std::string capability;
-        std::string status;
-    };
+namespace OIC
+{
+enum ACTIONSET_TYPE
+{
+    NONE = 0, SCHEDULED, RECURSIVE
+};
+
+typedef tm OCTime;
+
+/**
+ * @class      Time
+ * @brief      This class provides time-related information used for scheduled/recursive group action
+ *          features. Along with time-related variables, it also provides various useful functionality
+ *          including translating time to second unit
+ */
+class Time
+{
+public:
+    /**
+     * Constructor for Time
+     */
+    Time();
+    /**
+     * Virtual destructor for Time
+     */
+    ~Time();
+
+    /** @brief a unit of second.*/
+    long int mDelay;
+    /** @brief time information in structure tm.*/
+    OCTime mTime;
+    /** @brief flag to indicate group action type(NONE, SCHEDULED, RECURSIVE).*/
+    ACTIONSET_TYPE type;
+
+    void setTime(OCTime t);
+    void setTime(unsigned int yy, unsigned int mm, unsigned int dd,
+            unsigned int h, unsigned int m, unsigned int s,
+            int dayoftheweek);
+    void setDayOfWeekForRecursive(int day);
+    unsigned int getYear();
+    unsigned int getMonth();
+    unsigned int getDay();
+    unsigned int getHour();
+    unsigned int getMin();
+    unsigned int getSec();
+    long int getSecondsFromAbsoluteTime();
+    long int getSecAbsTime();
+    long int getSecondsForWeeklySchedule();
+    void setDelay(long int seconds);
+    std::string toString() const;
+};
+
+/**
+ * @class      Capability
+ * @brief      This class provides a structure to help developers to easily specify a unit of attribute
+ *          key-value pair which corresponds to action.
+ */
+class Capability
+{
+public:
+    /** @brief This corresponds with attribute key.*/
+    std::string capability;
+    /** @brief This corresponds with attribute value.*/
+    std::string status;
+};
 
-    class Action
-    {
-    public:
-        Action() :
-                target("")
-        {
-        }
-        ~Action()
-        {
-            listOfCapability.clear();
-        }
-        std::string target;
+/**
+ * @class      Action
+ * @brief      This class provides a structure to help developers to easily specify an action which a
+ *          target resource have to do for.
+ */
+class Action
+{
+public:
+    /**
+     * Constructor for Action
+     */
+    Action();
+    /**
+     * Virtual destructor for Action
+     */
+    ~Action();
 
-        std::vector< Capability* > listOfCapability;
-    };
+    /** @brief This is a target URL of this action. It includes IP address, port, and resource URI.*/
+    std::string target;
+    /** @brief This is a list of capabilites.*/
+    std::vector<Capability*> listOfCapability;
+};
 
-    class ActionSet
-    {
-    public:
-        ActionSet() :
-                actionsetName("")
-        {
-        }
-        ~ActionSet()
-        {
-            listOfAction.clear();
-        }
-        std::string actionsetName;
+/**
+ * @class      ActionSet
+ * @brief      This class provides a structure to help developers to easily specify group action.
+ */
+class ActionSet: public Time
+{
+public:
+    /**
+     * Constructor for ActionSet
+     */
+    ActionSet();
+    /**
+     * Virtual destructor for ActionSet
+     */
+    ~ActionSet();
 
-        std::vector< Action* > listOfAction;
-    };
+    /** @brief a name of group action */
+    std::string actionsetName;
+    /** @brief a list of actions composing group action */
+    std::vector<Action*> listOfAction;
+};
 }
-#endif 
+#endif
old mode 100644 (file)
new mode 100755 (executable)
index 4c5ff34..1aa9465
@@ -74,7 +74,7 @@ namespace OIC
          */
         OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
                 std::function< void(std::vector< std::shared_ptr< OCResource > >) > callback,
-                int waitsec = -1);
+                int waitsec);
 
         /**
          * API for subscribing child's state.
@@ -91,10 +91,10 @@ namespace OIC
                 std::function< void(std::string, OCStackResult) > callback);
 
         /**
-         * API for register and bind resource to group.
+         * API for registering and binding resource to group.
          *
          * @param childHandle - child resource handle. It will be filled from resource param.
-         * @param resource - resource for register and bind to group. It has all data.
+         * @param resource - resource for registering and binding to group. It has all data.
          * @param collectionHandle - collection resource handle. It will be added child resource.
          *
          * @return OCStackResult - return value of this API.
@@ -119,8 +119,8 @@ namespace OIC
          * @return OCStackResult - return value of this API.
          *                         It returns OC_STACK_OK if success.
          *
-         * NOTE: It return OC_STACK ERROR when It was finding a group.
-         *       You should call this api when the group finding process has stopped.
+         * NOTE: It return OC_STACK ERROR when it is already finding a group.
+         *       You should call this api after the group finding process has stopped.
          *       OCStackResult is defined in ocstack.h.
          */
         OCStackResult findGroup(std::vector< std::string > collectionResourceTypes,
@@ -190,6 +190,24 @@ namespace OIC
                 OCResourceHandle resourceHandle);
 
         /**
+         * API for leaving a joined group.
+         *
+         * @param resource - group resource pointer to join.
+         *                   It can be the callback result of findGroup().
+         *
+         * @param collectionResourceType - resource type of a group to leave.
+         * @param resourceHandle - resource handle to leave a group.
+         *
+         * @return OCStackResult - return value of this API.
+         *                         It returns OC_STACK_OK if success.
+         *
+         * NOTE: OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult leaveGroup(const std::shared_ptr< OCResource > resource,
+                        std::string collectionResourceType,
+                        OCResourceHandle resourceHandle);
+
+        /**
          * API for deleting a group.
          *
          * @param collectionResourceType - resource type of a group to delete.
@@ -201,12 +219,10 @@ namespace OIC
         /**
          * API for getting a list of joined groups.
          *
-         * @param void
-         *
          * @return std::map - return value of this API.
          *                  It returns group resource type and group resource handle as a map type.
          */
-        std::map< std::string, OCResourceHandle > getGroupList(void);
+        std::map< std::string, OCResourceHandle > getGroupList();
 
         // Things Configuration
 
@@ -226,8 +242,8 @@ namespace OIC
          * function, which provides the list in JSON format.
          *
          * @param resource - resource pointer representing the target group or the single thing.
-         * @param configurations - ConfigurationUnit: a nickname of attribute of target resource
-         *                         (e.g., installedlocation, currency, (IP)address)
+         * @param configurations - ConfigurationUnit: an attribute key of target resource.
+         *                         (e.g., loc, st, c, r)
          *                         Value : a value to be updated
          * @param callback - callback for updateConfigurations.
          *
@@ -248,7 +264,7 @@ namespace OIC
          * Callback is called when a response arrives.
          *
          * @param resource - resource pointer representing the target group or the single thing.
-         * @param configurations - ConfigurationUnit: a nickname of attribute of target resource.
+         * @param configurations - ConfigurationUnit: an attribute key of target resource.
          * @param callback - callback for getConfigurations.
          *
          * @return OCStackResult - return value of this API.
@@ -263,7 +279,7 @@ namespace OIC
                                 const int eCode) > callback);
 
         /**
-         * API for showing the list of supported configuration units (configurable parameters)
+         * API for showing the list of supported configuration units (attribute keys)
          * Callback is called when a response arrives.
          *
          * @param void
@@ -274,7 +290,7 @@ namespace OIC
 
         /**
          * API for boostrapping system configuration parameters from a bootstrap server.
-         * Callback call when a response from the bootstrap server arrives.
+         * Callback is called when a response from the bootstrap server arrives.
          *
          * @param callback - callback for doBootstrap.
          *
@@ -329,21 +345,21 @@ namespace OIC
         // Group Action.
 
         /**
-         * API for extracting Action Set string from the Action Set class instance
+         * API for extracting an action set string from the ActionSet class instance
          *
-         * @param newActionSet - pointer of Action Set
+         * @param newActionSet - pointer of ActionSet class instance
          *
          * @return std::string - return value of this API.
-         *                                          It returns Action Set String.
+         *                                          It returns an action set String.
          *
          * NOTE: OCStackResult is defined in ocstack.h.
          */
         std::string getStringFromActionSet(const ActionSet *newActionSet);
 
         /**
-         * API for extrracting Action Set class instance from Action Set String.
+         * API for extrracting ActionSet class instance from an action set string.
          *
-         * @param desc - description of Action set
+         * @param desc - description of an action set string
          *
          * @return ActionSet* - return value of this API.
          *                      It returns pointer of ActionSet.
@@ -351,11 +367,11 @@ namespace OIC
         ActionSet* getActionSetfromString(std::string desc);
 
         /**
-         * API for adding an Action Set.
+         * API for adding an action set.
          * Callback is called when the response of PUT operation arrives.
          *
          * @param resource - resource pointer of the group resource
-         * @param newActionSet - pointer of Action Set
+         * @param newActionSet - pointer of ActionSet class instance
          * @param callback - callback for PUT operation.
          *
          * @return OCStackResult - return value of this API.
@@ -367,11 +383,11 @@ namespace OIC
                 const ActionSet* newActionSet, PutCallback cb);
 
         /**
-         * API for executing the Action Set.
+         * API for executing an existing action set.
          * Callback is called when the response of  POST operation arrives.
          *
          * @param resource - resource pointer of the group resource
-         * @param actionsetName - Action Set name for executing the Action set
+         * @param actionsetName - the action set name for executing the action set
          * @param callback - callback for POST operation.
          *
          * @return OCStackResult - return value of this API.
@@ -383,11 +399,43 @@ namespace OIC
                 std::string actionsetName, PostCallback cb);
 
         /**
-         * API for reading the Action Set.
-         * Callback is called when the response of  GET operation arrives.
+         * API for executing an existing action set.
+         * Callback is called when the response of  POST operation arrives.
+         *
+         * @param resource - resource pointer of the group resource
+         * @param actionsetName - the action set name for executing the action set
+         * @param delay - waiting time for until the action set run.
+         * @param callback - callback for POST operation.
+         *
+         * @return OCStackResult - return value of this API.
+         *                         It returns OC_STACK_OK if success.
+         *
+         * NOTE: OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
+                std::string actionsetName, long int delay, PostCallback cb);
+
+        /**
+         * API for canceling an existing action set.
+         * Callback is called when the response of POST operation arrives.
+         *
+         * @param resource - resource pointer of the group resource
+         * @param actionsetName - the action set name for executing the action set
+         * @param callback - callback for POST operation.
+         *
+         * @return OCStackResult - return value of this API.
+         *                         It returns OC_STACK_OK if success.
+         *
+         * NOTE: OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
+                std::string actionsetName, PostCallback cb);
+        /**
+         * API for reading an existing action set.
+         * Callback is called when the response of GET operation arrives.
          *
          * @param resource - resource pointer of the group resource
-         * @param actionsetName - Action Set name for reading the Action set
+         * @param actionsetName - the action set name for reading the action set
          * @param callback - callback for GET operation.
          *
          * @return OCStackResult - return value of this API.
@@ -399,11 +447,11 @@ namespace OIC
                 std::string actionsetName, GetCallback cb);
 
         /**
-         * API for removing the Action Set.
+         * API for removing an existing action set.
          * Callback is called when the response of  POST operation arrives.
          *
          * @param resource - resource pointer of the group resource
-         * @param actionsetName - Action Set name for removing the Action set
+         * @param actionsetName - the action set name for removing the action set
          * @param callback - callback for POST operation.
          *
          * @return OCStackResult - return value of this API.
diff --git a/service/things-manager/sdk/src/ActionSet.cpp b/service/things-manager/sdk/src/ActionSet.cpp
new file mode 100755 (executable)
index 0000000..910a5e6
--- /dev/null
@@ -0,0 +1,165 @@
+//******************************************************************
+//
+// 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 "ActionSet.h"
+using namespace std;
+
+namespace OIC
+{
+Time::Time()
+{
+    setTime(0, 0, 0, 0, 0, 0, 0);
+}
+
+Time::~Time()
+{
+}
+
+void Time::setTime(OCTime t)
+{
+    mTime = t;
+}
+void Time::setTime(unsigned int yy, unsigned int mm, unsigned int dd,
+        unsigned int h, unsigned int m, unsigned int s,
+        int dayoftheweek = 0)
+{
+    yy -= 1900;
+    mm -= 1;
+
+    mDelay = 0;
+    mTime.tm_year = yy;
+    mTime.tm_mon = mm;
+    mTime.tm_mday = dd;
+
+    mTime.tm_hour = h;
+    mTime.tm_min = m;
+    mTime.tm_sec = s;
+
+    mTime.tm_wday = (unsigned int) dayoftheweek;
+    type = NONE;
+}
+void Time::setDayOfWeekForRecursive(int day)
+{
+    if (day != -1)
+        type = RECURSIVE;
+    else
+        return;
+
+    setTime(0, 0, 0, 0, 0, 0, day);
+}
+unsigned int Time::getYear()
+{
+    return mTime.tm_year;
+}
+unsigned int Time::getMonth()
+{
+    return mTime.tm_mon;
+}
+unsigned int Time::getDay()
+{
+    return mTime.tm_mday;
+}
+unsigned int Time::getHour()
+{
+    return mTime.tm_hour;
+}
+unsigned int Time::getMin()
+{
+    return mTime.tm_min;
+}
+unsigned int Time::getSec()
+{
+    return mTime.tm_sec;
+}
+long int Time::getSecondsFromAbsoluteTime()
+{
+    if(mTime.tm_year > 1900)
+        mTime.tm_year -= 1900;
+
+    mTime.tm_mon -= 1;
+
+    return getSecondsFromAbsTime(&mTime);
+}
+long int Time::getSecAbsTime()
+{
+    return getSeconds(&mTime);
+}
+long int Time::getSecondsForWeeklySchedule()
+{
+    if(mTime.tm_year > 1900)
+        mTime.tm_year -= 1900;
+
+    mTime.tm_mon -= 1;
+    return getRelativeIntervalOfWeek(&mTime);
+}
+
+void Time::setDelay(long int seconds)
+{
+    if(type != NONE)
+    {
+        mDelay = seconds;
+    }
+}
+
+std::string Time::toString() const
+{
+    char temp[25] = { 0 };
+    // It is shown format which required of scheduled/recursive group action time.
+    // " [delay] [type of actionset] "
+    snprintf(temp, sizeof(temp) / sizeof(char),
+            "%ld %d", mDelay, (unsigned int) type);
+    return std::string(temp);
+}
+
+
+
+
+
+
+
+
+
+
+Action::Action() :
+        target("")
+{
+}
+Action::~Action()
+{
+    listOfCapability.clear();
+}
+
+
+
+
+
+
+
+
+
+ActionSet::ActionSet() :
+        actionsetName("")
+{
+}
+ActionSet::~ActionSet()
+{
+    listOfAction.clear();
+}
+}
old mode 100644 (file)
new mode 100755 (executable)
index 5e52e06..494cd91
@@ -4,7 +4,7 @@
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 //
-// Licensed under the Apache License, Version 2.0 (the "License");
+// 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
 //
@@ -36,9 +36,8 @@
 #define ATTR_DELIMITER "="
 
 using namespace OC;
+using namespace OIC;
 
-namespace OIC
-{
 std::map< std::vector< std::string >, CandidateCallback > candidateRequest;
 std::map< std::vector< std::string >, CandidateCallback > candidateRequestForTimer;
 std::map< std::string, std::map< std::string, std::shared_ptr< OCResource > > > rtForResourceList;
@@ -194,7 +193,8 @@ void GroupManager::lazyCallback(int second)
 
 }
 
-OCStackResult GroupManager::findCandidateResources(std::vector< std::string > resourceTypes,
+OCStackResult GroupManager::findCandidateResources(
+        std::vector< std::string > resourceTypes,
         CandidateCallback callback, int waitsec)
 {
     if (resourceTypes.size() < 1)
@@ -221,15 +221,24 @@ OCStackResult GroupManager::findCandidateResources(std::vector< std::string > re
 
     for (unsigned int i = 0; i < resourceTypes.size(); ++i)
     {
-        std::cout << "resourceTypes : " << resourceTypes.at(i) << std::endl;
+        // std::cout << "resourceTypes : " << resourceTypes.at(i) << std::endl;
         std::string query = OC_WELL_KNOWN_QUERY;
-        query += "?rt=";
-        query += resourceTypes.at(i);
+        query.append("?rt=");
+        query.append(resourceTypes.at(i));
+
+        OCPlatform::findResource("", 
+                query,
+                OC_ETHERNET,
+                std::function < void(std::shared_ptr < OCResource > resource)
+                        > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
+                                waitsec)));
 
-        OCPlatform::findResource("", query, OC_WIFI,
+        OCPlatform::findResource("", 
+                query,
+                OC_WIFI,
                 std::function < void(std::shared_ptr < OCResource > resource)
-                > (std::bind(&GroupManager::onFoundResource, this,
-                        std::placeholders::_1, waitsec)));
+                        > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
+                                waitsec)));
     }
 
     if (waitsec >= 0)
@@ -316,7 +325,6 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
      }
      */
     std::vector< OCRepresentation > children = rep.getChildren();
-
     if(children.size() == 0 )
     {
         callback("", OC_STACK_ERROR);
@@ -325,7 +333,7 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
 
     for (auto oit = children.begin(); oit != children.end(); ++oit)
     {
-        std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
+        // std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
         std::vector< std::string > hostAddressVector = str_split(oit->getUri(), '/');
         std::string hostAddress = "";
         for (unsigned int i = 0; i < hostAddressVector.size(); ++i)
@@ -341,19 +349,23 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
         }
 
         std::vector< std::string > resourceTypes = oit->getResourceTypes();
-        for (unsigned int i = 0; i < resourceTypes.size(); ++i)
-        {
-            std::cout << "\t\t\tresourcetype :" << resourceTypes.at(i) << std::endl;
-        }
-
-        std::string resourceType = "core.";
-        resourceType.append(str_split(oit->getUri(), '/').at(4));
-        std::cout << "\t\tconvertRT : " << resourceType << std::endl;
-        std::cout << "\t\thost : " << hostAddress << std::endl;
+        // for (unsigned int i = 0; i < resourceTypes.size(); ++i)
+        // {
+        //     std::cout << "\t\t\tresourcetype :" << resourceTypes.at(i) << std::endl;
+        // }
+
+        // std::string resourceType = "core.";
+        // resourceType.append(str_split(oit->getUri(), '/').at(4));
+        // std::cout << "\t\tconvertRT : " << resourceType << std::endl;
+        // std::cout << "\t\tresource type front : " << resourceTypes.front() << endl;
+        // std::cout << "\t\thost : " << hostAddress << std::endl;
         OCPlatform::OCPresenceHandle presenceHandle;
+        OCStackResult result = OC_STACK_ERROR;
 
-        OCStackResult result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
-                resourceType, OC_WIFI,
+        result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
+                // resourceType,
+                resourceTypes.front(),
+                OC_WIFI,
                 std::function<
                         void(OCStackResult result, const unsigned int nonce,
                                 const std::string& hostAddress) >(
@@ -363,14 +375,12 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
 
         if (result == OC_STACK_OK)
         {
-            std::cout << "\t\tOK!" << std::endl;
             presenceCallbacks.insert(std::make_pair(oit->getUri(), callback));
         }
         else
         {
             callback("", OC_STACK_ERROR);
         }
-
     }
 }
 
@@ -399,7 +409,7 @@ OCStackResult GroupManager::subscribeCollectionPresence(
     {
         return OC_STACK_ERROR;
     }
-
+    
     OCStackResult result = OC_STACK_OK;
     //callback("core.room",OC_STACK_OK);
 
@@ -429,6 +439,8 @@ std::string GroupManager::getStringFromActionSet(const ActionSet *newActionSet)
 
     message = newActionSet->actionsetName;
     message.append("*");
+    message.append(newActionSet->toString());
+    message.append("*");
     for (auto iterAction = newActionSet->listOfAction.begin();
             iterAction != newActionSet->listOfAction.end(); iterAction++)
     {
@@ -468,7 +480,6 @@ std::string GroupManager::getStringFromActionSet(const ActionSet *newActionSet)
 
 ActionSet* GroupManager::getActionSetfromString(std::string description)
 {
-
     char *token = NULL;
     char *plainText = NULL;
     char *plainPtr = NULL;
@@ -476,6 +487,16 @@ ActionSet* GroupManager::getActionSetfromString(std::string description)
 
     Capability *capa = NULL;
     ActionSet *actionset = new ActionSet();
+
+    if(description.empty())
+    {
+        goto exit;
+    }
+    else if(description.at(0) == '*')
+    {
+        goto exit;
+    }
+
     plainText = new char[(description.length() + 1)];
     strcpy(plainText, description.c_str());
 
@@ -495,6 +516,17 @@ ActionSet* GroupManager::getActionSetfromString(std::string description)
         goto exit;
     }
 
+    if (token != NULL)
+    {
+        sscanf(token, "%ld %d", &actionset->mDelay, (int*)&actionset->type);
+
+        token = strtok_r(NULL, ACTION_DELIMITER, &plainPtr);
+    }
+    else
+    {
+        goto exit;
+    }
+
     while (token)
     {
         char *descPtr = NULL;
@@ -506,7 +538,6 @@ ActionSet* GroupManager::getActionSetfromString(std::string description)
             strcpy(desc, token);
             token = strtok_r(desc, DESC_DELIMITER, &descPtr);
 
-            // cout << "desc :: " << token << endl;
             while (token != NULL)
             {
                 char *attrPtr = NULL;
@@ -514,8 +545,6 @@ ActionSet* GroupManager::getActionSetfromString(std::string description)
 
                 strcpy(attr, token);
 
-                // cout << "attr :: " << attr << endl;
-
                 token = strtok_r(attr, ATTR_DELIMITER, &attrPtr);
                 while (token != NULL)
                 {
@@ -596,10 +625,9 @@ OCStackResult GroupManager::addActionSet(std::shared_ptr< OCResource > resource,
     if ((resource != NULL) && (newActionSet != NULL))
     {
         std::string message = getStringFromActionSet(newActionSet);
-        OCRepresentation rep;
 
+        OCRepresentation rep;
         rep.setValue("ActionSet", message);
-
         return resource->put(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
                 QueryParamsMap(), cb);
     }
@@ -626,6 +654,47 @@ OCStackResult GroupManager::executeActionSet(std::shared_ptr< OCResource > resou
     }
 }
 
+OCStackResult GroupManager::executeActionSet(std::shared_ptr< OCResource > resource,
+        std::string actionsetName, long int delay, PostCallback cb)
+{
+    if(delay == 0 )
+    {
+        return OC_STACK_INVALID_PARAM;
+    }
+    if (resource != NULL)
+    {
+        std::string value = actionsetName;
+        value.append("*");
+        value.append(std::to_string(delay));
+
+        OCRepresentation rep;
+        rep.setValue("DoScheduledAction", value);
+        return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
+                QueryParamsMap(), cb);
+    }
+    else
+    {
+        return OC_STACK_ERROR;
+    }
+}
+
+OCStackResult GroupManager::cancelActionSet(std::shared_ptr< OCResource > resource,
+        std::string actionsetName, PostCallback cb)
+{
+    if (resource != NULL)
+    {
+        OCRepresentation rep;
+
+        rep.setValue("CancelAction", actionsetName);
+        return resource->post(resource->getResourceTypes().front(), GROUP_INTERFACE, rep,
+                QueryParamsMap(), cb);
+    }
+    else
+    {
+        return OC_STACK_ERROR;
+    }
+}
+
 OCStackResult GroupManager::getActionSet(std::shared_ptr< OCResource > resource,
         std::string actionsetName, PostCallback cb)
 {
@@ -661,5 +730,3 @@ OCStackResult GroupManager::deleteActionSet(std::shared_ptr< OCResource > resour
         return OC_STACK_ERROR;
     }
 }
-}
-
index ebc7d0c..c8a8f9d 100644 (file)
@@ -82,7 +82,8 @@ public:
     OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
             CollectionPresenceCallback);
 
-    OCStackResult bindResourceToGroup(OCResourceHandle& childHandle, std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
+    OCStackResult bindResourceToGroup(OCResourceHandle& childHandle,
+            std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
 
 private:
 
@@ -109,6 +110,10 @@ public:
             const ActionSet* newActionSet, PutCallback cb);
     OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
             std::string actionsetName, PostCallback cb);
+    OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
+            std::string actionsetName, long int delay, PostCallback cb);
+    OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
+            std::string actionsetName, PostCallback cb);
     OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
             PostCallback cb);
     OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
index 46987d1..87458cb 100644 (file)
 #include "GroupSynchronization.h"
 
 using namespace OC;
+using namespace std;
 
 namespace OIC
 {
 
-    using std::cout;
-    using std::endl;
     GroupSynchronization* GroupSynchronization::groupSyncnstance = NULL;
+    bool GroupSynchronization::bIsFinding = false;
 
     GroupSynchronization* GroupSynchronization::getInstance()
     {
@@ -57,6 +57,9 @@ namespace OIC
     {
         cout << "GroupSynchronization::findGroup" << endl;
 
+        if(bIsFinding)
+            return OC_STACK_ERROR;
+
         foundGroupResourceList.clear();
         findCallback = callback;
 
@@ -65,18 +68,24 @@ namespace OIC
             return OC_STACK_ERROR;
         }
 
-
         for (unsigned int i = 0; i < collectionResourceTypes.size(); ++i)
         {
+
             std::string query = OC_WELL_KNOWN_QUERY;
-            query += "?rt=";
-            query += collectionResourceTypes.at(i);
+            query.append("?rt=");
+            query.append(collectionResourceTypes.at(i));
             cout << "GroupSynchronization::findGroup - " << query << endl;
 
-            OCPlatform::findResource("", query, OC_WIFI,
+            OCPlatform::findResource("", query,
+                    OC_ETHERNET,
+                    std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
+
+            OCPlatform::findResource("", query,
+                    OC_WIFI,
                     std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
         }
 
+        bIsFinding = true;
 
         // thread to check if GroupSynchronization::onFoundGroup is called or not.
         std::thread t(std::bind(&GroupSynchronization::checkFindGroup, this));
@@ -197,7 +206,6 @@ namespace OIC
         }
 
         OCResourceHandle collectionResHandle = resIt->second;
-
         try{
             OCStackResult result = OCPlatform::bindResource(collectionResHandle, resourceHandle);
             if (result != OC_STACK_OK)
@@ -274,8 +282,12 @@ namespace OIC
         std::vector< std::string > resourceInterface;
         resourceInterface.push_back(DEFAULT_INTERFACE);
 
-        OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri, OC_WIFI,
-                1, resourceTypes, resourceInterface);
+        OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri,
+                OC_ETHERNET, false, resourceTypes, resourceInterface);
+
+        // OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri,
+        //         OC_WIFI, false, resourceTypes, resourceInterface);
+
         groupSyncResourceList[type[0]] = groupSyncResource;
 
         cout << "GroupSynchronization::joinGroup : creating groupSyncResource." << endl;
@@ -414,70 +426,76 @@ namespace OIC
 
             debugGroupSync();
         }
-        else // requesting to unbind this resourceHandle to the remote collection resource
+
+        return OC_STACK_OK;
+    }
+
+OCStackResult GroupSynchronization::leaveGroup(
+        const std::shared_ptr<OCResource> resource,
+        std::string collectionResourceType, OCResourceHandle resourceHandle)
+    {
+        if ((!resource) || (!resourceHandle))
         {
-            auto resourceIt = groupSyncResourceList.find(collectionResourceType);
+            cout << "GroupSynchronization::joinGroup : Error! Input params are wrong." << endl;
+            return OC_STACK_INVALID_PARAM;
+        }
 
-            if (resourceIt == groupSyncResourceList.end())
-            {
-                cout << "GroupSynchronization::leaveGroup : "
-                        << "Error! There is no collectin resource type to leave." << endl;
-                return OC_STACK_INVALID_PARAM;
-            }
+        cout << "GroupSynchronization::joinGroup" << endl;
 
-            std::shared_ptr< OCResource > resource = resourceIt->second;
-            if(resource == NULL)
-                return OC_STACK_NO_RESOURCE;
-//            cout << "GroupSynchronization::leaveGroup : group sync resource uri - "
-//                    << resource->uri() << endl;
+        // making representation to join group
+        std::vector< std::string > type = resource->getResourceTypes();
+        std::string host = resource->host();
+        std::string uri = resource->uri() + "/groupsync";
 
-            handleIt = collectionResourceHandleList.find(collectionResourceType);
-            if (handleIt == collectionResourceHandleList.end())
-            {
-                cout << "GroupSynchronization::leaveGroup : "
-                        << "Error! There is no collection resource handle to leave." << endl;
-                return OC_STACK_INVALID_PARAM;
-            }
+        std::vector< std::string > resourceTypes;
+        std::string temp;
+        for (unsigned int i = 0; i < type.size(); ++i)
+        {
+            temp = type[0] + ".groupsync";
+            resourceTypes.push_back(temp);
+        }
 
-            collectionResHandle = handleIt->second;
+        std::vector< std::string > resourceInterface;
+        resourceInterface.push_back(DEFAULT_INTERFACE);
 
-            // making representation to leave group
-            std::string method = "leaveGroup";
-            std::string type = OCGetResourceTypeName(collectionResHandle, 0);
-            std::string resourceType;
-            resourceType.append(OCGetResourceTypeName(resourceHandle, 0));
+        OCResource::Ptr groupSyncResource;
+        groupSyncResource = OCPlatform::constructResourceObject(host, uri,
+                OC_ETHERNET, false, resourceTypes, resourceInterface);
+        // groupSyncResource = OCPlatform::constructResourceObject(host, uri,
+        //         OC_WIFI, false, resourceTypes, resourceInterface);
 
-            OCRepresentation rep;
-            rep.setValue("method", method);
-            rep.setValue("collectionResourceType", type);
-            rep.setValue("resourceType", resourceType);
+        // making representation to leave group
+        std::string method = "leaveGroup";
+//        std::string type = OCGetResourceTypeName(collectionResourceType, 0);
+        std::string resourceType;
+        resourceType.append(OCGetResourceTypeName(resourceHandle, 0));
 
-            cout << "\tmethod - " << method << endl;
-            cout << "\tcollectionResourceType - " << type << endl;
-            cout << "\tresourceType - " << resourceType << endl;
+        OCRepresentation rep;
+        rep.setValue("method", method);
+        rep.setValue("collectionResourceType", collectionResourceType);
+        rep.setValue("resourceType", resourceType);
 
-            QueryParamsMap queryParamsMap;
+        cout << "\tmethod - " << method << endl;
+        cout << "\tcollectionResourceType - " << collectionResourceType << endl;
+        cout << "\tresourceType - " << resourceType << endl;
 
-            // request to leave group to the remote group sync resource
-            OCStackResult result = resource->put(rep, queryParamsMap,
-                    std::bind(&GroupSynchronization::onLeaveGroup, this, std::placeholders::_1,
-                            std::placeholders::_2, std::placeholders::_3));
-            if (OC_STACK_OK == result)
-            {
-                cout << "GroupSynchronization::leaveGroup : "
-                        << "groupSyncResource->put was successful." << endl;
-            }
-            else
-            {
-                cout << "GroupSynchronization::leaveGroup : "
-                        << "groupSyncResource->put was unsuccessful. result - " << result << endl;
-            }
+        QueryParamsMap queryParamsMap;
 
-            // deleting all remote resources. These are copied in onGetJoinedRemoteChild()
-            deleteGroup(collectionResourceType);
+        // request to leave group to the remote group sync resource
+        OCStackResult result = groupSyncResource->put(rep, queryParamsMap,
+                std::bind(&GroupSynchronization::onLeaveGroup, this, std::placeholders::_1,
+                        std::placeholders::_2, std::placeholders::_3));
+        if (OC_STACK_OK == result)
+        {
+            cout << "GroupSynchronization::leaveGroup : "
+                    << "groupSyncResource->put was successful." << endl;
         }
-
-        return OC_STACK_OK;
+        else
+        {
+            cout << "GroupSynchronization::leaveGroup : "
+                    << "groupSyncResource->put was unsuccessful. result - " << result << endl;
+        }
+        return result;
     }
 
     void GroupSynchronization::deleteGroup(std::string collectionResourceType)
@@ -681,7 +699,13 @@ namespace OIC
 
                         resourceRequest = request;
 
-                        OCPlatform::findResource("", resourceName, OC_WIFI,
+                        OCPlatform::findResource("", resourceName,
+                                OC_ETHERNET,
+                                std::bind(&GroupSynchronization::onFindResource, this,
+                                        std::placeholders::_1));
+                        
+                        OCPlatform::findResource("", resourceName,
+                                OC_WIFI,
                                 std::bind(&GroupSynchronization::onFindResource, this,
                                         std::placeholders::_1));
                     }
@@ -746,7 +770,6 @@ namespace OIC
 
                         }
 
-
                         childResourceHandleList[collectionResourceHandle] = childList;
 
                         debugGroupSync();
@@ -799,7 +822,6 @@ namespace OIC
         try
         {
             if (resource)
-
             {
                 // Debugging
                 std::string resourceURI;
@@ -827,7 +849,6 @@ namespace OIC
                 cout << "\tList of resource interfaces: " << endl;
                 for (auto &resourceInterfaces : resource->getResourceInterfaces())
                 {
-
                     cout << "\t\t" << resourceInterfaces << endl;
                 }
 
@@ -844,6 +865,7 @@ namespace OIC
                 findCallback(NULL);
             }
 
+            bIsFinding = false;
         }
         catch (std::exception& e)
         {
@@ -928,29 +950,29 @@ namespace OIC
             return;
         }
 
-        cout << "GroupSynchronization::onJoinGroup : " << endl;
-
-        if (remoteCollectionResource)
-        {
-            std::string resourceInterface = DEFAULT_INTERFACE;
-            QueryParamsMap queryParamsMap;
-
-            OCStackResult result = remoteCollectionResource->get("", resourceInterface,
-                    queryParamsMap,
-                    std::bind(&GroupSynchronization::onGetJoinedRemoteChild, this,
-                            std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
-            if (OC_STACK_OK == result)
-            {
-                cout << "GroupSynchronization::onJoinGroup : "
-                        << "remoteCollectionResource->get was successful." << endl;
-            }
-            else
-            {
-                cout << "GroupSynchronization::onJoinGroup : "
-                        << "remoteCollectionResource->get was unsuccessful. result - " << result
-                        << endl;
-            }
-        }
+//        cout << "GroupSynchronization::onJoinGroup : " << endl;
+//
+//        if (remoteCollectionResource)
+//        {
+//            std::string resourceInterface = DEFAULT_INTERFACE;
+//            QueryParamsMap queryParamsMap;
+//
+//            OCStackResult result = remoteCollectionResource->get("", resourceInterface,
+//                    queryParamsMap,
+//                    std::bind(&GroupSynchronization::onGetJoinedRemoteChild, this,
+//                            std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+//            if (OC_STACK_OK == result)
+//            {
+//                cout << "GroupSynchronization::onJoinGroup : "
+//                        << "remoteCollectionResource->get was successful." << endl;
+//            }
+//            else
+//            {
+//                cout << "GroupSynchronization::onJoinGroup : "
+//                        << "remoteCollectionResource->get was unsuccessful. result - " << result
+//                        << endl;
+//            }
+//        }
     }
 
     void GroupSynchronization::onFindResource(std::shared_ptr< OCResource > resource)
@@ -1307,4 +1329,3 @@ namespace OIC
         }
     }
 }
-
index a7bd296..6c0252b 100644 (file)
@@ -68,6 +68,7 @@ private:
     std::shared_ptr< OCResourceRequest > resourceRequest; // this is used for slow response
 
     static GroupSynchronization* groupSyncnstance;
+    static bool bIsFinding;
 
     GroupSynchronization()
     {
@@ -109,6 +110,9 @@ public:
             OCResourceHandle resourceHandle);
     OCStackResult leaveGroup(std::string collectionResourceType,
             OCResourceHandle resourceHandle);
+    OCStackResult leaveGroup(const std::shared_ptr< OCResource > resource,
+                std::string collectionResourceType,
+                OCResourceHandle resourceHandle);
     void deleteGroup(std::string collectionResourceType);
 
     std::map< std::string, OCResourceHandle > getGroupList();
@@ -138,4 +142,3 @@ private:
 };
 }
 #endif    // __OC_GROUPSYNCHRONIZATION__
-
old mode 100644 (file)
new mode 100755 (executable)
index 165668d..1026e00
@@ -33,15 +33,62 @@ using namespace OC;
 
 namespace OIC
 {
-    const int SUCCESS_RESPONSE = 0;
     int cnt = 0;
 
     std::map< std::string, ConfigurationRequestEntry > configurationRequestTable;
-
     ThingsConfiguration* ThingsConfiguration::thingsConfigurationInstance = NULL;
-
     ConfigurationCallback g_bootstrapCallback;
 
+    ConfigurationRequestEntry::ConfigurationRequestEntry(std::string ID,
+                                                        ConfigurationCallback callback,
+                                                        std::shared_ptr< OCResource > resource,
+                                                        std::string updateVal)
+    {
+        m_ID = ID;
+        m_callback = callback;
+        m_resource = resource;
+        m_updateVal = updateVal;
+    }
+
+    ConfigurationUnitInfo::ConfigurationUnitInfo(std::string name,
+                                                std::string attribute,
+                                                std::string uri)
+    {
+        m_name = name;
+        m_attribute = attribute;
+        m_uri = uri;
+    }
+
+    std::string ConfigurationUnitInfo::getJSON()
+    {
+        std::string res;
+
+        res = "{\"name\":\"" + m_name + "\",\"property\":\"" + m_attribute + "\"}";
+
+        return res;
+    }
+
+    ThingsConfiguration::ThingsConfiguration(void)
+    {
+        ConfigurationUnitInfo unit[] =
+        {
+        { "all", "All attributes", "/oic/con" },
+        { "r", "Region", "/oic/con" },
+        { "st", "System Time", "/oic/con"},
+        { "loc", "Location", "/oic/con"},
+        { "c","Currency", "/oic/con" } };
+
+        for (int i = 0; i < NUMCONFUNIT; i++)
+            ConfigurationUnitTable.push_back(unit[i]);
+    }
+
+    ThingsConfiguration::~ThingsConfiguration(void){}
+
+    void ThingsConfiguration::setGroupManager(GroupManager *groupmanager)
+    {
+        g_groupmanager = groupmanager;
+    }
+
     ThingsConfiguration* ThingsConfiguration::getInstance()
     {
         if (thingsConfigurationInstance == NULL)
@@ -156,8 +203,6 @@ namespace OIC
     {
         std::shared_ptr < OCResource > resource = getResource(conf);
 
-        std::cout << __func__ << std::endl;
-
         if (resource)
         {
             QueryParamsMap query;
@@ -172,7 +217,6 @@ namespace OIC
                             std::bind(&ThingsConfiguration::onGetChildInfoForUpdate, this,
                                     std::placeholders::_1, std::placeholders::_2,
                                     std::placeholders::_3, conf)));
-
         }
 
     }
@@ -180,186 +224,174 @@ namespace OIC
     void ThingsConfiguration::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string conf)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
-            std::cout << "GET request was successful" << std::endl;
-
-            std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+            std::cout << "onPut Response error: " << eCode << std::endl;
+            getCallback(conf)(headerOptions, rep, eCode);
+            return ;
+        }
 
-            std::vector < OCRepresentation > children = rep.getChildren();
-            for (auto oit = children.begin(); oit != children.end(); ++oit)
-            {
-                std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
-            }
+        std::cout << "GET request was successful" << std::endl;
 
-            // Get information by using configuration name(conf)
-            std::shared_ptr < OCResource > resource = getResource(conf);
-            std::string actionstring = conf;
-            std::string uri = getUriByConfigurationName(conf);
-            std::string attr = getAttributeByConfigurationName(conf);
+        std::cout << "\tResource URI: " << rep.getUri() << std::endl;
 
-            if (uri == "")
-                return;
+        std::vector < OCRepresentation > children = rep.getChildren();
+        for (auto oit = children.begin(); oit != children.end(); ++oit)
+        {
+            std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
+        }
 
-            if (resource)
-            {
-                // In this nest, we create a new action set of which name is the configuration name.
-                // Required information consists of a host address, URI, attribute key, and
-                // attribute value.
-                ActionSet *newActionSet = new ActionSet();
-                newActionSet->actionsetName = conf;
+        // Get information by using configuration name(conf)
+        std::shared_ptr < OCResource > resource = getResource(conf);
+        std::string actionstring = conf;
+        std::string uri = getUriByConfigurationName(conf);
+        std::string attrKey = conf;
 
-                for (auto oit = children.begin(); oit != children.end(); ++oit)
-                {
-                    Action *newAction = new Action();
+        if (uri == "")
+            return;
 
-                    // oit->getUri() includes a host address as well as URI.
-                    // We should split these to each other and only use the host address to create
-                    // a child resource's URI. Note that the collection resource and its child
-                    // resource are located in same host.
-                    newAction->target = getHostFromURI(oit->getUri()) + uri;
+        if (resource)
+        {
+            // In this nest, we create a new action set of which name is the configuration name.
+            // Required information consists of a host address, URI, attribute key, and
+            // attribute value.
+            ActionSet *newActionSet = new ActionSet();
+            newActionSet->actionsetName = conf;
 
-                    Capability *newCapability = new Capability();
-                    newCapability->capability = attr;
-                    newCapability->status = getUpdateVal(conf);
+            for (auto oit = children.begin(); oit != children.end(); ++oit)
+            {
+                Action *newAction = new Action();
 
-                    newAction->listOfCapability.push_back(newCapability);
-                    newActionSet->listOfAction.push_back(newAction);
-                }
+                // oit->getUri() includes a host address as well as URI.
+                // We should split these to each other and only use the host address to create
+                // a child resource's URI. Note that the collection resource and its child
+                // resource are located in same host.
+                newAction->target = getHostFromURI(oit->getUri()) + uri;
 
-                // Request to create a new action set by using the above actionSet
-                g_groupmanager->addActionSet(resource, newActionSet,
-                        std::function<
-                                void(const HeaderOptions& headerOptions,
-                                        const OCRepresentation& rep, const int eCode) >(
-                                std::bind(&ThingsConfiguration::onCreateActionSet, this,
-                                        std::placeholders::_1, std::placeholders::_2,
-                                        std::placeholders::_3, conf)));
+                Capability *newCapability = new Capability();
+                newCapability->capability = attrKey;
+                newCapability->status = getUpdateVal(conf);
 
-                free(newActionSet);
+                newAction->listOfCapability.push_back(newCapability);
+                newActionSet->listOfAction.push_back(newAction);
             }
 
-        }
-        else
-        {
-            std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            // Request to create a new action set by using the above actionSet
+            g_groupmanager->addActionSet(resource, newActionSet,
+                    std::function<
+                            void(const HeaderOptions& headerOptions,
+                                    const OCRepresentation& rep, const int eCode) >(
+                            std::bind(&ThingsConfiguration::onCreateActionSet, this,
+                                    std::placeholders::_1, std::placeholders::_2,
+                                    std::placeholders::_3, conf)));
+
+            free(newActionSet);
         }
     }
 
     void ThingsConfiguration::onGetChildInfoForGet(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string conf)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
-            std::cout << "GET request was successful" << std::endl;
-            std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+            std::cout << "onGet Response error: " << eCode << std::endl;
+            getCallback(conf)(headerOptions, rep, eCode);
+            return ;
+        }
 
-            std::shared_ptr< OCResource > resource, tempResource;
-            std::vector < std::shared_ptr< OCResource > > p_resources;
-            std::vector < std::string > m_if;
-            std::string uri = getUriByConfigurationName(conf);
+        std::cout << "GET request was successful" << std::endl;
+        std::cout << "\tResource URI: " << rep.getUri() << std::endl;
 
-            if (uri == "")
-                return;
+        std::shared_ptr< OCResource > resource, tempResource;
+        std::vector < std::shared_ptr< OCResource > > p_resources;
+        std::vector < std::string > m_if;
+        std::string uri = getUriByConfigurationName(conf);
 
-            if (uri == "/oic/con" || uri == "/factoryset" || uri == "/factoryset/oic/con")
-                m_if.push_back(BATCH_INTERFACE);
-            else
-                m_if.push_back(DEFAULT_INTERFACE);
+        if (uri == "")
+            return;
 
-            std::vector < OCRepresentation > children = rep.getChildren();
-            for (auto oit = children.begin(); oit != children.end(); ++oit)
-            {
-                std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
+        if (uri == "/factoryset" || uri == "/factoryset/oic/con")
+            m_if.push_back(BATCH_INTERFACE);
+        else
+            m_if.push_back(DEFAULT_INTERFACE);
 
-                // Using a host address and child URIs, we can dynamically create resource objects.
-                // Note that the child resources have not found before, we have no resource objects.
-                // For this reason, we create the resource objects.
+        std::vector < OCRepresentation > children = rep.getChildren();
+        for (auto oit = children.begin(); oit != children.end(); ++oit)
+        {
+            std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
 
-                std::string host = getHostFromURI(oit->getUri());
-                tempResource = OCPlatform::constructResourceObject(host, uri, OC_WIFI, true,
-                        oit->getResourceTypes(), m_if);
+            // Using a host address and child URIs, we can dynamically create resource objects.
+            // Note that the child resources have not found before, we have no resource objects.
+            // For this reason, we create the resource objects.
 
-                p_resources.push_back(tempResource);
-            }
+            std::string host = getHostFromURI(oit->getUri());
+            tempResource = OCPlatform::constructResourceObject(host, uri, OC_ETHERNET, true,
+                    oit->getResourceTypes(), m_if);
+            // tempResource = OCPlatform::constructResourceObject(host, uri, OC_WIFI, true,
+            //         oit->getResourceTypes(), m_if);
+
+            p_resources.push_back(tempResource);
+        }
 
-            // Send GET messages to the child resources in turn.
-            for (unsigned int i = 0; i < p_resources.size(); ++i)
+        // Send GET messages to the child resources in turn.
+        for (unsigned int i = 0; i < p_resources.size(); ++i)
+        {
+            resource = p_resources.at(i);
+            if (resource)
             {
-                resource = p_resources.at(i);
-                if (resource)
+                try
                 {
-                    try
-                    {
-                        if (isSimpleResource(resource))
-                        {
-                            QueryParamsMap test;
-                            resource->get(test, getCallback(conf));
-                        }
-                        else
-                        {
-                            QueryParamsMap test;
-                            resource->get(resource->getResourceTypes().at(0), BATCH_INTERFACE, test,
-                                    getCallback(conf));
-                        }
-                    }
-                    catch (OCException& e)
-                    {
-                        std::cout << e.reason() << std::endl;
-                    }
-
+                    QueryParamsMap test;
+                    resource->get(test, getCallback(conf));
                 }
+                catch (OCException& e)
+                {
+                    std::cout << e.reason() << std::endl;
+                }
+
             }
         }
-        else
-        {
-            std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
-        }
     }
 
     void ThingsConfiguration::onCreateActionSet(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string conf)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
-            std::cout << "PUT request was successful" << std::endl;
-
-            std::shared_ptr < OCResource > resource = getResource(conf);
-            if (resource)
-            {
-                // Now, it is time to execute the action set.
-                g_groupmanager->executeActionSet(resource, conf,
-                        std::function<
-                                void(const HeaderOptions& headerOptions,
-                                        const OCRepresentation& rep, const int eCode) >(
-                                std::bind(&ThingsConfiguration::onExecuteForGroupAction, this,
-                                        std::placeholders::_1, std::placeholders::_2,
-                                        std::placeholders::_3, conf)));
-            }
+            std::cout << "onPut Response error: " << eCode << std::endl;
+            getCallback(conf)(headerOptions, rep, eCode);
+            return ;
         }
-        else
+
+        std::cout << "PUT request was successful" << std::endl;
+
+        std::shared_ptr < OCResource > resource = getResource(conf);
+        if (resource)
         {
-            std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            // Now, it is time to execute the action set.
+            g_groupmanager->executeActionSet(resource, conf,
+                    std::function<
+                            void(const HeaderOptions& headerOptions,
+                                    const OCRepresentation& rep, const int eCode) >(
+                            std::bind(&ThingsConfiguration::onExecuteForGroupAction, this,
+                                    std::placeholders::_1, std::placeholders::_2,
+                                    std::placeholders::_3, conf)));
         }
     }
 
     void ThingsConfiguration::onExecuteForGroupAction(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string conf)
     {
-        if (eCode == SUCCESS_RESPONSE)
-        {
-            std::cout << "PUT request was successful" << std::endl;
-
-            getCallback(conf)(headerOptions, rep, eCode);
-        }
-        else
+        if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            getCallback(conf)(headerOptions, rep, eCode);
+            return ;
         }
+
+        std::cout << "PUT request was successful" << std::endl;
+
+        getCallback(conf)(headerOptions, rep, eCode);
     }
 
     bool ThingsConfiguration::isSimpleResource(std::shared_ptr< OCResource > resource)
@@ -388,34 +420,31 @@ namespace OIC
     void ThingsConfiguration::onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep,
             const int eCode, std::string conf)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
-            std::cout << "Get request was successful" << std::endl;
-
+            std::cout << "onGet Response error: " << eCode << std::endl;
             getCallback(conf)(headerOptions, rep, eCode);
+            return ;
         }
-        else
-        {
-            std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
-        }
+
+        std::cout << "Get request was successful" << std::endl;
+
+        getCallback(conf)(headerOptions, rep, eCode);
     }
 
     void ThingsConfiguration::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
             const int eCode, std::string conf)
     {
-        if (eCode == SUCCESS_RESPONSE)
-        {
-            std::cout << "PUT request was successful" << std::endl;
-
-            // Callback
-            getCallback(conf)(headerOptions, rep, eCode);
-        }
-        else
+        if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            getCallback(conf)(headerOptions, rep, eCode);
+            return;
         }
+
+        std::cout << "PUT request was successful" << std::endl;
+
+        getCallback(conf)(headerOptions, rep, eCode);
     }
 
     OCStackResult ThingsConfiguration::updateConfigurations(std::shared_ptr< OCResource > resource,
@@ -455,7 +484,7 @@ namespace OIC
         if (isSimpleResource(resource))
         {
             // This resource does not need to use a group manager. Just send a PUT message
-            rep.setValue(getAttributeByConfigurationName(conf), getUpdateVal(conf));
+            rep.setValue(conf, getUpdateVal(conf));
             return resource->put(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, rep, query,
                     std::function<
                             void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
@@ -548,16 +577,14 @@ namespace OIC
     void ThingsConfiguration::onGetBootstrapInformation(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
+            std::cout << "onGET Response error: " << eCode << std::endl;
             g_bootstrapCallback(headerOptions, rep, eCode);
+            return;
         }
 
-        else
-        {
-            std::cout << "onGET Response error: " << eCode << std::endl;
-            std::exit(-1);
-        }
+        g_bootstrapCallback(headerOptions, rep, eCode);
     }
 
     void ThingsConfiguration::onFoundBootstrapServer(
old mode 100644 (file)
new mode 100755 (executable)
index b21417e..ccf90d4
@@ -61,11 +61,7 @@ namespace OIC
     {
     public:
         ConfigurationRequestEntry(std::string ID, ConfigurationCallback callback,
-                std::shared_ptr< OCResource > resource, std::string updateVal):
-                m_ID(ID), m_callback(callback), m_resource(resource), m_updateVal(updateVal)
-        {
-        }
-        ;
+                std::shared_ptr< OCResource > resource, std::string updateVal);
 
         // Configuration Name (used in key value in std::map structure)
         // e.g., time, network, security, and so on
@@ -92,29 +88,16 @@ namespace OIC
     public:
 
         std::string m_name;
-        std::string m_description;
-        std::string m_uri;
         std::string m_attribute;
+        std::string m_uri;
 
-        ConfigurationUnitInfo(std::string name, std::string description, std::string uri,
-                std::string attribute) :
-                m_name(name), m_description(description), m_uri(uri), m_attribute(attribute)
-        {
-        }
-        ;
+        ConfigurationUnitInfo(std::string name, std::string attribute, std::string uri);
 
         // If a developer wants to know a list of configuration names, gives it in JSON format.
-        std::string getJSON()
-        {
-            std::string res;
-
-            res = "{\"name\":\"" + m_name + "\",\"description\":\"" + m_description + "\"}";
-
-            return res;
-        }
+        std::string getJSON();
     };
 
-#define NUMCONFUNIT 6
+#define NUMCONFUNIT 5
     typedef std::string ConfigurationName;
     typedef std::string ConfigurationValue;
 
@@ -124,44 +107,18 @@ namespace OIC
         /**
          * Constructor for ThingsConfiguration. Constructs a new ThingsConfiguration
          */
-        ThingsConfiguration(void)
-        {
-            ConfigurationUnitInfo unit[] =
-            {
-            { "configuration", "Configuration Collection's value and its child resource's value",
-                    "/oic/con", "value" },
-            { "region", "the current region in which the device is located geographically",
-                    "/oic/con/0/region", "value" },
-            { "timelink", "link of time collection.", "/oic/con/0/time", "link" },
-            { "ipaddress", "IP Address", "/oic/con/network/0/IPAddress", "value" },
-            { "securitymode",
-                    "Resource for security information (credentials, access control list etc.)",
-                    "/oic/con/security/0/mode", "value" },
-                    { "getfactoryset", "get all default configuration value", "/factoryset/oic/con",
-                            "value" } };
-
-            for (int i = 0; i < NUMCONFUNIT; i++)
-                ConfigurationUnitTable.push_back(unit[i]);
-        }
-        ;
+        ThingsConfiguration(void);
 
         /**
          * Virtual destructor
          */
-        ~ThingsConfiguration(void)
-        {
-        }
-        ;
+        ~ThingsConfiguration(void);
 
         static ThingsConfiguration *thingsConfigurationInstance;
         static ThingsConfiguration* getInstance();
         void deleteInstance();
 
-        void setGroupManager(GroupManager *groupmanager)
-        {
-            g_groupmanager = groupmanager;
-        }
-        ;
+        void setGroupManager(GroupManager *groupmanager);
 
         /**
          * API for updating configuration value of multiple things of a target group or a single
@@ -184,8 +141,8 @@ namespace OIC
          * updateConfiguration()->...(CoAP msg. is transmitted)->OnPut()->callback function in APP.
          *
          * @param resource - resource pointer representing the target group or the single thing.
-         * @param configurations - ConfigurationUnit: a nickname of attribute of target resource
-         *                         (e.g., installedlocation, currency, (IP)address)
+         * @param configurations - ConfigurationUnit: an attribute key of target resource
+         *                         (e.g., loc, st, c, r)
          *                         Value : a value to be updated
          * @param callback - callback.
          *
@@ -209,7 +166,7 @@ namespace OIC
          * getConfigurations()->...(CoAP msg. is transmitted)->onGet()->callback function in APP.
          *
          * @param resource - resource pointer representing the target group or the single thing.
-         * @param configurations - ConfigurationUnit: a nickname of attribute of target resource.
+         * @param configurations - ConfigurationUnit: an attribute key of target resource.
          * @param callback - callback.
          *
          * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
@@ -265,271 +222,6 @@ namespace OIC
         static void onFoundBootstrapServer(std::vector< std::shared_ptr< OCResource > > resources);
         static void onGetBootstrapInformation(const HeaderOptions& headerOptions,
                 const OCRepresentation& rep, const int eCode);
-        // Copyright 2014 Samsung Electronics All Rights Reserved.
-
-        /// @file   ThingsConfiguration.h
-
-        /// @brief  This file contains the declaration of classes and its members related to
-        ///         ThingsConfiguration.
-
-#ifndef __OC_THINGSCONFIGURATION__
-#define __OC_THINGSCONFIGURATION__
-
-#include <string>
-#include <vector>
-#include <map>
-#include <cstdlib>
-#include "GroupManager.h"
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-        using namespace OC;
-
-/// Declearation of Configuation Callback funtion type
-        typedef std::function<
-        void(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode) > ConfigurationCallback;
-
-        typedef std::string ConfigurationName;
-        typedef std::string ConfigurationValue;
-
-        /**
-         * @brief
-         * The following class is used as a item stacking in request queue. The class stores a
-         * request and referential information (e.g., a configuration name, a target resource
-         * object, a callback function passed from the applications, and a update value). When the
-         * function for updating/getting configuration value is called from applications, this class
-         * instance is created and stored in the request queue. The queue is maintained in
-         * a std::map structure so if desiring to find a specific request, you can find it
-         * by querying a configuration name.
-         */
-        class ConfigurationRequestEntry
-        {
-        public:
-            ConfigurationRequestEntry(std::string ID, ConfigurationCallback callback,
-                    std::shared_ptr< OCResource > resource, std::string updateVal) :
-            m_ID(ID), m_callback(callback), m_resource(resource), m_updateVal(updateVal)
-            {
-            }
-            ;
-
-            // Configuration Name (used in key value in std::map structure)
-            // e.g., time, network, security, and so on
-            std::string m_ID;
-            // Reference callback pointer
-            ConfigurationCallback m_callback;
-            // Reference resource object
-            std::shared_ptr< OCResource > m_resource;
-            // Update value only used for configuration update
-            std::string m_updateVal;
-        };
-
-        /**
-         * @brief
-         * The following class is used to store providing configuration name and its relevant
-         * information. The relevant information includes a brief description, uri, and attribute
-         * key. Note that a developer only specifies a configuration name, not URI nor attribute
-         * key, to update/get a value to a remote. Thus, using configuration name, we convert it to
-         * more specific information (i.e. uri and attribute key) to send a request. This class is
-         * reponsible to storing these information.
-         */
-        class ConfigurationUnitInfo
-        {
-        public:
-
-            std::string m_name;
-            std::string m_description;
-            std::string m_uri;
-            std::string m_attribute;
-
-            ConfigurationUnitInfo(std::string name, std::string description, std::string uri,
-                    std::string attribute) :
-            m_name(name), m_description(description), m_uri(uri), m_attribute(attribute)
-            {
-            }
-            ;
-
-            // If a developer wants to know a list of configuration names, gives it in JSON format.
-            std::string getJSON()
-            {
-                std::string res;
-
-                res = "{\"name\":\"" + m_name + "\",\"description\":\"" + m_description + "\"}";
-
-                return res;
-            }
-        };
-
-#define NUMCONFUNIT 6
-        typedef std::string ConfigurationName;
-        typedef std::string ConfigurationValue;
-
-        class ThingsConfiguration
-        {
-        public:
-            /**
-             * Constructor for ThingsConfiguration. Constructs a new ThingsConfiguration
-             */
-            ThingsConfiguration(void)
-            {
-                ConfigurationUnitInfo unit[] =
-                {
-                    {   "configuration", "Configuration value and its child resource's value",
-                            "/oic/con", "value"},
-                    {   "region", "the current region in which the Thing is located geographically",
-                        "/oic/con/0/region", "value"},
-                    {   "timelink", "link of time collection.", "/oic/con/0/time", "link"},
-                    {   "ipaddress", "IP Address", "/oic/con/network/0/IPAddress", "value"},
-                    {   "securitymode",
-                        "Resource for security information (credentials, access control list etc.)",
-                        "/oic/con/security/0/mode", "value"},
-                    {   "getfactoryset", "get all default configuration value",
-                        "/factoryset/oic/con", "value"}};
-
-                for (int i = 0; i < NUMCONFUNIT; i++)
-                ConfigurationUnitTable.push_back(unit[i]);
-            }
-            ;
-
-            /**
-             * Virtual destructor
-             */
-            ~ThingsConfiguration(void)
-            {
-            }
-            ;
-
-            static ThingsConfiguration *thingsConfigurationInstance;
-            static ThingsConfiguration* getInstance();
-            void deleteInstance();
-
-            void setGroupManager(GroupManager *groupmanager)
-            {
-                g_groupmanager = groupmanager;
-            }
-            ;
-
-            /**
-             * API for updating configuration value of multiple things of a target group or a single
-             * thing.
-             * Callback is called when a response arrives.
-             * Before using the below function, a developer should acquire a resource pointer of
-             * (collection) resource that he want to send a request by calling findResource()
-             * function provided in OCPlatform. And he should also notice a "Configuration Name"
-             * term which represents a nickname of a target attribute of a resource that he wants to
-             * update.
-             * The base motivation to introduce the term is to avoid a usage of URI to access
-             * a resource from a developer. Thus, a developer should know which configuration names
-             * are supported by Things Configuration class and what the configuration name means.
-             * To get a list of supported configuration names, use getListOfSupportedConfigurationU-
-             * nits() function, which provides the list in JSON format.
-             * NOTICE: A series of callback functions is called from updateConfigurations() function
-             * (1) For a collection resource
-             * updateConfiguration()->onDeleteActionSet()->onGetChildInfoForUpdate()->onCreateActio-
-             * nSet()->...(CoAP msg. is transmitted)->OnExecuteForGroupAction()->callback function
-             * in APP.
-             * (2) For a simple resource
-             * updateConfiguration()->...(CoAP msg. is transmitted)->OnPut()->callback function in
-             * APP.
-             *
-             * @param resource - resource pointer representing the target group or the single thing.
-             * @param configurations - ConfigurationUnit: a nickname of attribute of target resource
-             *                         (e.g., installedlocation, currency, (IP)address)
-             *                         Value : a value to be updated
-             * @param callback - callback.
-             *
-             * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
-             *
-             * NOTE: OCStackResult is defined in ocstack.h.
-             */
-            OCStackResult updateConfigurations(std::shared_ptr< OCResource > resource,
-                    std::map< ConfigurationName, ConfigurationValue > configurations,
-                    ConfigurationCallback callback);
-
-            /**
-             * API for getting configuration value of multiple things of a target group or a single
-             * thing.
-             * Callback is called when a response arrives.
-             * NOTICE: A series of callback functions is called from getConfigurations() function:
-             * (1) For a collection resource
-             * getConfigurations()->onGetChildInfoForGet()->...(CoAP msg. is transmitted)
-             * ->callback function in APP.
-             * (2) For a simple resource
-             * getConfigurations()->...(CoAP msg. is transmitted)->onGet()->callback function in APP
-             *
-             * @param resource - resource pointer representing the target group or the single thing.
-             * @param configurations - ConfigurationUnit: a nickname of attribute of target resource
-             * @param callback - callback.
-             *
-             * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
-             *
-             * NOTE: OCStackResult is defined in ocstack.h.
-             */
-            OCStackResult getConfigurations(std::shared_ptr< OCResource > resource,
-                    std::vector< ConfigurationName > configurations, ConfigurationCallback callback);
-
-            /**
-             * API to show a list of supported configuration units (configurable parameters)
-             * Callback call when a response arrives.
-             *
-             * @return the list in JSON format
-             */
-            std::string getListOfSupportedConfigurationUnits();
-
-            /**
-             * API for bootstrapping functionality. Find a bootstrap server and get configuration
-             * information from the bootstrap server. With the information, make a configuration
-             * resource.
-             *
-             * @param callback - callback.
-             *
-             * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
-             *
-             * NOTE: OCStackResult is defined in ocstack.h.
-             */
-            OCStackResult doBootstrap(ConfigurationCallback callback);
-
-        private:
-
-            GroupManager *g_groupmanager;
-
-            std::vector< ConfigurationUnitInfo > ConfigurationUnitTable;
-
-            void onExecuteForGroupAction(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onGetChildInfoForGet(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onCreateActionSet(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onGetActionSet(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onDeleteActionSet(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onGet(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            void onPut(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode, std::string conf);
-            static void onFoundBootstrapServer(std::vector< std::shared_ptr< OCResource >
-                > resources);
-            static void onGetBootstrapInformation(const HeaderOptions& headerOptions,
-                    const OCRepresentation& rep, const int eCode);
-
-            std::shared_ptr< OCResource > getResource(std::string conf);
-            ConfigurationCallback getCallback(std::string conf);
-            std::string getUpdateVal(std::string conf);
-            std::string getAttributeByConfigurationName(ConfigurationName name);
-            std::string getUriByConfigurationName(ConfigurationName name);
-
-            std::string getHostFromURI(std::string oldUri);
-
-            bool isSimpleResource(std::shared_ptr< OCResource > resource);
-            bool hasBatchInterface(std::shared_ptr< OCResource > resource);
-
-        };
-
-#endif  /* __OC_THINGSCONFIGURATION__*/
 
         std::shared_ptr< OCResource > getResource(std::string conf);
         ConfigurationCallback getCallback(std::string conf);
old mode 100644 (file)
new mode 100755 (executable)
index dffbb8d..524c197
@@ -33,12 +33,57 @@ using namespace OC;
 
 namespace OIC
 {
-    const int SUCCESS_RESPONSE = 0;
-
     std::map< std::string, DiagnosticsRequestEntry > diagnosticsRequestTable;
-
     ThingsDiagnostics* ThingsDiagnostics::thingsDiagnosticsInstance = NULL;
 
+    DiagnosticsRequestEntry::DiagnosticsRequestEntry(std::string ID, DiagnosticsCallback callback,
+                std::shared_ptr< OCResource > resource, std::string updateVal)
+    {
+        m_ID = ID;
+        m_callback = callback;
+        m_resource = resource;
+        m_updateVal = updateVal;
+    }
+
+    DiagnosticsUnitInfo::DiagnosticsUnitInfo(std::string name,
+                                            std::string attribute,
+                                            std::string uri)
+    {
+        m_name = name;
+        m_attribute = attribute;
+        m_uri = uri;
+    }
+
+    std::string DiagnosticsUnitInfo::getJSON()
+    {
+        std::string res;
+
+        res = "{\"name\":\"" + m_name + "\",\"attribute\":\"" + m_attribute + "\"}";
+
+        return res;
+    }
+
+    ThingsDiagnostics::ThingsDiagnostics()
+    {
+        DiagnosticsUnitInfo unit[] =
+                {
+                { "rb", "Reboot", "/oic/diag"},
+                { "ssc", "StartStatCollection", "/oic/diag"},
+                { "fr", "Factory Reset", "/oic/diag" } };
+
+        for (int i = 0; i < NUMDIAGUNIT; i++)
+            DiagnosticsUnitTable.push_back(unit[i]);
+    }
+
+    ThingsDiagnostics::~ThingsDiagnostics()
+    {
+    }
+
+    void ThingsDiagnostics::setGroupManager(GroupManager *groupmanager)
+    {
+        g_groupmanager = groupmanager;
+    }
+
     ThingsDiagnostics* ThingsDiagnostics::getInstance()
     {
         if (thingsDiagnosticsInstance == NULL)
@@ -151,131 +196,127 @@ namespace OIC
     void ThingsDiagnostics::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string diag)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
-            std::cout << "GET request was successful" << std::endl;
+            std::cout << "onGet Response error: " << eCode << std::endl;
+            getCallback(diag)(headerOptions, rep, eCode);
+            return ;
+        }
 
-            std::cout << "\tResource URI: " << rep.getUri() << std::endl;
+        std::cout << "GET request was successful" << std::endl;
 
-            std::vector < OCRepresentation > children = rep.getChildren();
-            for (auto oit = children.begin(); oit != children.end(); ++oit)
-            {
-                std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
-            }
+        std::cout << "\tResource URI: " << rep.getUri() << std::endl;
 
-            // Get information by using diagnostics name(diag)
-            std::shared_ptr < OCResource > resource = getResource(diag);
-            std::string actionstring = diag;
-            std::string uri = getUriByDiagnosticsName(diag);
-            std::string attr = getAttributeByDiagnosticsName(diag);
+        std::vector < OCRepresentation > children = rep.getChildren();
+        for (auto oit = children.begin(); oit != children.end(); ++oit)
+        {
+            std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
+        }
 
-            if (uri == "")
-                return;
+        // Get information by using diagnostics name(diag)
+        std::shared_ptr < OCResource > resource = getResource(diag);
+        std::string actionstring = diag;
+        std::string uri = getUriByDiagnosticsName(diag);
+        std::string attrKey = diag;
 
-            if (resource)
-            {
-                // In this nest, we create a new action set of which name is the dignostics name.
-                // Required information consists of a host address, URI, attribute key, and
-                // attribute value.
-                ActionSet *newActionSet = new ActionSet();
-                newActionSet->actionsetName = diag;
+        if (uri == "")
+            return;
 
-                for (auto oit = children.begin(); oit != children.end(); ++oit)
-                {
-                    Action *newAction = new Action();
+        if (resource)
+        {
+            // In this nest, we create a new action set of which name is the dignostics name.
+            // Required information consists of a host address, URI, attribute key, and
+            // attribute value.
+            ActionSet *newActionSet = new ActionSet();
+            newActionSet->actionsetName = diag;
 
-                    // oit->getUri() includes a host address as well as URI.
-                    // We should split these to each other and only use the host address to create
-                    // a child resource's URI. Note that the collection resource and its child
-                    // resource are located in same host.
-                    newAction->target = getHostFromURI(oit->getUri()) + uri;
+            for (auto oit = children.begin(); oit != children.end(); ++oit)
+            {
+                Action *newAction = new Action();
 
-                    Capability *newCapability = new Capability();
-                    newCapability->capability = attr;
-                    newCapability->status = getUpdateVal(diag);
+                // oit->getUri() includes a host address as well as URI.
+                // We should split these to each other and only use the host address to create
+                // a child resource's URI. Note that the collection resource and its child
+                // resource are located in same host.
+                newAction->target = getHostFromURI(oit->getUri()) + uri;
 
-                    newAction->listOfCapability.push_back(newCapability);
-                    newActionSet->listOfAction.push_back(newAction);
-                }
+                Capability *newCapability = new Capability();
+                newCapability->capability = attrKey;
+                newCapability->status = getUpdateVal(diag);
 
-                // Request to create a new action set by using the above actionSet
-                g_groupmanager->addActionSet(resource, newActionSet,
-                        std::function<
-                                void(const HeaderOptions& headerOptions,
-                                        const OCRepresentation& rep, const int eCode) >(
-                                std::bind(&ThingsDiagnostics::onCreateActionSet, this,
-                                        std::placeholders::_1, std::placeholders::_2,
-                                        std::placeholders::_3, diag)));
+                newAction->listOfCapability.push_back(newCapability);
+                newActionSet->listOfAction.push_back(newAction);
+            }
 
-                free(newActionSet);
+            // Request to create a new action set by using the above actionSet
+            g_groupmanager->addActionSet(resource, newActionSet,
+                    std::function<
+                            void(const HeaderOptions& headerOptions,
+                                    const OCRepresentation& rep, const int eCode) >(
+                            std::bind(&ThingsDiagnostics::onCreateActionSet, this,
+                                    std::placeholders::_1, std::placeholders::_2,
+                                    std::placeholders::_3, diag)));
 
-            }
+            free(newActionSet);
 
         }
-        else
-        {
-            std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
-        }
     }
 
     void ThingsDiagnostics::onCreateActionSet(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string diag)
     {
-        if (eCode == SUCCESS_RESPONSE)
+        if (eCode != OC_STACK_OK)
         {
-            std::cout << "PUT request was successful" << std::endl;
-
-            std::shared_ptr < OCResource > resource = getResource(diag);
-            if (resource)
-            {
-                // Now, it is time to execute the action set.
-                g_groupmanager->executeActionSet(resource, diag,
-                        std::function<
-                                void(const HeaderOptions& headerOptions,
-                                        const OCRepresentation& rep, const int eCode) >(
-                                std::bind(&ThingsDiagnostics::onExecuteForGroupAction, this,
-                                        std::placeholders::_1, std::placeholders::_2,
-                                        std::placeholders::_3, diag)));
-            }
+            std::cout << "onPut Response error: " << eCode << std::endl;
+            getCallback(diag)(headerOptions, rep, eCode);
+            return ;
         }
-        else
+
+        std::cout << "PUT request was successful" << std::endl;
+
+        std::shared_ptr < OCResource > resource = getResource(diag);
+        if (resource)
         {
-            std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            // Now, it is time to execute the action set.
+            g_groupmanager->executeActionSet(resource, diag,
+                    std::function<
+                            void(const HeaderOptions& headerOptions,
+                                    const OCRepresentation& rep, const int eCode) >(
+                            std::bind(&ThingsDiagnostics::onExecuteForGroupAction, this,
+                                    std::placeholders::_1, std::placeholders::_2,
+                                    std::placeholders::_3, diag)));
         }
     }
 
     void ThingsDiagnostics::onExecuteForGroupAction(const HeaderOptions& headerOptions,
             const OCRepresentation& rep, const int eCode, std::string diag)
     {
-        if (eCode == SUCCESS_RESPONSE)
-        {
-            std::cout << "PUT request was successful" << std::endl;
-
-            getCallback(diag)(headerOptions, rep, eCode);
-        }
-        else
+        if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            getCallback(diag)(headerOptions, rep, eCode);
+            return ;
         }
+
+        std::cout << "PUT request was successful" << std::endl;
+
+        getCallback(diag)(headerOptions, rep, eCode);
     }
 
     void ThingsDiagnostics::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
             const int eCode, std::string diag)
     {
-        if (eCode == SUCCESS_RESPONSE)
-        {
-            std::cout << "PUT request was successful" << std::endl;
-
-            getCallback(diag)(headerOptions, rep, eCode);
-        }
-        else
+        if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            std::exit(-1);
+            getCallback(diag)(headerOptions, rep, eCode);
+            return ;
         }
+
+        std::cout << "PUT request was successful" << std::endl;
+
+        getCallback(diag)(headerOptions, rep, eCode);
+
     }
 
     bool ThingsDiagnostics::isSimpleResource(std::shared_ptr< OCResource > resource)
@@ -298,7 +339,7 @@ namespace OIC
             return OC_STACK_ERROR;
         }
 
-        std::string diag = "reboot";
+        std::string diag = "rb";
 
         // Check the request queue if a previous request is still left. If so, remove it.
         std::map< std::string, DiagnosticsRequestEntry >::iterator iter =
@@ -351,7 +392,7 @@ namespace OIC
             return OC_STACK_ERROR;
         }
 
-        std::string diag = "factoryreset";
+        std::string diag = "fr";
 
         // Check the request queue if a previous request is still left. If so, remove it.
         std::map< std::string, DiagnosticsRequestEntry >::iterator iter =
old mode 100644 (file)
new mode 100755 (executable)
index 072f367..024a2d9
@@ -39,7 +39,6 @@
 using namespace OC;
 namespace OIC
 {
-
     /// Declearation of Diagnostics Callback funtion type
     typedef std::function<
             void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
@@ -58,11 +57,7 @@ namespace OIC
     {
     public:
         DiagnosticsRequestEntry(std::string ID, DiagnosticsCallback callback,
-                std::shared_ptr< OCResource > resource, std::string updateVal) :
-                m_ID(ID), m_callback(callback), m_resource(resource), m_updateVal(updateVal)
-        {
-        }
-        ;
+                std::shared_ptr< OCResource > resource, std::string updateVal);
 
         // Diagnostics Name (used in key value in std::map structure)
         // e.g., reboot and factoryset
@@ -90,27 +85,14 @@ namespace OIC
     class DiagnosticsUnitInfo
     {
     public:
-        DiagnosticsUnitInfo(std::string name, std::string description, std::string uri,
-                std::string attribute) :
-                m_name(name), m_description(description), m_uri(uri), m_attribute(attribute)
-        {
-        }
-        ;
-
         std::string m_name;
-        std::string m_description;
-        std::string m_uri;
         std::string m_attribute;
+        std::string m_uri;
 
-        // If a developer wants to know a list of diagnostics names, gives it in JSON format.
-        std::string getJSON()
-        {
-            std::string res;
-
-            res = "{\"name\":\"" + m_name + "\",\"description\":\"" + m_description + "\"}";
+        DiagnosticsUnitInfo(std::string name, std::string attribute, std::string uri);
 
-            return res;
-        }
+        // If a developer wants to know a list of configuration names, gives it in JSON format.
+        std::string getJSON();
     };
 
 #define NUMDIAGUNIT 3
@@ -123,39 +105,18 @@ namespace OIC
         /**
          * Constructor for ThingsDiagnostics. Constructs a new ThingsDiagnostics
          */
-        ThingsDiagnostics(void)
-        {
-            DiagnosticsUnitInfo unit[] =
-                    {
-                    { "reboot", "reboot", "/oic/diag/0/reboot", "value" },
-                            { "value",
-                                    "Collecting any device statistics",
-                                    "/oic/diag/0/startCollection", "value" },
-                            { "factoryreset", "restore all configuration values to default values",
-                                    "/oic/diag/0/factoryReset", "value" } };
-
-            for (int i = 0; i < NUMDIAGUNIT; i++)
-                DiagnosticsUnitTable.push_back(unit[i]);
-        }
-        ;
+        ThingsDiagnostics(void);
 
         /**
          * Virtual destructor
          */
-        ~ThingsDiagnostics(void)
-        {
-        }
-        ;
+        ~ThingsDiagnostics(void);
 
         static ThingsDiagnostics *thingsDiagnosticsInstance;
         static ThingsDiagnostics* getInstance();
         void deleteInstance();
 
-        void setGroupManager(GroupManager *groupmanager)
-        {
-            g_groupmanager = groupmanager;
-        }
-        ;
+        void setGroupManager(GroupManager *groupmanager);
 
         /**
          * API to make things reboot
index 916e9de..3c0178f 100644 (file)
@@ -125,6 +125,13 @@ namespace OIC
         return result;
     }
 
+    OCStackResult ThingsManager::leaveGroup(const std::shared_ptr< OCResource > resource,
+                            std::string collectionResourceType,
+                            OCResourceHandle resourceHandle)
+    {
+        return g_groupSync->leaveGroup(resource, collectionResourceType, resourceHandle);
+    }
+
     void ThingsManager::deleteGroup(std::string collectionResourceType)
     {
         g_groupSync->deleteGroup(collectionResourceType);
@@ -185,6 +192,16 @@ namespace OIC
     {
         return g_groupManager->executeActionSet(resource, actionsetName, cb);
     }
+    OCStackResult ThingsManager::executeActionSet(std::shared_ptr< OCResource > resource,
+                    std::string actionsetName, long int delay, PostCallback cb)
+    {
+        return g_groupManager->executeActionSet(resource, actionsetName, delay, cb);
+    }
+    OCStackResult ThingsManager::cancelActionSet(std::shared_ptr< OCResource > resource,
+                    std::string actionsetName, PostCallback cb)
+    {
+        return g_groupManager->cancelActionSet(resource, actionsetName, cb);
+    }
     OCStackResult ThingsManager::getActionSet(std::shared_ptr< OCResource > resource,
             std::string actionsetName, GetCallback cb)
     {