Updated tizen sample applications to removed things manager class dependency.
Enabled things manager library build for tizen.
Change-Id: I30db7102d6598103c46b3044fff1e218acded6c5
Signed-off-by: arya.k <arya.kumar@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2401
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
# Remove it if the conversion for Android and Tizen platform is done
-if target_os == 'linux':
+if target_os in ['linux', 'tizen']:
tgm_src = env.Glob('sdk/src/*.cpp', '../../extlibs/timer/timer.c')
tgmsdk_static = things_manager_env.StaticLibrary('TGMSDKLibrary', tgm_src)
tgmsdk_shared = things_manager_env.SharedLibrary('TGMSDKLibrary', tgm_src)
<listOptionValue builtIn="false" value=""..\..\..\..\sdk\inc""/>
<listOptionValue builtIn="false" value=""..\..\..\..\sdk\src""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\include""/>
+ <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\c_common""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\stack\include""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\logger\include""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\occoap\include""/>
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
#pragma once
+#define DEFAULT_LOCATION "loc"
+#define DEFAULT_SYSTIME "st"
+#define DEFAULT_CURRENCY "c"
+#define DEFAULT_REGION "r"
+
using namespace OC;
typedef std::function<OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request)>
ResourceEntityHandler;
-static std::string defaultURIPrefix = "/oic/con";
-static std::string defaultResourceTypePrefix = "oic.con";
+static std::string defaultConURI = "/oic/con";
+static std::string defaultConResourceType = "oic.wk.con";
extern std::string defaultLocation;
-extern std::string defaultDeviceName;
+extern std::string defaultSystemTime;
extern std::string defaultCurrency;
extern std::string defaultRegion;
#include "OCPlatform.h"
#include "OCApi.h"
-#include "thingsmanager.h"
#ifdef LOG_TAG
#undef LOG_TAG
#define __DIAGNOSTICS_RESOURCE_H__
#include <functional>
+#include <thread>
+#include <string>
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
#pragma once
static std::string defaultReboot = "false";
static std::string defaultStartStatCollection = "false";
-class DiagnosticsResource
+class MaintenanceResource
{
public:
- // Diagnostics members
- std::string m_diagnosticsUri;
+ // Maintenance members
+ std::string m_maintenanceUri;
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;
+ std::vector< std::string > m_maintenanceTypes;
+ std::vector< std::string > m_maintenanceInterfaces;
+ OCResourceHandle m_maintenanceHandle;
+ OCRepresentation m_maintenanceRep;
public:
- DiagnosticsResource();
+ MaintenanceResource();
void createResource(ResourceEntityHandler callback);
- void setDiagnosticsRepresentation(OCRepresentation &rep);
+ void setMaintenanceRepresentation(OCRepresentation &rep);
- OCRepresentation getDiagnosticsRepresentation();
+ OCRepresentation getMaintenanceRepresentation();
std::string getUri();
- void diagnosticsMonitor(int second);
+ void maintenanceMonitor(int second);
std::function< void() > factoryReset;
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
#include "configurationresource.h"
#pragma once
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
using namespace OC;
// Constructor
ConfigurationResource::ConfigurationResource() :
- m_location(defaultLocation), m_systemTime(defaultDeviceName), m_currency(
+ m_location(defaultLocation), m_systemTime(defaultSystemTime), m_currency(
defaultCurrency), m_region(defaultRegion)
{
- m_configurationUri = "/oic/con"; // URI of the resource
- m_configurationTypes.push_back("oic.con"); // resource type name
+ m_configurationUri = defaultConURI; // URI of the resource
+ m_configurationTypes.push_back(defaultConResourceType); // resource type name
m_configurationInterfaces.push_back(DEFAULT_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.setValue(DEFAULT_LOCATION, m_location);
+ m_configurationRep.setValue(DEFAULT_SYSTIME, m_systemTime);
+ m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
+ m_configurationRep.setValue(DEFAULT_REGION, m_region);
m_configurationRep.setUri(m_configurationUri);
m_configurationRep.setResourceTypes(m_configurationTypes);
m_configurationRep.setResourceInterfaces(m_configurationInterfaces);
- m_configurationHandle = NULL;
+ m_configurationHandle = nullptr;
}
// Creates a ConfigurationResource
void ConfigurationResource::setConfigurationRepresentation(OCRepresentation &rep)
{
- string value;
+ std::string value;
- if (rep.getValue("loc", value))
+ if (rep.getValue(DEFAULT_LOCATION, value))
{
m_location = value;
dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_location: %s",
m_location.c_str());
}
- if (rep.getValue("st", value))
+ if (rep.getValue(DEFAULT_SYSTIME, value))
{
dlog_print(DLOG_INFO, "ConfigurationResource", "#### SystemTime is not"
"allowed to be written");
}
- if (rep.getValue("c", value))
+ if (rep.getValue(DEFAULT_CURRENCY, value))
{
m_currency = value;
dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_currency: %s",
m_currency.c_str());
}
- if (rep.getValue("r", value))
+ if (rep.getValue(DEFAULT_REGION, value))
{
m_region = value;
dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_region: %s",
OCRepresentation ConfigurationResource::getConfigurationRepresentation()
{
- 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.setValue(DEFAULT_LOCATION, m_location);
+ m_configurationRep.setValue(DEFAULT_SYSTIME, m_systemTime);
+ m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
+ m_configurationRep.setValue(DEFAULT_REGION, m_region);
return m_configurationRep;
}
void ConfigurationResource::factoryReset()
{
m_location = defaultLocation;
- m_systemTime = defaultDeviceName;
+ m_systemTime = defaultSystemTime;
m_currency = defaultCurrency;
m_region = defaultRegion;
}
void ConfigurationResource::deleteResource()
{
// Unregister the resource
- if (NULL != m_configurationHandle)
+ if (nullptr != m_configurationHandle)
{
OCPlatform::unregisterResource(m_configurationHandle);
}
#include <tizen.h>
#include <pthread.h>
+#include "ThingsConfiguration.h"
+#include "ThingsMaintenance.h"
#include "configurationresource.h"
#include "diagnosticsresource.h"
#include "factorysetresource.h"
-using namespace std;
using namespace OC;
using namespace OIC;
std::string defaultSystemTime;
std::string defaultCurrency;
-static ThingsManager *g_thingsmanager;
+static ThingsConfiguration *g_thingsConf;
const int SUCCESS_RESPONSE = 0;
OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
ConfigurationResource *myConfigurationResource;
-DiagnosticsResource *myDiagnosticsResource;
+MaintenanceResource *myMaintenanceResource;
FactorySetResource *myFactorySetResource;
typedef std::function< void(OCRepresentation &) > putFunc;
res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
myConfigurationResource);
}
- else if (uri == myDiagnosticsResource->getUri())
+ else if (uri == myMaintenanceResource->getUri())
{
- res = std::bind(&DiagnosticsResource::getDiagnosticsRepresentation,
- myDiagnosticsResource);
+ res = std::bind(&MaintenanceResource::getMaintenanceRepresentation,
+ myMaintenanceResource);
}
return res;
res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
myConfigurationResource, std::placeholders::_1);
}
- else if (uri == myDiagnosticsResource->getUri())
+ else if (uri == myMaintenanceResource->getUri())
{
- res = std::bind(&DiagnosticsResource::setDiagnosticsRepresentation,
- myDiagnosticsResource, std::placeholders::_1);
+ res = std::bind(&MaintenanceResource::setMaintenanceRepresentation,
+ myMaintenanceResource, std::placeholders::_1);
}
return res;
// Updates the log in the UI
void *updateLog(void *data)
{
- string *log = (string *)data;
- //Show the log
- elm_entry_entry_append(log_entry, log->c_str());
- elm_entry_cursor_end_set(log_entry);
+ std::string *log = (std::string *)data;
- dlog_print(DLOG_INFO, LOG_TAG, "%s", log->c_str());
+ if (nullptr == log)
+ {
+ dlog_print(DLOG_INFO, LOG_TAG, "#### No log !!!!");
+ }
+ else
+ {
+ //Show the log
+ elm_entry_entry_append(log_entry, log->c_str());
+ elm_entry_cursor_end_set(log_entry);
+ dlog_print(DLOG_INFO, LOG_TAG, "%s", log->c_str());
+ }
dlog_print(DLOG_INFO, LOG_TAG, "#### updateLog exit!!!!");
-
return NULL;
}
{
if (NULL != myConfigurationResource)
myConfigurationResource->deleteResource();
- if (NULL != myDiagnosticsResource)
- myDiagnosticsResource->deleteResource();
+ if (NULL != myMaintenanceResource)
+ myMaintenanceResource->deleteResource();
if (NULL != myFactorySetResource)
myFactorySetResource->deleteResource();
+
+ delete g_thingsConf;
}
static void
logMessage += "GET request was successful<br>";
logMessage += "URI : " + rep.getUri() + "<br>";
- defaultRegion = rep.getValue< std::string >("r");
- defaultSystemTime = rep.getValue< std::string >("st");
- defaultCurrency = rep.getValue< std::string >("c");
- defaultLocation = rep.getValue< std::string >("loc");
+ defaultRegion = rep.getValue< std::string >(DEFAULT_REGION);
+ defaultSystemTime = rep.getValue< std::string >(DEFAULT_SYSTIME);
+ defaultCurrency = rep.getValue< std::string >(DEFAULT_CURRENCY);
+ defaultLocation = rep.getValue< std::string >(DEFAULT_LOCATION);
logMessage += "Location : " + defaultLocation + "<br>";
logMessage += "SystemTime : " + defaultSystemTime + "<br>";
static void
doBootStrap_cb(void *data , Evas_Object *obj , void *event_info)
{
- OCStackResult result = g_thingsmanager->doBootstrap(&onBootStrapCallback);
+
+ if (NULL == g_thingsConf)
+ {
+ dlog_print(DLOG_ERROR, LOG_TAG, "#### doBootstrap returned g_thingsConf NULL check");
+ return;
+ }
+
+ OCStackResult result = g_thingsConf->doBootstrap(&onBootStrapCallback);
+
if (OC_STACK_OK == result)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### doBootstrap returned OC_STACK_OK");
myConfigurationResource = new ConfigurationResource();
myConfigurationResource->createResource(&entityHandlerForResource);
- myDiagnosticsResource = new DiagnosticsResource();
- myDiagnosticsResource->createResource(&entityHandlerForResource);
+ myMaintenanceResource = new MaintenanceResource();
+ myMaintenanceResource->createResource(&entityHandlerForResource);
myFactorySetResource = new FactorySetResource();
myFactorySetResource->createResource(&entityHandlerForResource);
- myDiagnosticsResource->factoryReset = std::function < void()
+ myMaintenanceResource->factoryReset = std::function < void()
> (std::bind(&ConfigurationResource::factoryReset,
myConfigurationResource));
// Configure the OCPlatform
configure_platform();
- g_thingsmanager = new ThingsManager();
+ g_thingsConf = new ThingsConfiguration();
return true;
}
#include <functional>
#include <dlog.h>
+#include <thread>
+#include <string>
#include "conserverapp.h"
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
-extern string logMessage;
+using namespace OC;
+
+extern std::string logMessage;
extern void *updateLog(void *);
-using namespace OC;
+static std::string defaultMntURI = "/oic/mnt";
+static std::string defaultMntResourceType = "oic.wk.mnt";
// Constructor
-DiagnosticsResource::DiagnosticsResource() :
+MaintenanceResource::MaintenanceResource() :
m_factoryReset(defaultFactoryReset), m_reboot(defaultReboot),
m_startStatCollection(defaultStartStatCollection)
{
- 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_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);
- m_diagnosticsHandle = NULL;
+ m_maintenanceUri = defaultMntURI; // URI of the resource
+ m_maintenanceTypes.push_back(defaultMntResourceType); // resource type name
+ m_maintenanceInterfaces.push_back(DEFAULT_INTERFACE); // resource interface
+ m_maintenanceRep.setValue("fr", m_factoryReset);
+ m_maintenanceRep.setValue("rb", m_reboot);
+ m_maintenanceRep.setValue("ssc", m_startStatCollection);
+ m_maintenanceRep.setUri(m_maintenanceUri);
+ m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
+ m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
+ m_maintenanceHandle = NULL;
}
// Creates a DiagnosticResource
-void DiagnosticsResource::createResource(ResourceEntityHandler callback)
+void MaintenanceResource::createResource(ResourceEntityHandler callback)
{
using namespace OC::OCPlatform;
if (NULL == callback)
{
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### Callback should be binded");
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### Callback should be binded");
return;
}
// This will internally create and register the resource
- OCStackResult result = registerResource(m_diagnosticsHandle, m_diagnosticsUri,
- m_diagnosticsTypes[0], m_diagnosticsInterfaces[0],
+ OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri,
+ m_maintenanceTypes[0], m_maintenanceInterfaces[0],
callback, OC_DISCOVERABLE | OC_OBSERVABLE);
if (OC_STACK_OK != result)
{
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### Resource creation"
- "(configuration) was unsuccessful");
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### Resource creation"
+ "(maintenance) was unsuccessful");
return;
}
- thread exec(
+ std::thread exec(
std::function< void(int second) >(
- std::bind(&DiagnosticsResource::diagnosticsMonitor, this,
+ std::bind(&MaintenanceResource::maintenanceMonitor, this,
std::placeholders::_1)), 1);
exec.detach();
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### Diagnostics Resource is Created");
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### maintenance Resource is Created");
}
-void DiagnosticsResource::setDiagnosticsRepresentation(OCRepresentation &rep)
+void MaintenanceResource::setMaintenanceRepresentation(OCRepresentation &rep)
{
- string value;
+ std::string value;
if (rep.getValue("fr", value))
{
m_factoryReset = value;
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### m_factoryReset: %s",
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_factoryReset: %s",
m_factoryReset.c_str());
}
if (rep.getValue("rb", value))
{
m_reboot = value;
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### m_reboot: %s", m_reboot.c_str());
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_reboot: %s", m_reboot.c_str());
}
if (rep.getValue("ssc", value))
{
m_startStatCollection = value;
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### m_startStatCollection: %s",
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_startStatCollection: %s",
m_startStatCollection.c_str());
}
}
-OCRepresentation DiagnosticsResource::getDiagnosticsRepresentation()
+OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
{
- m_diagnosticsRep.setValue("fr", m_factoryReset);
- m_diagnosticsRep.setValue("rb", m_reboot);
- m_diagnosticsRep.setValue("ssc", m_startStatCollection);
+ m_maintenanceRep.setValue("fr", m_factoryReset);
+ m_maintenanceRep.setValue("rb", m_reboot);
+ m_maintenanceRep.setValue("ssc", m_startStatCollection);
- return m_diagnosticsRep;
+ return m_maintenanceRep;
}
-std::string DiagnosticsResource::getUri()
+std::string MaintenanceResource::getUri()
{
- return m_diagnosticsUri;
+ return m_maintenanceUri;
}
// Handles the Reboot and FactoryReset request
-void DiagnosticsResource::diagnosticsMonitor(int second)
+void MaintenanceResource::maintenanceMonitor(int second)
{
while (1)
{
if (m_reboot == "true")
{
int res;
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### Reboot will be soon...");
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### Reboot will be soon...");
m_reboot = defaultReboot;
res = system("sudo reboot"); // System reboot
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### return: %d", res);
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### return: %d", res);
logMessage = "----------------------------<br>";
logMessage += "*** System Reboot Success ***<br>";
}
else if (m_factoryReset == "true")
{
- dlog_print(DLOG_INFO, "DiagnosticsResource", "#### Factory Reset will be soon...");
+ dlog_print(DLOG_INFO, "MaintenanceResource", "#### Factory Reset will be soon...");
m_factoryReset = defaultFactoryReset;
factoryReset();
}
}
// Deletes the diagnostic resource which has been created using createResource()
-void DiagnosticsResource::deleteResource()
+void MaintenanceResource::deleteResource()
{
// Unregister the resource
- if (NULL != m_diagnosticsHandle)
+ if (NULL != m_maintenanceHandle)
{
- OCPlatform::unregisterResource(m_diagnosticsHandle);
+ OCPlatform::unregisterResource(m_maintenanceHandle);
}
}
#include <functional>
#include <dlog.h>
+#include <string.h>
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
+#include "configurationresource.h"
using namespace OC;
void FactorySetResource::setFactorySetRepresentation(OCRepresentation &rep)
{
- string value;
+ std::string value;
- if (rep.getValue("loc", value))
+ if (rep.getValue(DEFAULT_LOCATION, value))
{
m_location = value;
dlog_print(DLOG_INFO, "FactorySetResource", "#### m_location: %s",
m_location.c_str());
}
- if (rep.getValue("st", value))
+ if (rep.getValue(DEFAULT_SYSTIME, value))
{
dlog_print(DLOG_INFO, "FactorySetResource", "#### SystemTime is not"
"allowed to be written");
}
- if (rep.getValue("c", value))
+ if (rep.getValue(DEFAULT_CURRENCY, value))
{
m_currency = value;
dlog_print(DLOG_INFO, "FactorySetResource", "#### m_currency: %s",
m_currency.c_str());
}
- if (rep.getValue("r", value))
+ if (rep.getValue(DEFAULT_REGION, value))
{
m_region = value;
dlog_print(DLOG_INFO, "FactorySetResource", "#### m_region: %s",
OCRepresentation FactorySetResource::getFactorySetRepresentation()
{
- 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.setValue(DEFAULT_LOCATION, m_location);
+ m_configurationRep.setValue(DEFAULT_SYSTIME, m_systemTime);
+ m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
+ m_configurationRep.setValue(DEFAULT_REGION, m_region);
return m_configurationRep;
}
<listOptionValue builtIn="false" value=""..\..\..\..\sdk\inc""/>
<listOptionValue builtIn="false" value=""..\..\..\..\sdk\src""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\include""/>
+ <listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\c_common""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\stack\include""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\logger\include""/>
<listOptionValue builtIn="false" value=""..\..\..\..\..\..\resource\csdk\occoap\include""/>
#include "OCPlatform.h"
#include "OCApi.h"
-#include "ThingsManager.h"
+#include "GroupManager.h"
+#include "ThingsConfiguration.h"
+#include "ThingsMaintenance.h"
#ifdef LOG_TAG
#define ELM_DEMO_EDJ "opt/usr/apps/org.tizen.tmsampleapp/res/ui_controls.edj"
+#define FINDGROUP_TIMEOUT 5
+#define FINDRESOURCE_TIMEOUT 6
+
+#define DEFAULT_LOCATION "loc"
+#define DEFAULT_SYSTIME "st"
+#define DEFAULT_CURRENCY "c"
+#define DEFAULT_REGION "r"
+
void group_cb(void *data, Evas_Object *obj, void *event_info);
void configuration_cb(void *data, Evas_Object *obj, void *event_info);
std::shared_ptr< OCResource > g_configurationCollection; // For a group of multiple resources
std::shared_ptr< OCResource > g_configurationResource; // For a single resource
-OCResourceHandle diagnosticsCollectionHandle = NULL;
-OCResourceHandle diagnosticsFoundHandle = NULL;
-std::shared_ptr< OCResource > g_diagnosticsCollection; // For a group of multiple resources
-std::shared_ptr< OCResource > g_diagnosticsResource; // For a single resource
+OCResourceHandle maintenanceCollectionHandle = NULL;
+OCResourceHandle maintenanceFoundHandle = NULL;
+std::shared_ptr< OCResource > g_maintenanceCollection; // For a group of multiple resources
+std::shared_ptr< OCResource > g_maintenanceResource; // For a single resource
OCResourceHandle setCollectionHandle = NULL;
OCResourceHandle setFoundHandle = NULL;
string CONFIGURATION_COLLECTION_RESOURCE_URI = "/core/a/configuration/resourceset";
string CONFIGURATION_COLLECTION_RESOURCE_TYPE = "core.configuration.resourceset";
-string DIAGNOSTIC_COLLECTION_RESOURCE_URI = "/core/a/diagnostics/resourceset";
-string DIAGNOSTIC_COLLECTION_RESOURCE_TYPE = "core.diagnostics.resourceset";
+string MAINTENANCE_COLLECTION_RESOURCE_URI = "/core/a/maintenance/resourceset";
+string MAINTENANCE_COLLECTION_RESOURCE_TYPE = "core.maintenance.resourceset";
string FACTORYSET_COLLECTION_RESOURCE_URI = "/core/a/factoryset/resourceset";
string FACTORYSET_COLLECTION_RESOURCE_TYPE = "core.factoryset.resourceset";
string CONFIGURATION_RESOURCE_URI = "/oic/con";
-string DIAGNOSTIC_RESOURCE_URI = "/oic/diag";
+string MAINTENANCE_RESOURCE_URI = "/oic/mnt";
string FACTORYSET_RESOURCE_URI = "/factorySet";
-ThingsManager *configthingsMgr = new ThingsManager();
+GroupManager *g_groupManager = new GroupManager();
+ThingsConfiguration *g_thingsConfig = new ThingsConfiguration();
+ThingsMaintenance *g_thingsMnt = new ThingsMaintenance();
+
typedef struct region_popup
{
if (resource->uri() == CONFIGURATION_COLLECTION_RESOURCE_URI)
g_configurationCollection = resource;
- else if (resource->uri() == DIAGNOSTIC_COLLECTION_RESOURCE_URI)
- g_diagnosticsCollection = resource;
+ else if (resource->uri() == MAINTENANCE_COLLECTION_RESOURCE_URI)
+ g_maintenanceCollection = resource;
else if (resource->uri() == FACTORYSET_COLLECTION_RESOURCE_URI)
g_setCollection = resource;
else
"g_configurationResource is not null");
}
}
- else if (resource->uri() == DIAGNOSTIC_RESOURCE_URI &&
- NULL != diagnosticsCollectionHandle)
+ else if (resource->uri() == MAINTENANCE_RESOURCE_URI &&
+ NULL != maintenanceCollectionHandle)
{
- OCPlatform::bindResource(diagnosticsCollectionHandle,
+ OCPlatform::bindResource(maintenanceCollectionHandle,
foundResourceHandle);
- diagnosticsFoundHandle = foundResourceHandle;
- if (NULL == g_diagnosticsResource)
+ maintenanceFoundHandle = foundResourceHandle;
+ if (NULL == g_maintenanceResource)
{
dlog_print(DLOG_INFO, LOG_TAG,
- "g_diagnosticsResource updated");
- g_diagnosticsResource = resource;
+ "g_maintenanceResource updated");
+ g_maintenanceResource = resource;
}
else
{
dlog_print(DLOG_INFO, LOG_TAG,
- "g_diagnosticsResource is not null");
+ "g_maintenanceResource is not null");
}
}
else if (resource->uri() == FACTORYSET_RESOURCE_URI &&
string logMessage = "Resource URI: " + rep.getUri() + "<br>";
dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
- if (rep.hasAttribute("loc"))
+ if (rep.hasAttribute(DEFAULT_LOCATION))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Location : %s",
rep.getValue< std::string >("loc").c_str());
logMessage = logMessage + "Location : " + rep.getValue< std::string >("loc") + "<br>";
}
- if (rep.hasAttribute("st"))
+ if (rep.hasAttribute(DEFAULT_SYSTIME))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### SystemTime : %s",
rep.getValue< std::string >("st").c_str());
logMessage = logMessage + "SystemTime : " + rep.getValue< std::string >("st") + "<br>";
}
- if (rep.hasAttribute("c"))
+ if (rep.hasAttribute(DEFAULT_CURRENCY))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Currency : %s",
rep.getValue< std::string >("c").c_str());
logMessage = logMessage + "Currency : " + rep.getValue< std::string >("c") + "<br>";
}
- if (rep.hasAttribute("r"))
+ if (rep.hasAttribute(DEFAULT_REGION))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Region : %s",
rep.getValue< std::string >("r").c_str());
string logMessage = "Resource URI: " + rep.getUri() + "<br>";
dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
- if (rep.hasAttribute("loc"))
+ if (rep.hasAttribute(DEFAULT_LOCATION))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Location : %s",
- rep.getValue< std::string >("loc").c_str());
- logMessage = logMessage + "Location : " + rep.getValue< std::string >("loc") + "<br>";
+ rep.getValue< std::string >(DEFAULT_LOCATION).c_str());
+ logMessage = logMessage + "Location : " + rep.getValue< std::string >(DEFAULT_LOCATION) + "<br>";
}
- if (rep.hasAttribute("st"))
+ if (rep.hasAttribute(DEFAULT_SYSTIME))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### SystemTime : %s",
- rep.getValue< std::string >("st").c_str());
- logMessage = logMessage + "SystemTime : " + rep.getValue< std::string >("st") + "<br>";
+ rep.getValue< std::string >(DEFAULT_SYSTIME).c_str());
+ logMessage = logMessage + "SystemTime : " + rep.getValue< std::string >(DEFAULT_SYSTIME) + "<br>";
}
- if (rep.hasAttribute("c"))
+ if (rep.hasAttribute(DEFAULT_CURRENCY))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Currency : %s",
- rep.getValue< std::string >("c").c_str());
- logMessage = logMessage + "Currency : " + rep.getValue< std::string >("c") + "<br>";
+ rep.getValue< std::string >(DEFAULT_CURRENCY).c_str());
+ logMessage = logMessage + "Currency : " + rep.getValue< std::string >(DEFAULT_CURRENCY) + "<br>";
}
- if (rep.hasAttribute("r"))
+ if (rep.hasAttribute(DEFAULT_REGION))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Region : %s",
- rep.getValue< std::string >("r").c_str());
- logMessage = logMessage + "Region : " + rep.getValue< std::string >("r") + "<br>";
+ rep.getValue< std::string >(DEFAULT_REGION).c_str());
+ logMessage = logMessage + "Region : " + rep.getValue< std::string >(DEFAULT_REGION) + "<br>";
}
logMessage += "----------------------<br>";
std::vector<string> resourceTypes;
resourceTypes.push_back(CONFIGURATION_COLLECTION_RESOURCE_TYPE);
- if (NULL != configthingsMgr)
+ if (NULL != g_groupManager)
{
- configthingsMgr->findCandidateResources(resourceTypes, &onFoundCollectionResource, 5);
+ g_groupManager->findCandidateResources(resourceTypes, &onFoundCollectionResource,
+ FINDGROUP_TIMEOUT);
}
resourceTypes.clear();
- resourceTypes.push_back(DIAGNOSTIC_COLLECTION_RESOURCE_TYPE);
- if (NULL != configthingsMgr)
+ resourceTypes.push_back(MAINTENANCE_COLLECTION_RESOURCE_TYPE);
+ if (NULL != g_groupManager)
{
- configthingsMgr->findCandidateResources(resourceTypes, &onFoundCollectionResource, 5);
+ g_groupManager->findCandidateResources(resourceTypes, &onFoundCollectionResource,
+ FINDGROUP_TIMEOUT);
}
resourceTypes.clear();
resourceTypes.push_back(FACTORYSET_COLLECTION_RESOURCE_TYPE);
- if (NULL != configthingsMgr)
+ if (NULL != g_groupManager)
{
- configthingsMgr->findCandidateResources(resourceTypes, &onFoundCollectionResource, 5);
+ g_groupManager->findCandidateResources(resourceTypes, &onFoundCollectionResource,
+ FINDGROUP_TIMEOUT);
}
dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources EXIT!!!!");
{
dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources ENTRY!!!!");
std::vector<string> resourceTypes;
- resourceTypes.push_back("oic.con");
+ resourceTypes.push_back("oic.wk.con");
- if (NULL != configthingsMgr)
+ if (NULL != g_groupManager)
{
- configthingsMgr->findCandidateResources(resourceTypes, &onFoundCandidateResource, 7);
+ g_groupManager->findCandidateResources(resourceTypes, &onFoundCandidateResource,
+ FINDRESOURCE_TIMEOUT);
}
resourceTypes.clear();
- resourceTypes.push_back("oic.diag");
- if (NULL != configthingsMgr)
+ resourceTypes.push_back("oic.wk.mnt");
+ if (NULL != g_groupManager)
{
- configthingsMgr->findCandidateResources(resourceTypes, &onFoundCandidateResource, 7);
+ g_groupManager->findCandidateResources(resourceTypes, &onFoundCandidateResource,
+ FINDRESOURCE_TIMEOUT);
}
resourceTypes.clear();
resourceTypes.push_back("factorySet");
- if (NULL != configthingsMgr)
+ if (NULL != g_groupManager)
{
- configthingsMgr->findCandidateResources(resourceTypes, &onFoundCandidateResource, 7);
+ g_groupManager->findCandidateResources(resourceTypes, &onFoundCandidateResource,
+ FINDRESOURCE_TIMEOUT);
}
dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources EXIT!!!!");
try
{
- configthingsMgr->getConfigurations(g_configurationCollection, configurations,
- &onGetConfigurationsCallback);
+ g_thingsConfig->getConfigurations(g_configurationCollection, configurations,
+ &onGetConfigurationsCallback);
+
+ isWaiting = 0;
}
catch (std::exception &e)
{
try
{
- result = configthingsMgr->updateConfigurations(g_configurationCollection, configurations,
+ result = g_thingsConfig->updateConfigurations(g_configurationCollection, configurations,
&onUpdateConfigurationsCallback);
}
catch (std::exception &e)
static void factoryReset(void *data, Evas_Object *obj, void *event_info)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### factoryReset ENTRY!!!!");
- if (NULL == g_diagnosticsCollection || NULL == g_diagnosticsCollection.get())
+ if (NULL == g_maintenanceCollection || NULL == g_maintenanceCollection.get())
{
dlog_print(DLOG_ERROR, LOG_TAG, "Note that you first create a group to use this command");
string logMessage = "FIRST CREATE GROUP <br>";
try
{
- result = configthingsMgr->factoryReset(g_diagnosticsCollection, &onFactoryReset);
+ result = g_thingsMnt->factoryReset(g_maintenanceCollection, &onFactoryReset);
}
catch (std::exception &e)
{
static void reboot(void *data, Evas_Object *obj, void *event_info)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### reboot ENTRY!!!!");
- if (NULL == g_diagnosticsCollection || NULL == g_diagnosticsCollection.get())
+ if (NULL == g_maintenanceCollection || NULL == g_maintenanceCollection.get())
{
dlog_print(DLOG_INFO, LOG_TAG, "Note that you first create a group to use this command");
string logMessage = "FIRST CREATE GROUP <br>";
try
{
- result = configthingsMgr->reboot(g_diagnosticsCollection, &onReboot);
+ result = g_thingsMnt->reboot(g_maintenanceCollection, &onReboot);
}
catch (std::exception &e)
{
{
dlog_print(DLOG_INFO, LOG_TAG, "#### getListOfSupportedConfigurationUnits ENTRY!!!!");
string listOfSupportedConfigurationUnits =
- configthingsMgr->getListOfSupportedConfigurationUnits();
+ g_thingsConfig->getListOfSupportedConfigurationUnits();
dlog_print(DLOG_INFO, LOG_TAG, "#### List : %s", listOfSupportedConfigurationUnits.c_str());
string logMessage;
createResourceCollection(CONFIGURATION_COLLECTION_RESOURCE_URI,
CONFIGURATION_COLLECTION_RESOURCE_TYPE,
configurationCollectionHandle);
- createResourceCollection(DIAGNOSTIC_COLLECTION_RESOURCE_URI,
- DIAGNOSTIC_COLLECTION_RESOURCE_TYPE,
- diagnosticsCollectionHandle);
+ createResourceCollection(MAINTENANCE_COLLECTION_RESOURCE_URI,
+ MAINTENANCE_COLLECTION_RESOURCE_TYPE,
+ maintenanceCollectionHandle);
createResourceCollection(FACTORYSET_COLLECTION_RESOURCE_URI,
FACTORYSET_COLLECTION_RESOURCE_TYPE,
setCollectionHandle);
deleteResource(configurationCollectionHandle, configurationFoundHandle);
- deleteResource(diagnosticsCollectionHandle, diagnosticsFoundHandle);
+ deleteResource(maintenanceCollectionHandle, maintenanceFoundHandle);
deleteResource(setCollectionHandle, setFoundHandle);
shared_ptr< OCResource > g_resource ;
std::vector< string > lights;
-ThingsManager *groupThingsMgr = new ThingsManager();
+GroupManager *groupMgr = NULL;
typedef struct datetime_popup
{
string plainText;
if (rep.getValue("ActionSet", plainText))
{
- ActionSet *actionset = groupThingsMgr->getActionSetfromString(plainText);
+ ActionSet *actionset = groupMgr->getActionSetfromString(plainText);
if (NULL != actionset)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### ACTIONSET NAME :: (%s)",
{
if (g_resource)
{
- groupThingsMgr->addActionSet(g_resource, actionSet, onPut);
+ groupMgr->addActionSet(g_resource, actionSet, onPut);
}
}
catch (std::exception &e)
{
if (g_resource)
{
- groupThingsMgr->addActionSet(g_resource, actionSet, onPut);
+ groupMgr->addActionSet(g_resource, actionSet, onPut);
}
}
catch (std::exception &e)
}
if (g_resource)
{
- groupThingsMgr->addActionSet(g_resource, allBulbOn, onPut);
+ groupMgr->addActionSet(g_resource, allBulbOn, onPut);
}
delete allBulbOn;
}
if (g_resource)
{
- groupThingsMgr->addActionSet(g_resource, allBulbOff, onPut);
+ groupMgr->addActionSet(g_resource, allBulbOff, onPut);
}
delete allBulbOff;
static void scheduled_AllbulbOff(void *data, Evas_Object *obj, void *event_info)
{
- groupThingsMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
+ groupMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
}
static void scheduled_AllbulbOffEx(void *data, Evas_Object *obj, void *event_info)
{
- groupThingsMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", 10, &onPost);
+ groupMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", 10, &onPost);
}
static void cancelScheduled_AllBulbOff(void *data, Evas_Object *obj, void *event_info)
{
- groupThingsMgr->cancelActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
+ groupMgr->cancelActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
}
static void recursive_allBulbOn(void *data, Evas_Object *obj, void *event_info)
{
- groupThingsMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
+ groupMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
}
static void recursive_allBulbOnEx(void *data, Evas_Object *obj, void *event_info)
{
- groupThingsMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", 10, &onPost);
+ groupMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", 10, &onPost);
}
static void cancelRecursive_allBulbOn(void *data, Evas_Object *obj, void *event_info)
{
- groupThingsMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
+ groupMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
}
/* Method for executing the action Set AllBulbOff that we have created using
{
if (g_resource)
{
- groupThingsMgr->executeActionSet(g_resource, BULBOFF, &onPost);
+ groupMgr->executeActionSet(g_resource, BULBOFF, &onPost);
}
}
catch (std::exception &e)
{
if (g_resource)
{
- groupThingsMgr->executeActionSet(g_resource, BULBON, &onPost);
+ groupMgr->executeActionSet(g_resource, BULBON, &onPost);
}
}
catch (std::exception &e)
{
if (g_resource)
{
- groupThingsMgr->getActionSet(g_resource, BULBOFF, &onPost);
+ groupMgr->getActionSet(g_resource, BULBOFF, &onPost);
}
}
catch (std::exception &e)
{
if (g_resource)
{
- groupThingsMgr->getActionSet(g_resource, BULBON, &onPost);
+ groupMgr->getActionSet(g_resource, BULBON, &onPost);
}
}
catch (std::exception &e)
{
if (g_resource)
{
- groupThingsMgr->deleteActionSet(g_resource, BULBOFF, &onPost);
+ groupMgr->deleteActionSet(g_resource, BULBOFF, &onPost);
}
}
catch (std::exception &e)
{
if (g_resource)
{
- groupThingsMgr->deleteActionSet(g_resource, BULBON, &onPost);
+ groupMgr->deleteActionSet(g_resource, BULBON, &onPost);
}
}
catch (std::exception &e)
static void create_group()
{
- if (NULL != groupThingsMgr)
+
+ groupMgr = new GroupManager();
+
+ if (NULL != groupMgr)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### calling findCandidateResources from "
"create_group!!!!");
vector< string > types;
types.push_back("core.light");
- groupThingsMgr->findCandidateResources(types, &foundResources, 5);
+ groupMgr->findCandidateResources(types, &foundResources, FINDRESOURCE_TIMEOUT);
}
try
void findLightResource(void *data, Evas_Object *obj, void *event_info)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### findLightResource ENTRY");
- if (NULL != groupThingsMgr)
+ if (NULL != groupMgr)
{
vector< string > types;
types.push_back("core.light");
- OCStackResult result = groupThingsMgr->findCandidateResources(types, &foundResources, 5);
+ OCStackResult result = groupMgr->findCandidateResources(types, &foundResources,
+ FINDRESOURCE_TIMEOUT);
if (result == OC_STACK_OK)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### create_group -- findCandidateResources :: "
void observeBookMark(void *data, Evas_Object *obj, void *event_info)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### observeBookMark ENTRY");
- if (NULL != groupThingsMgr)
+ if (NULL != groupMgr)
{
vector< string > types;
types.push_back("core.bookmark");
- OCStackResult result = groupThingsMgr->findCandidateResources(types, &foundResources, 5);
+ OCStackResult result = groupMgr->findCandidateResources(types, &foundResources,
+ FINDRESOURCE_TIMEOUT);
if (OC_STACK_OK == result)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### create_group - findCandidateResources :: "
{
dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
}
+
+ delete groupMgr;
}
static void createActionSet(void *data, Evas_Object *obj, void *event_info)
static void find_group()
{
dlog_print(DLOG_INFO, LOG_TAG, "#### findGroup ENTRY");
- vector< string > resourceTypes;
- resourceTypes.push_back(resourceTypeName);
- OCStackResult result = groupThingsMgr->findGroup(resourceTypes, &foundResource);
- if (OC_STACK_OK == result)
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### findGroup returned OC_STACK_OK");
- }
- else
- {
- dlog_print(DLOG_INFO, LOG_TAG, "#### findGroup failed");
- }
+ std::string query = OC_RSRVD_WELL_KNOWN_URI;
+ query.append("?rt=");
+ query.append(resourceTypeName);
+
+ OCPlatform::findResource("", query, CT_DEFAULT, &foundResource);
+
dlog_print(DLOG_INFO, LOG_TAG, "#### findGroup EXIT");
}