void BMISensorBundleActivator::createResource(resourceInfo resourceInfo)
{
- if (resourceInfo.resourceType == "oic.softsensor")
+ if (resourceInfo.resourceType == "oic.r.sensor")
{
static int BMISensorCount = 1;
}
extern "C" void bmisensor_externalActivateBundle(ResourceContainerBundleAPI *resourceContainer,
- std::string bundleId)
+ std::string bundleId)
{
bundle = new BMISensorBundleActivator();
bundle->activateBundle(resourceContainer, bundleId);
#define COAP_MODE OC::ModeType::Server
#define COAP_SRVTYPE OC::ServiceType::InProc
-#define RESOURCE_TYPE_NAME "oic.sensor.height"
+#define RESOURCE_TYPE_NAME "oic.r.sensor.height"
// testing case
#define INTERVAL_FOR_CHECK 4 // seconds
#define COAP_MODE OC::ModeType::Server
#define COAP_SRVTYPE OC::ServiceType::InProc
-#define RESOURCE_TYPE_NAME "oic.sensor.weight"
+#define RESOURCE_TYPE_NAME "oic.r.sensor.weight"
// testing case
#define INTERVAL_FOR_CHECK 14 // seconds
std::map<string, string> resourceParams;
cout << "Press enter to add SO bundle resource " << endl;
getchar();
- resourceParams["resourceType"] = "oic.light.control";
+ resourceParams["resourceType"] = "oic.r.light";
resourceParams["address"] = "http://192.168.0.2/api/newdeveloper/lights/1";
container->addResourceConfig("oic.bundle.hueSample", "", resourceParams);
container->addResourceConfig("oic.bundle.hueSample", "", resourceParams);
{
std::cout << "\t\t" << resourceTypes << std::endl;
- if (resourceTypes == "oic.light.control")
+ if (resourceTypes == "oic.r.light")
{
curResource = resource;
// Call a local function which will internally invoke get API on the resource pointer
void DISensorBundleActivator::createResource(resourceInfo resourceInfo)
{
- if (resourceInfo.resourceType == "oic.softsensor")
+ if (resourceInfo.resourceType == "oic.r.sensor")
{
static int discomfortIndexSensorCount = 1;
}
extern "C" void disensor_externalActivateBundle(ResourceContainerBundleAPI *resourceContainer,
- std::string bundleId)
+ std::string bundleId)
{
bundle = new DISensorBundleActivator();
bundle->activateBundle(resourceContainer, bundleId);
#define COAP_MODE OC::ModeType::Server
#define COAP_SRVTYPE OC::ServiceType::InProc
-#define RESOURCE_TYPE_NAME_TEMP "oic.sensor.temperature"
-#define RESOURCE_TYPE_NAME_HUMID "oic.sensor.humidity"
+#define RESOURCE_TYPE_NAME_TEMP "oic.r.temperature"
+#define RESOURCE_TYPE_NAME_HUMID "oic.r.humidity"
// Forward declaring the entityHandler
#define COAP_MODE OC::ModeType::Server
#define COAP_SRVTYPE OC::ServiceType::InProc
-#define RESOURCE_TYPE_NAME_TEMP "oic.sensor.temperature"
-#define RESOURCE_TYPE_NAME_HUMID "oic.sensor.humidity"
+#define RESOURCE_TYPE_NAME_TEMP "oic.r.temperature"
+#define RESOURCE_TYPE_NAME_HUMID "oic.r.humidity"
class TemphumidResource
void HueSampleBundleActivator::createResource(resourceInfo resourceInfo)
{
- if (resourceInfo.resourceType == "oic.light.control")
+ if (resourceInfo.resourceType == "oic.r.light")
{
static int lightCount = 1;
HueLight *hueLight = new HueLight(m_connector, resourceInfo.address);
}
extern "C" void huesample_externalActivateBundle(ResourceContainerBundleAPI *resourceContainer,
- std::string bundleId)
+ std::string bundleId)
{
bundle = new HueSampleBundleActivator();
bundle->activateBundle(resourceContainer, bundleId);
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<container>
+<container>
<bundle>
<id>oic.bundle.discomfortIndexSensor</id>
<path>libDISensorBundle.so</path>
<resources>
<resourceInfo>
<name>DiscomfortIndexSensor1</name>
- <resourceType>oic.softsensor</resourceType>
+ <resourceType>oic.r.sensor</resourceType>
<outputs>
<output>
<name>discomfortIndex</name>
<input>
<name>humidity</name>
<type>double</type>
- <resourceType>oic.sensor.humidity</resourceType>
+ <resourceType>oic.r.humidity</resourceType>
</input>
<input>
<name>temperature</name>
<type>double</type>
- <resourceType>oic.sensor.temperature</resourceType>
+ <resourceType>oic.r.temperature</resourceType>
</input>
</inputs>
</resourceInfo>
<resources>
<resourceInfo>
<name>BMISensor1</name>
- <resourceType>oic.softsensor</resourceType>
+ <resourceType>oic.r.sensor</resourceType>
<outputs>
<output>
<name>BMIresult</name>
<input>
<name>weight</name>
<type>double</type>
- <resourceType>oic.sensor.weight</resourceType>
+ <resourceType>oic.r.sensor.weight</resourceType>
<resourceUri>/Thing_WeightSensor</resourceUri>
</input>
<input>
<name>height</name>
<type>double</type>
- <resourceType>oic.sensor.height</resourceType>
+ <resourceType>oic.r.sensor.height</resourceType>
<resourceUri>/Thing_HeightSensor</resourceUri>
</input>
</inputs>
<resources>
<resourceInfo>
<name>light</name>
- <resourceType>oic.light.control</resourceType>
+ <resourceType>oic.r.light</resourceType>
<address>http://192.168.0.2/api/newdeveloper/lights/1</address>
</resourceInfo>
</resources>
<resourceInfo>
<name>light</name>
<uri>light/1</uri>
- <resourceType>oic.light.control</resourceType>
+ <resourceType>oic.r.light</resourceType>
<address>http://192.168.0.2/api/newdeveloper/lights/1</address>
</resourceInfo>
</resources>
</bundle>
-->
-</container>
+</container>
\ No newline at end of file
{
pUpdatedCB = nullptr;
isStartedDiscovery = false;
+ discoveryTask = nullptr;
pUpdatedCBFromServer = std::bind(&DiscoverResourceUnit::onUpdate, this,
std::placeholders::_1, std::placeholders::_2);
DiscoverResourceUnit::~DiscoverResourceUnit()
{
pUpdatedCB = nullptr;
+ discoveryTask = nullptr;
pUpdatedCBFromServer = nullptr;
m_vecRemoteResource.clear();
}
discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
- RCSAddress::multicast(), m_ResourceType, pDiscoveredCB);
+ RCSAddress::multicast(), m_ResourceType, pDiscoveredCB);
}
catch (RCSInvalidParameterException &e)
{
}
}
return false;
-}
\ No newline at end of file
+}
std::string(m_bundles[id]->getID()).c_str());
activationLock.lock();
auto f = std::bind(&ResourceContainerImpl::activateBundleThread, this,
- id);
+ id);
boost::thread activator(f);
activator.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
activationLock.unlock();
OC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
std::string(m_bundles[id]->getID()).c_str());
-}
+ }
void ResourceContainerImpl::deactivateBundle(const std::string &id)
{
m_mapResources[strUri] = resource;
m_mapBundleResources[resource->m_bundleId].push_back(strUri);
- resource->registerObserver(this);
-
server->setGetRequestHandler(
std::bind(&ResourceContainerImpl::getRequestHandler, this,
std::placeholders::_1, std::placeholders::_2));
RCSResourceObject::Ptr ResourceContainerImpl::buildResourceObject(const std::string &strUri,
const std::string &strResourceType)
{
- return RCSResourceObject::Builder(strUri, strResourceType, "DEFAULT_INTERFACE").setObservable(
+ return RCSResourceObject::Builder(strUri, strResourceType, "oic.if.baseline").setObservable(
true).setDiscoverable(true).build();
}
void ResourceContainerImpl::activateBundleThread(const std::string &id)
{
OC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
- std::string(m_bundles[id]->getID()).c_str());
+ std::string(m_bundles[id]->getID()).c_str());
if (m_bundles[id]->getJavaBundle())
{
}
OC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
- std::string(m_bundles[id]->getID()).c_str());
+ std::string(m_bundles[id]->getID()).c_str());
}
#if(JAVA_SUPPORT)
{
std::list<string> resources;
std::map<string, string> resourceParams;
- resourceParams["resourceType"] = "oic.test";
+ resourceParams["resourceType"] = "container.test";
m_pResourceContainer->startContainer(m_strConfigPath);
resources = m_pResourceContainer->listBundleResources("oic.bundle.test");
m_pBundleResource = new TestBundleResource();
m_pBundleResource->m_bundleId = "oic.bundle.test";
m_pBundleResource->m_uri = "/test_resource";
- m_pBundleResource->m_resourceType = "oic.test";
+ m_pBundleResource->m_resourceType = "container.test";
}
};
m_pBundleResource = new TestBundleResource();
m_pBundleResource->m_bundleId = "oic.bundle.test";
m_pBundleResource->m_uri = "/test_resource/test";
- m_pBundleResource->m_resourceType = "oic.test";
+ m_pBundleResource->m_resourceType = "container.test";
mocks.ExpectCallFunc(ResourceContainerImpl::buildResourceObject).With(m_pBundleResource->m_uri,
m_pBundleResource->m_resourceType).Return(nullptr);
result = *resourceConfig.begin();
EXPECT_STREQ("test_resource", result.name.c_str());
- EXPECT_STREQ("oic.test", result.resourceType.c_str());
+ EXPECT_STREQ("container.test", result.resourceType.c_str());
((ResourceContainerImpl *)m_pResourceContainer)->stopContainer();
}
EXPECT_FALSE(((BundleInfoInternal *)m_pBundleInfo)->isActivated());
}
+
/* Test for Configuration */
TEST(ConfigurationTest, ConfigFileLoadedWithValidPath)
{
Configuration *config = new Configuration(strConfigPath);
EXPECT_TRUE(config->isLoaded());
+
+ delete config;
}
TEST(ConfigurationTest, ConfigFileNotLoadedWithInvalidPath)
Configuration *config = new Configuration("InvalidPath");
EXPECT_FALSE(config->isLoaded());
+
+ delete config;
}
TEST(ConfigurationTest, BundleConfigurationListParsed)
EXPECT_STREQ("oic.bundle.test", results["id"].c_str());
EXPECT_STREQ("libTestBundle.so", results["path"].c_str());
EXPECT_STREQ("1.0.0", results["version"].c_str());
+
+ delete config;
}
TEST(ConfigurationTest, BundleConfigurationParsedWithValidBundleId)
EXPECT_STREQ("oic.bundle.test", results["id"].c_str());
EXPECT_STREQ("libTestBundle.so", results["path"].c_str());
EXPECT_STREQ("1.0.0", results["version"].c_str());
+
+ delete config;
}
TEST(ConfigurationTest, BundleConfigurationNotParsedWithInvalidBundleId)
config->getBundleConfiguration("test", &bundles);
EXPECT_TRUE(bundles.empty());
+
+ delete config;
}
TEST(ConfigurationTest, BundleResourceConfigurationListParsed)
result = *resourceConfig.begin();
EXPECT_STREQ("test_resource", result.name.c_str());
- EXPECT_STREQ("oic.test", result.resourceType.c_str());
+ EXPECT_STREQ("container.test", result.resourceType.c_str());
+
+ delete config;
}
TEST(ConfigurationTest, BundleResourceConfigurationNotParsedWithInvalidBundleId)
config->getResourceConfiguration("test", &resourceConfig);
EXPECT_TRUE(bundles.empty());
+
+ delete config;
}
namespace
<resources>
<resourceInfo>
<name>test_resource</name>
- <resourceType>oic.test</resourceType>
+ <resourceType>container.test</resourceType>
</resourceInfo>
</resources>
</bundle>
-</container>
+</container>
\ No newline at end of file
mutexForDiscovery(),
MULTICASTURI("/oic/res"),
RESOURCEURI("/a/TempHumSensor/Container"),
- RESOURCETYPE("Resource.Container"),
+ RESOURCETYPE("resource.container"),
RESOURCEINTERFACE("oic.if.baseline"),
ATTR_KEY("Temperature"),
ATTR_VALUE(0)
try
{
discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
- RCSAddress::multicast(), MULTICASTURI, resourceType,
- std::bind(onDiscoveryResource, std::placeholders::_1,
- std::weak_ptr<ResourceContainerTestSimulator>(shared_from_this())));
+ RCSAddress::multicast(), MULTICASTURI, resourceType,
+ std::bind(onDiscoveryResource, std::placeholders::_1,
+ std::weak_ptr<ResourceContainerTestSimulator>(shared_from_this())));
mutexForDiscovery.lock();
}
catch (std::exception &e)