From 08ee7c41e9b7bb64243fd1dc1f416e53aad6f1d1 Mon Sep 17 00:00:00 2001 From: Markus Jung Date: Tue, 5 Apr 2016 13:38:40 +0900 Subject: [PATCH] [IOT-1065][IOT-1069] RC - Tizen: sample application fix - Correct sample configuration - Deactivate notification on bundle resource initialization - Remove BMI related UI for Tizen. Soft-sensors cannot be configered at runtime. This will be a feature for the next release. - Removed async bundle activation which is causing crashes in Tizen Change-Id: Id87a36b1cb27d4267433823494415e35d2c6acee Signed-off-by: Markus Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/7593 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../examples/HueSampleBundle/src/HueLight.cpp | 6 +- .../lib/ResourceContainerConfig.xml | 12 ++-- .../tizen/ContainerServerApp/src/container.cpp | 14 +--- service/resource-container/src/BundleResource.cpp | 2 +- .../src/ResourceContainerImpl.cpp | 83 +++++++++++----------- .../resource-container/src/ResourceContainerImpl.h | 2 - 6 files changed, 52 insertions(+), 67 deletions(-) diff --git a/service/resource-container/examples/HueSampleBundle/src/HueLight.cpp b/service/resource-container/examples/HueSampleBundle/src/HueLight.cpp index 90ae1a1..ba77414 100644 --- a/service/resource-container/examples/HueSampleBundle/src/HueLight.cpp +++ b/service/resource-container/examples/HueSampleBundle/src/HueLight.cpp @@ -44,9 +44,9 @@ HueLight::~HueLight() void HueLight::initAttributes() { - BundleResource::setAttribute("on-off", false); - BundleResource::setAttribute("dim", 0); - BundleResource::setAttribute("color", 0); + BundleResource::setAttribute("on-off", false, false); + BundleResource::setAttribute("dim", 0, false); + BundleResource::setAttribute("color", 0, false); } RCSResourceAttributes HueLight::handleGetAttributesRequest() diff --git a/service/resource-container/examples/tizen/ContainerServerApp/lib/ResourceContainerConfig.xml b/service/resource-container/examples/tizen/ContainerServerApp/lib/ResourceContainerConfig.xml index 3dfc9a9..9938053 100644 --- a/service/resource-container/examples/tizen/ContainerServerApp/lib/ResourceContainerConfig.xml +++ b/service/resource-container/examples/tizen/ContainerServerApp/lib/ResourceContainerConfig.xml @@ -6,11 +6,11 @@ huesample 1.0.0 - - light - oic.r.control -
http://192.168.0.2/api/newdeveloper/lights/1
-
+
- + + + + + diff --git a/service/resource-container/examples/tizen/ContainerServerApp/src/container.cpp b/service/resource-container/examples/tizen/ContainerServerApp/src/container.cpp index eb5572b..64652d5 100644 --- a/service/resource-container/examples/tizen/ContainerServerApp/src/container.cpp +++ b/service/resource-container/examples/tizen/ContainerServerApp/src/container.cpp @@ -528,18 +528,6 @@ void *showContainerAPIs(void *data) elm_list_item_append(listnew, "4. Remove HUE Bundle Resource", NULL, NULL, removeHueResourceConfig, NULL); - elm_list_item_append(listnew, "5. Add BMI Bundle", NULL, NULL, - addBMIBundle, NULL); - - elm_list_item_append(listnew, "6. Start BMI Bundle", NULL, NULL, - startBMIBundle, NULL); - - elm_list_item_append(listnew, "7. Remove BMI Bundle", NULL, NULL, - removeBMIBundle, NULL); - - elm_list_item_append(listnew, "8. Stop BMI Bundle", NULL, NULL, - stopBMIBundle, NULL); - elm_list_go(listnew); } return NULL; @@ -593,8 +581,8 @@ static void stopContainer(void *data, Evas_Object *obj, void *event_info) if (checkContainer) { s_containerFlag = false; - removeHueBundle(NULL, NULL, NULL); stopHueBundle(NULL, NULL, NULL); + removeHueBundle(NULL, NULL, NULL); container->stopContainer(); logMessage += "CONTAINER STOPPED
"; diff --git a/service/resource-container/src/BundleResource.cpp b/service/resource-container/src/BundleResource.cpp index 5b38edc..f39e77c 100644 --- a/service/resource-container/src/BundleResource.cpp +++ b/service/resource-container/src/BundleResource.cpp @@ -32,7 +32,7 @@ namespace OIC { namespace Service { - BundleResource::BundleResource() : m_pNotiReceiver(nullptr) + BundleResource::BundleResource() : m_pNotiReceiver(nullptr), m_resourceAttributes_mutex() { } diff --git a/service/resource-container/src/ResourceContainerImpl.cpp b/service/resource-container/src/ResourceContainerImpl.cpp index a25bc9a..ff04522 100644 --- a/service/resource-container/src/ResourceContainerImpl.cpp +++ b/service/resource-container/src/ResourceContainerImpl.cpp @@ -68,58 +68,53 @@ namespace OIC activationLock.lock(); - if (!configFile.empty()) - { - m_config = new Configuration(configFile); - - if (m_config->isLoaded()) + try{ + if (!configFile.empty()) { - configInfo bundles; - m_config->getConfiguredBundles(&bundles); + m_config = new Configuration(configFile); - for (unsigned int i = 0; i < bundles.size(); i++) + if (m_config->isLoaded()) { - shared_ptr bundleInfo(new BundleInfoInternal); - bundleInfo->setPath(bundles[i][BUNDLE_PATH]); - bundleInfo->setVersion(bundles[i][BUNDLE_VERSION]); - bundleInfo->setID(bundles[i][BUNDLE_ID]); - if (!bundles[i][BUNDLE_ACTIVATOR].empty()) + configInfo bundles; + m_config->getConfiguredBundles(&bundles); + + for (unsigned int i = 0; i < bundles.size(); i++) { - string activatorName = bundles[i][BUNDLE_ACTIVATOR]; - std::replace(activatorName.begin(), activatorName.end(), '.', '/'); - bundleInfo->setActivatorName(activatorName); - bundleInfo->setLibraryPath(bundles[i][BUNDLE_LIBRARY_PATH]); - } + shared_ptr bundleInfo(new BundleInfoInternal); + bundleInfo->setPath(bundles[i][BUNDLE_PATH]); + bundleInfo->setVersion(bundles[i][BUNDLE_VERSION]); + bundleInfo->setID(bundles[i][BUNDLE_ID]); + if (!bundles[i][BUNDLE_ACTIVATOR].empty()) + { + string activatorName = bundles[i][BUNDLE_ACTIVATOR]; + std::replace(activatorName.begin(), activatorName.end(), '.', '/'); + bundleInfo->setActivatorName(activatorName); + bundleInfo->setLibraryPath(bundles[i][BUNDLE_LIBRARY_PATH]); + } - OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)", - std::string(bundles[i][BUNDLE_ID] + ";" + - bundles[i][BUNDLE_PATH]).c_str()); + OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)", + std::string(bundles[i][BUNDLE_ID] + ";" + + bundles[i][BUNDLE_PATH]).c_str()); - registerBundle(bundleInfo); - activateBundle(bundleInfo); + registerBundle(bundleInfo); + activateBundle(bundleInfo); + } + } + else + { + OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path."); } } else { - OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path."); + OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided."); } - } - else - { - OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided."); - } - - map::iterator activatorIterator; - for (activatorIterator = m_activators.begin(); activatorIterator != m_activators.end(); - activatorIterator++) - { - activatorIterator->second.timed_join( - boost::posix_time::seconds(BUNDLE_ACTIVATION_WAIT_SEC)); - // wait for bundles to be activated + OIC_LOG(INFO, CONTAINER_TAG, "Resource container started."); + }catch(...){ + OIC_LOG(INFO, CONTAINER_TAG, "Resource container failed starting."); } activationLock.unlock(); - OIC_LOG(INFO, CONTAINER_TAG, "Resource container started."); } void ResourceContainerImpl::stopContainer() @@ -178,11 +173,15 @@ namespace OIC { OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)", std::string(m_bundles[id]->getID()).c_str()); + activationLock.lock(); - auto f = std::bind(&ResourceContainerImpl::activateBundleThread, this, - id); - boost::thread activator(f); - activator.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC)); + try{ + activateBundleThread(id); + } + catch(...){ + OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s) failed", + std::string(m_bundles[id]->getID()).c_str()); + } activationLock.unlock(); OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)", std::string(m_bundles[id]->getID()).c_str()); diff --git a/service/resource-container/src/ResourceContainerImpl.h b/service/resource-container/src/ResourceContainerImpl.h index b7cb614..5d5f81b 100644 --- a/service/resource-container/src/ResourceContainerImpl.h +++ b/service/resource-container/src/ResourceContainerImpl.h @@ -107,8 +107,6 @@ namespace OIC // string m_configFile; Configuration *m_config; - // holds for a bundle the threads for bundle activation - map< std::string, boost::thread > m_activators; // used for synchronize the resource registration of multiple bundles std::mutex registrationLock; // used to synchronize the startup of the container with other operation -- 2.7.4