"Device Name" and "Location Name" properties are added and "SystemTime" property
is removed.
diagnosticsresource file is renamed to maintenanceresource.
Change-Id: I4fab4b7989a714d2aa1089f22f8adde674597bab
Signed-off-by: arya.k <arya.kumar@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2445
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
* limitations under the License.
*
******************************************************************/
-#ifndef __CONFIGURATION_RESOURCE_H__
-#define __CONFIGURATION_RESOURCE_H__
+#ifndef CONFIGURATION_RESOURCE_H__
+#define CONFIGURATION_RESOURCE_H__
#include <functional>
#pragma once
+#define DEFAULT_DEVICENAME "n"
#define DEFAULT_LOCATION "loc"
-#define DEFAULT_SYSTIME "st"
+#define DEFAULT_LOCATIONNAME "locn"
#define DEFAULT_CURRENCY "c"
#define DEFAULT_REGION "r"
static std::string defaultConURI = "/oic/con";
static std::string defaultConResourceType = "oic.wk.con";
+extern std::string defaultDeviceName;
extern std::string defaultLocation;
-extern std::string defaultSystemTime;
+extern std::string defaultLocationName;
extern std::string defaultCurrency;
extern std::string defaultRegion;
public:
// Configuration members
std::string m_configurationUri;
+ std::string m_deviceName;
std::string m_location;
- std::string m_systemTime;
+ std::string m_locationName;
std::string m_currency;
std::string m_region;
std::vector< std::string > m_configurationTypes;
void deleteResource();
};
-#endif // __CONFIGURATION_RESOURCE_H__
\ No newline at end of file
+#endif // CONFIGURATION_RESOURCE_H__
\ No newline at end of file
*
******************************************************************/
-#ifndef __CONSERVERAPP_H__
-#define __CONSERVERAPP_H__
+#ifndef CONSERVERAPP_H__
+#define CONSERVERAPP_H__
#include <app.h>
#include <Elementary.h>
#define ELM_DEMO_EDJ "opt/usr/apps/org.tizen.conserverapp/res/ui_controls.edj"
-#endif // __CONSERVERAPP_H__
+#endif // CONSERVERAPP_H__
\ No newline at end of file
* limitations under the License.
*
******************************************************************/
-#ifndef __FACTORYSET_RESOURCE_H__
-#define __FACTORYSET_RESOURCE_H__
+#ifndef FACTORYSET_RESOURCE_H__
+#define FACTORYSET_RESOURCE_H__
#include <functional>
void deleteResource();
};
-#endif // __FACTORYSET_RESOURCE_H__
\ No newline at end of file
+#endif // FACTORYSET_RESOURCE_H__
\ No newline at end of file
* limitations under the License.
*
******************************************************************/
-#ifndef __DIAGNOSTICS_RESOURCE_H__
-#define __DIAGNOSTICS_RESOURCE_H__
+#ifndef MAINTENANCE_RESOURCE_H__
+#define MAINTENANCE_RESOURCE_H__
#include <functional>
#include <thread>
#pragma once
+#define DEFAULT_REBOOT "rb"
+#define DEFAULT_FACTORYRESET "fr"
+#define DEFAULT_STARTCOLLECTION "ssc"
+
using namespace OC;
typedef std::function<OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request)>
void deleteResource();
};
-#endif // __DIAGNOSTICS_RESOURCE_H__
\ No newline at end of file
+#endif // MAINTENANCE_RESOURCE_H__
\ No newline at end of file
// Constructor
ConfigurationResource::ConfigurationResource() :
- m_location(defaultLocation), m_systemTime(defaultSystemTime), m_currency(
- defaultCurrency), m_region(defaultRegion)
+ m_deviceName(defaultDeviceName), m_location(defaultLocation),
+ m_locationName(defaultLocationName), m_currency(defaultCurrency),
+ m_region(defaultRegion)
{
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(DEFAULT_DEVICENAME, m_deviceName);
m_configurationRep.setValue(DEFAULT_LOCATION, m_location);
- m_configurationRep.setValue(DEFAULT_SYSTIME, m_systemTime);
+ m_configurationRep.setValue(DEFAULT_LOCATIONNAME, m_locationName);
m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
m_configurationRep.setValue(DEFAULT_REGION, m_region);
m_configurationRep.setUri(m_configurationUri);
{
std::string value;
+ if (rep.getValue(DEFAULT_DEVICENAME, value))
+ {
+ m_deviceName = value;
+ dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_deviceName: %s",
+ m_deviceName.c_str());
+ }
+
if (rep.getValue(DEFAULT_LOCATION, value))
{
m_location = value;
m_location.c_str());
}
- if (rep.getValue(DEFAULT_SYSTIME, value))
+ if (rep.getValue(DEFAULT_LOCATIONNAME, value))
{
- dlog_print(DLOG_INFO, "ConfigurationResource", "#### SystemTime is not"
- "allowed to be written");
+ m_locationName = value;
+ dlog_print(DLOG_INFO, "ConfigurationResource", "#### m_locationName: %s",
+ m_locationName.c_str());
}
if (rep.getValue(DEFAULT_CURRENCY, value))
OCRepresentation ConfigurationResource::getConfigurationRepresentation()
{
+ m_configurationRep.setValue(DEFAULT_DEVICENAME, m_deviceName);
m_configurationRep.setValue(DEFAULT_LOCATION, m_location);
- m_configurationRep.setValue(DEFAULT_SYSTIME, m_systemTime);
+ m_configurationRep.setValue(DEFAULT_LOCATIONNAME, m_locationName);
m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
m_configurationRep.setValue(DEFAULT_REGION, m_region);
// Assigns default values to all the attributes of the configuration resource
void ConfigurationResource::factoryReset()
{
+ m_deviceName = defaultDeviceName;
m_location = defaultLocation;
- m_systemTime = defaultSystemTime;
+ m_locationName = defaultLocationName;
m_currency = defaultCurrency;
m_region = defaultRegion;
}
#include "ThingsConfiguration.h"
#include "ThingsMaintenance.h"
#include "configurationresource.h"
-#include "diagnosticsresource.h"
+#include "maintenanceresource.h"
#include "factorysetresource.h"
using namespace OC;
/* Default system configuration value's variables
The variable's names should be same as the names of "extern" variables defined in
"configurationresource.h" */
+std::string defaultDeviceName;
std::string defaultLocation;
+std::string defaultLocationName;
std::string defaultRegion;
-std::string defaultSystemTime;
std::string defaultCurrency;
static ThingsConfiguration *g_thingsConf;
logMessage += "URI : " + rep.getUri() + "<br>";
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);
+ defaultLocationName = rep.getValue< std::string >(DEFAULT_LOCATIONNAME);
+ defaultDeviceName = rep.getValue< std::string >(DEFAULT_DEVICENAME);
+ logMessage += "Device Name : " + defaultDeviceName + "<br>";
logMessage += "Location : " + defaultLocation + "<br>";
- logMessage += "SystemTime : " + defaultSystemTime + "<br>";
+ logMessage += "Location Name : " + defaultLocationName + "<br>";
logMessage += "currency : " + defaultCurrency + "<br>";
logMessage += "Region : " + defaultRegion + "<br>";
{
std::string value;
+ if (rep.getValue(DEFAULT_DEVICENAME, value))
+ {
+ m_deviceName = value;
+ dlog_print(DLOG_INFO, "FactorySetResource", "#### m_deviceName: %s",
+ m_deviceName.c_str());
+ }
+
if (rep.getValue(DEFAULT_LOCATION, value))
{
m_location = value;
m_location.c_str());
}
- if (rep.getValue(DEFAULT_SYSTIME, value))
+ if (rep.getValue(DEFAULT_LOCATIONNAME, value))
{
- dlog_print(DLOG_INFO, "FactorySetResource", "#### SystemTime is not"
- "allowed to be written");
+ m_locationName = value;
+ dlog_print(DLOG_INFO, "FactorySetResource", "#### m_locationName: %s",
+ m_locationName.c_str());
}
if (rep.getValue(DEFAULT_CURRENCY, value))
OCRepresentation FactorySetResource::getFactorySetRepresentation()
{
+ m_configurationRep.setValue(DEFAULT_DEVICENAME, m_deviceName);
m_configurationRep.setValue(DEFAULT_LOCATION, m_location);
- m_configurationRep.setValue(DEFAULT_SYSTIME, m_systemTime);
+ m_configurationRep.setValue(DEFAULT_LOCATIONNAME, m_locationName);
m_configurationRep.setValue(DEFAULT_CURRENCY, m_currency);
m_configurationRep.setValue(DEFAULT_REGION, m_region);
*
******************************************************************/
-#include "diagnosticsresource.h"
+#include "maintenanceresource.h"
#include <functional>
#include <dlog.h>
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.setValue(DEFAULT_FACTORYRESET, m_factoryReset);
+ m_maintenanceRep.setValue(DEFAULT_REBOOT, m_reboot);
+ m_maintenanceRep.setValue(DEFAULT_STARTCOLLECTION, m_startStatCollection);
m_maintenanceRep.setUri(m_maintenanceUri);
m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
{
std::string value;
- if (rep.getValue("fr", value))
+ if (rep.getValue(DEFAULT_FACTORYRESET, value))
{
m_factoryReset = value;
dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_factoryReset: %s",
m_factoryReset.c_str());
}
- if (rep.getValue("rb", value))
+ if (rep.getValue(DEFAULT_REBOOT, value))
{
m_reboot = value;
dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_reboot: %s", m_reboot.c_str());
}
- if (rep.getValue("ssc", value))
+ if (rep.getValue(DEFAULT_STARTCOLLECTION, value))
{
m_startStatCollection = value;
dlog_print(DLOG_INFO, "MaintenanceResource", "#### m_startStatCollection: %s",
OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
{
- m_maintenanceRep.setValue("fr", m_factoryReset);
- m_maintenanceRep.setValue("rb", m_reboot);
- m_maintenanceRep.setValue("ssc", m_startStatCollection);
+ m_maintenanceRep.setValue(DEFAULT_FACTORYRESET, m_factoryReset);
+ m_maintenanceRep.setValue(DEFAULT_REBOOT, m_reboot);
+ m_maintenanceRep.setValue(DEFAULT_STARTCOLLECTION, m_startStatCollection);
return m_maintenanceRep;
}
*
******************************************************************/
-#ifndef __TMSAMPLEAPP_H__
-#define __TMSAMPLEAPP_H__
+#ifndef TMSAMPLEAPP_H__
+#define TMSAMPLEAPP_H__
#include <app.h>
#include <Elementary.h>
#define FINDGROUP_TIMEOUT 5
#define FINDRESOURCE_TIMEOUT 6
+#define DEFAULT_DEVICENAME "n"
#define DEFAULT_LOCATION "loc"
-#define DEFAULT_SYSTIME "st"
+#define DEFAULT_LOCATIONNAME "locn"
#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);
-#endif // __TMSAMPLEAPP_H__
\ No newline at end of file
+#endif // TMSAMPLEAPP_H__
\ No newline at end of file
using namespace std;
-#ifndef __TMUTIL_H__
-#define __TMUTIL_H__
+#ifndef TMUTIL_H__
+#define TMUTIL_H__
extern std::string getOCStackResultStringFromInt(int result);
-#endif // __TMUTIL_H__
\ No newline at end of file
+#endif // TMUTIL_H__
\ No newline at end of file
string MAINTENANCE_RESOURCE_URI = "/oic/mnt";
string FACTORYSET_RESOURCE_URI = "/factorySet";
-GroupManager *g_groupManager = new GroupManager();
-ThingsConfiguration *g_thingsConfig = new ThingsConfiguration();
-ThingsMaintenance *g_thingsMnt = new ThingsMaintenance();
+GroupManager *g_groupManager = nullptr;
+ThingsConfiguration *g_thingsConfig = nullptr;
+ThingsMaintenance *g_thingsMnt = nullptr;
typedef struct region_popup
string logMessage = "Resource URI: " + rep.getUri() + "<br>";
dlog_print(DLOG_INFO, LOG_TAG, "#### Resource URI: %s", rep.getUri().c_str());
+ if (rep.hasAttribute(DEFAULT_DEVICENAME))
+ {
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Device Name : %s",
+ rep.getValue< std::string >(DEFAULT_DEVICENAME).c_str());
+ logMessage = logMessage + "Device Name : " +
+ rep.getValue< std::string >(DEFAULT_DEVICENAME) + "<br>";
+ }
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(DEFAULT_SYSTIME))
+ if (rep.hasAttribute(DEFAULT_LOCATIONNAME))
{
- dlog_print(DLOG_INFO, LOG_TAG, "#### SystemTime : %s",
- rep.getValue< std::string >("st").c_str());
- logMessage = logMessage + "SystemTime : " + rep.getValue< std::string >("st") + "<br>";
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Location Name : %s",
+ rep.getValue< std::string >(DEFAULT_LOCATIONNAME).c_str());
+ logMessage = logMessage + "Location Name: " +
+ rep.getValue< std::string >(DEFAULT_LOCATIONNAME) + "<br>";
}
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(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>";
dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.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(DEFAULT_DEVICENAME))
+ {
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Device Name : %s",
+ rep.getValue< std::string >(DEFAULT_DEVICENAME).c_str());
+ logMessage = logMessage + "Device Name : "
+ + rep.getValue< std::string >(DEFAULT_DEVICENAME) + "<br>";
+ }
if (rep.hasAttribute(DEFAULT_LOCATION))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Location : %s",
rep.getValue< std::string >(DEFAULT_LOCATION).c_str());
- logMessage = logMessage + "Location : " + rep.getValue< std::string >(DEFAULT_LOCATION) + "<br>";
+ logMessage = logMessage + "Location : "
+ + rep.getValue< std::string >(DEFAULT_LOCATION) + "<br>";
}
- if (rep.hasAttribute(DEFAULT_SYSTIME))
+ if (rep.hasAttribute(DEFAULT_LOCATIONNAME))
{
- dlog_print(DLOG_INFO, LOG_TAG, "#### SystemTime : %s",
- rep.getValue< std::string >(DEFAULT_SYSTIME).c_str());
- logMessage = logMessage + "SystemTime : " + rep.getValue< std::string >(DEFAULT_SYSTIME) + "<br>";
+ dlog_print(DLOG_INFO, LOG_TAG, "#### Location Name : %s",
+ rep.getValue< std::string >(DEFAULT_LOCATIONNAME).c_str());
+ logMessage = logMessage + "Location Name : "
+ + rep.getValue< std::string >(DEFAULT_LOCATIONNAME) + "<br>";
}
if (rep.hasAttribute(DEFAULT_CURRENCY))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Currency : %s",
rep.getValue< std::string >(DEFAULT_CURRENCY).c_str());
- logMessage = logMessage + "Currency : " + rep.getValue< std::string >(DEFAULT_CURRENCY) + "<br>";
+ logMessage = logMessage + "Currency : "
+ + rep.getValue< std::string >(DEFAULT_CURRENCY) + "<br>";
}
if (rep.hasAttribute(DEFAULT_REGION))
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Region : %s",
rep.getValue< std::string >(DEFAULT_REGION).c_str());
- logMessage = logMessage + "Region : " + rep.getValue< std::string >(DEFAULT_REGION) + "<br>";
+ logMessage = logMessage + "Region : "
+ + rep.getValue< std::string >(DEFAULT_REGION) + "<br>";
}
logMessage += "----------------------<br>";
}
OCStackResult result;
- ConfigurationName name = "r";
+ ConfigurationName name = DEFAULT_REGION;
ConfigurationValue value = newRegionValue;
std::map< ConfigurationName, ConfigurationValue > configurations;
createResourceCollection(FACTORYSET_COLLECTION_RESOURCE_URI,
FACTORYSET_COLLECTION_RESOURCE_TYPE,
setCollectionHandle);
+
+ g_groupManager = new GroupManager();
+ g_thingsConfig = new ThingsConfiguration();
+ g_thingsMnt = new ThingsMaintenance();
}
// Deletes all the resources
{
dlog_print(DLOG_INFO, LOG_TAG, "#### Destroy sequence called");
- deleteResource(configurationCollectionHandle, configurationFoundHandle);
+ deleteResource(setCollectionHandle, setFoundHandle);
deleteResource(maintenanceCollectionHandle, maintenanceFoundHandle);
- deleteResource(setCollectionHandle, setFoundHandle);
+ deleteResource(configurationCollectionHandle, configurationFoundHandle);
+
+ delete g_thingsMnt;
+ delete g_thingsConfig;
+ delete g_groupManager;
dlog_print(DLOG_INFO, LOG_TAG, "#### Resources destroyed successfully");
}