Merge "Merge branch '1.3-rel' (df031b0)"
authorC.J. Collier <cjcollier@linuxfoundation.org>
Thu, 1 Mar 2018 16:02:38 +0000 (16:02 +0000)
committerC.J. Collier <cjcollier@linuxfoundation.org>
Thu, 1 Mar 2018 16:02:38 +0000 (16:02 +0000)
73 files changed:
build_common/linux/SConscript
examples/OICMiddle/Server.cpp
extlibs/libcoap/SConscript
extlibs/yaml/SConscript
java/jni/JniCaInterface.c
plugins/samples/linux/IotivityandZigbeeClient.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/test/stacktests.cpp
resource/examples/SConscript
resource/examples/ocf_light/BinarySwitchResource.cpp [new file with mode: 0644]
resource/examples/ocf_light/BinarySwitchResource.h [new file with mode: 0644]
resource/examples/ocf_light/DimmingLightServer.cpp [new file with mode: 0644]
resource/examples/ocf_light/DimmingLightServer.h [new file with mode: 0644]
resource/examples/ocf_light/DimmingResource.cpp [new file with mode: 0644]
resource/examples/ocf_light/DimmingResource.h [new file with mode: 0644]
resource/examples/ocf_light/PICS.json [new file with mode: 0644]
resource/examples/ocf_light/Platform.cpp [new file with mode: 0644]
resource/examples/ocf_light/Platform.h [new file with mode: 0644]
resource/examples/ocf_light/Resource.h [new file with mode: 0644]
resource/examples/ocf_light/SConscript [new file with mode: 0644]
resource/examples/ocf_light/dimming_light_server.cpp [new file with mode: 0644]
resource/examples/ocf_light/oic_svr_db_server_mvjustworks.dat [new file with mode: 0644]
resource/examples/ocf_light/readme.md [new file with mode: 0644]
resource/examples/ocf_light/server_introspection.dat [new file with mode: 0644]
resource/examples/ocf_light/server_security.dat [new file with mode: 0644]
resource/examples/ocf_light/server_security.dat-org [new file with mode: 0644]
resource/examples/ocf_light/svr_server-justworks.json [new file with mode: 0644]
resource/examples/ocf_light/svr_server.json [new file with mode: 0644]
resource/examples/ocf_light/svr_server.json.cbor [new file with mode: 0644]
resource/src/OCResource.cpp
service/coap-http-proxy/src/CoapHttpParser.c
service/notification/cpp-wrapper/consumer/inc/NSProvider.h
service/notification/cpp-wrapper/consumer/src/NSProvider.cpp
service/notification/cpp-wrapper/examples/linux/notificationserviceprovider.cpp
service/notification/examples/linux/notificationprovider.c
service/notification/include/NSConsumerInterface.h
service/notification/src/common/NSUtil.c
service/notification/src/common/NSUtil.h
service/notification/src/consumer/NSConsumerCommon.c
service/notification/src/consumer/NSConsumerCommon.h
service/notification/src/consumer/NSConsumerInterface.c
service/notification/src/consumer/NSConsumerInternalTaskController.c
service/notification/src/consumer/NSConsumerInternalTaskController.h
service/notification/src/consumer/NSConsumerMemoryCache.c
service/notification/src/consumer/NSConsumerMemoryCache.h
service/notification/src/consumer/NSConsumerNetworkEventListener.c
service/notification/src/consumer/NSConsumerNetworkEventListener.h
service/notification/src/consumer/NSConsumerQueue.c
service/notification/src/consumer/NSConsumerQueue.h
service/notification/src/consumer/NSConsumerScheduler.c
service/notification/src/consumer/NSConsumerScheduler.h
service/notification/src/consumer/NSConsumerSystem.c
service/notification/src/consumer/NSConsumerSystem.h
service/notification/src/consumer/NSThread.c
service/notification/src/consumer/NSThread.h
service/notification/src/provider/NSProviderDiscovery.c
service/notification/src/provider/NSProviderDiscovery.h
service/notification/src/provider/NSProviderInterface.c
service/notification/src/provider/NSProviderMemoryCache.c
service/notification/src/provider/NSProviderMemoryCache.h
service/notification/src/provider/NSProviderNotification.h
service/notification/src/provider/NSProviderResource.c
service/notification/src/provider/NSProviderResource.h
service/notification/src/provider/NSProviderScheduler.c
service/notification/src/provider/NSProviderScheduler.h
service/notification/src/provider/NSProviderSubscription.c
service/notification/src/provider/NSProviderSubscription.h
service/notification/src/provider/NSProviderSystem.c
service/notification/src/provider/NSProviderSystem.h
service/notification/src/provider/NSProviderTopic.c
service/notification/src/provider/NSProviderTopic.h
tools/tizen/.gbs.conf

index 2c7c47f..1c3bb8b 100644 (file)
@@ -59,7 +59,7 @@ if LooseVersion(gcc_ver) < LooseVersion('5.0'):
     env.AppendUnique(CCFLAGS=['-Wno-missing-braces'])
 
 if env.get('ERROR_ON_WARN'):
-    env.AppendUnique(CFLAGS=['-Werror'])
+    env.AppendUnique(CCFLAGS=['-Werror'])
 
 # Set arch flags that match best TARGET_ARCH variable
 if not env.get('WITH_ENV'):
index 6d1de84..5699644 100644 (file)
@@ -45,7 +45,7 @@ OCEntityHandlerResult MiddleServer::entityHandler(const std::shared_ptr<OCResour
     int requestFlag = request->getRequestHandlerFlag();
     bool responseNeeded = false;
 
-    if (requestFlag && RequestHandlerFlag::RequestFlag) {
+    if (requestFlag & RequestHandlerFlag::RequestFlag) {
         if (requestType == "PUT") {
             responseNeeded = true;
         } else if (requestType == "GET") {
@@ -55,7 +55,7 @@ OCEntityHandlerResult MiddleServer::entityHandler(const std::shared_ptr<OCResour
         }
     }
 
-    if (requestFlag && RequestHandlerFlag::ObserverFlag) {
+    if (requestFlag & RequestHandlerFlag::ObserverFlag) {
     }
 
     if (responseNeeded) {
index 3a18d94..be4b6d9 100644 (file)
@@ -129,7 +129,7 @@ if target_os in ['linux', 'tizen', 'android']:
 
 # Remove -Werror build flag when building the 'coap' library  it
 # is external code. see IOT-2539
-while '-Werror' in libcoap_env['CFLAGS']: libcoap_env['CFLAGS'].remove('-Werror')
+while '-Werror' in libcoap_env['CCFLAGS']: libcoap_env['CCFLAGS'].remove('-Werror')
 
 ######################################################################
 # Source files and Target(s)
index 86f5ae3..17457c5 100644 (file)
@@ -45,7 +45,7 @@ yaml_env.AppendUnique(LIBS=['pthread'])
 
 # Remove -Werror build flag when building the 'YamlParser' library  it
 # is external code. see IOT-2539
-while '-Werror' in yaml_env['CFLAGS']: yaml_env['CFLAGS'].remove('-Werror')
+while '-Werror' in yaml_env['CCFLAGS']: yaml_env['CCFLAGS'].remove('-Werror')
 
 
 yaml_env.AppendUnique(
index 9d45c0a..e0691ab 100644 (file)
@@ -60,6 +60,7 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaInterface_initialize
 (JNIEnv *env, jclass clazz, jobject activity, jobject context)
 {
+    OC_UNUSED(clazz);
     LOGI("CaInterface_initialize");
 
     CANativeSetActivity(env, activity);
@@ -224,6 +225,7 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaInterface_caManagerInitialize(JNIEnv *env, jclass clazz,
                                                      jobject context, jobject listener)
 {
+    OC_UNUSED(clazz);
     LOGI("CaManager_initialize");
 
     CAUtilClientInitialize(env, g_jvm, context);
index 6a91d04..c766d2f 100644 (file)
@@ -379,6 +379,7 @@ void processUserInput(int resourceNo, int testCase)
                 OIC_LOG(ERROR, TAG, "Error creating payload. Not sending POST request");
                 promptUser = true;
             }
+            break;
         }
 
         case TEST_OBSERVE:
index 4e64661..98c19ec 100644 (file)
@@ -1257,15 +1257,15 @@ OCStackResult SRPSaveTrustCertChain(const uint8_t *trustCertChain, size_t chainS
 
     if (encodingType == OIC_ENCODING_PEM)
     {
-        cred->optionalData.data = (uint8_t *)OICCalloc(1, chainSize + 1);
-        VERIFY_NOT_NULL_RETURN(TAG, cred->optionalData.data, ERROR, OC_STACK_NO_MEMORY);
-        cred->optionalData.len = chainSize + 1;
+        cred->publicData.data = (uint8_t *)OICCalloc(1, chainSize + 1);
+        VERIFY_NOT_NULL_RETURN(TAG, cred->publicData.data, ERROR, OC_STACK_NO_MEMORY);
+        cred->publicData.len = chainSize + 1;
     }
     else if (encodingType == OIC_ENCODING_DER)
     {
-        cred->optionalData.data = (uint8_t *)OICCalloc(1, chainSize);
-        VERIFY_NOT_NULL_RETURN(TAG, cred->optionalData.data, ERROR, OC_STACK_NO_MEMORY);
-        cred->optionalData.len = chainSize;
+        cred->publicData.data = (uint8_t *)OICCalloc(1, chainSize);
+        VERIFY_NOT_NULL_RETURN(TAG, cred->publicData.data, ERROR, OC_STACK_NO_MEMORY);
+        cred->publicData.len = chainSize;
     }
     else
     {
@@ -1273,9 +1273,8 @@ OCStackResult SRPSaveTrustCertChain(const uint8_t *trustCertChain, size_t chainS
         DeleteCredList(cred);
         return OC_STACK_INVALID_PARAM;
     }
-    memcpy(cred->optionalData.data, trustCertChain, chainSize);
-    cred->optionalData.encoding = encodingType;
-    cred->optionalData.revstat = false;
+    memcpy(cred->publicData.data, trustCertChain, chainSize);
+    cred->publicData.encoding = encodingType;
 
     res = AddCredential(cred);
     if(res != OC_STACK_OK)
index dda821e..87cc7df 100644 (file)
@@ -1825,10 +1825,11 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const O
         for (size_t i = 0; i < infoSize; i++)
         {
             CAEndpoint_t *info = networkInfo + i;
+            OIC_LOG_V(DEBUG, TAG, "CATransportAdapter_t value = %d", info->adapter);
+            OIC_LOG_V(DEBUG, TAG, "info[%d], info->ifindex = %d, devAddr->ifindex = %d"
+                                  , (int)i, info->ifindex, devAddr->ifindex);
 
-            if (((CA_ADAPTER_IP | CA_ADAPTER_TCP) & info->adapter &&
-                 info->ifindex == devAddr->ifindex) ||
-                info->adapter == CA_ADAPTER_RFCOMM_BTEDR)
+            if ((CA_ADAPTER_IP | CA_ADAPTER_TCP) & info->adapter)
             {
                 OCTpsSchemeFlags matchedTps = OC_NO_TPS;
                 if (OC_STACK_OK != OCGetMatchedTpsFlags(info->adapter,
@@ -1855,7 +1856,7 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const O
                     OCStackResult ret = OCConvertTpsToString(matchedTps, &(tmpNode->tps));
                     if (ret != OC_STACK_OK)
                     {
-                        OIC_LOG_V(DEBUG, TAG, "OCConvertTpsToString(%s) is false", tmpNode->tps);
+                        OIC_LOG_V(ERROR, TAG, "OCConvertTpsToString(%s) is false", tmpNode->tps);
                         OCDiscoveryEndpointDestroy(tmpNode);
                         goto exit;
                     }
@@ -1900,10 +1901,6 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const O
                     }
                 }
             }
-            else
-            {
-                OIC_LOG_V(DEBUG, TAG, "CATransportAdapter_t value = %d", info->adapter);
-            }
         }
     }
 
index 9a0c30f..cca69c2 100644 (file)
@@ -3082,11 +3082,11 @@ TEST(LinksPayloadArray, BuildCollectionLinksPayloadArray)
 #endif
 #endif
         }
+        OCRepPayloadDestroy(policyMap);
         OCRepPayloadDestroy(linksMap[i]);
     }
 
     OICFree(linksMap);
-    OCRepPayloadDestroy(policyMap);
     OCRepPayloadDestroy(collectionPayload);
 
     //check for OCF1.0 logic
@@ -3138,6 +3138,7 @@ TEST(LinksPayloadArray, BuildCollectionLinksPayloadArray)
                 OIC_LOG_V(ERROR, TAG, "ep uri = %s \n", outUri);
             }
 
+            OICFree(outUri);
             OCRepPayloadDestroy(epsMap[k]);
         }
 
@@ -3158,11 +3159,13 @@ TEST(LinksPayloadArray, BuildCollectionLinksPayloadArray)
 #endif
 
         OCRepPayloadDestroy(linksMap[i]);
+        OCRepPayloadDestroy(policyMap);
         OICFree(epsMap);
     }
 
     OICFree(linksMap);
-    OCRepPayloadDestroy(policyMap);
+    OICFree(info);
+    OICFree(devAddr);
     OCRepPayloadDestroy(collectionPayload);
 
     EXPECT_EQ(OC_STACK_OK, OCStop());
index 4c55fe8..fb387eb 100644 (file)
@@ -148,6 +148,8 @@ if target_os in ['msys_nt', 'windows']:
         mediaserver = examples_env.Program('mediaserver', 'mediaserver.cpp')
         examples += [mediaserver]
 
+examples_env. SConscript('ocf_light/SConscript', exports='examples_env')
+
 examples_env.Alias("examples", examples)
 examples_env.AppendTarget('examples')
 examples_env.Alias("install", examples)
diff --git a/resource/examples/ocf_light/BinarySwitchResource.cpp b/resource/examples/ocf_light/BinarySwitchResource.cpp
new file mode 100644 (file)
index 0000000..4a6046d
--- /dev/null
@@ -0,0 +1,389 @@
+/*
+ * BinarySwitchResource.cpp
+ */
+#include <iostream>
+#include <vector>
+#include <thread>
+
+#include "BinarySwitchResource.h"
+#include "OCPlatform.h"
+
+#define INTERFACE_KEY "if"
+
+using namespace OC;
+namespace PH = std::placeholders;
+
+BinarySwitchResource::BinarySwitchResource():
+        m_notify_thread_active{true},
+        m_notify_thread{nullptr},
+        m_send_notification_flag{false},
+        m_cv_mutex{},
+        m_cv{},
+        m_nr_resource_types{1},
+        m_nr_resource_interfaces{2},
+        m_interestedObservers{},
+        m_var_value_rt{},
+        m_var_value_n{},
+        m_var_value_if{},
+        m_var_value_value{}
+{
+    std::cout << "- Running: BinarySwitchResource constructor" << std::endl;
+    std::string resourceURI = "/binaryswitch";
+
+    // VS2013 will fail list initialization so use array initialization
+    m_RESOURCE_TYPE[0] = "oic.r.switch.binary";
+    m_RESOURCE_INTERFACE[0] = "oic.if.baseline";
+    m_RESOURCE_INTERFACE[1] = "oic.if.a";
+    m_IF_UPDATE[0] = "oic.if.a";
+    m_IF_UPDATE[1] = "oic.if.rw";
+    m_IF_UPDATE[2] = "oic.if.baseline";
+    m_var_name_rt = "rt";
+    m_var_name_n = "n";
+    m_var_name_if = "if";
+    m_var_name_value = "value";
+
+    // initialize member variables /binaryswitch
+    // initialize vector rt
+    m_var_value_rt.push_back("oic.r.switch.binary");
+    m_var_value_n = "";  // current value of property "n"
+    // initialize vector if
+    m_var_value_if.push_back("oic.if.baseline");
+    m_var_value_if.push_back("oic.if.a");
+
+    m_var_value_value = true; // current value of property "value"
+
+    EntityHandler cb = std::bind(&BinarySwitchResource::entityHandler, this,PH::_1);
+    //uint8_t resourceProperty = 0;
+    OCStackResult result = OCPlatform::registerResource(m_resourceHandle,
+            resourceURI,
+            m_RESOURCE_TYPE[0],
+            m_RESOURCE_INTERFACE[0],
+            cb,
+            OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE );
+
+    // add the additional interfaces
+    std::cout << "\t" << "# resource interfaces: " << m_nr_resource_interfaces << std::endl;
+    std::cout << "\t" << "# resource types     : " << m_nr_resource_types << std::endl;
+    for( int a = 1; a < m_nr_resource_interfaces; a++)
+    {
+        OCStackResult result1 = OCBindResourceInterfaceToResource(m_resourceHandle, m_RESOURCE_INTERFACE[a].c_str());
+        if (result1 != OC_STACK_OK)
+            std::cerr << "Could not bind interface:" << m_RESOURCE_INTERFACE[a] << std::endl;
+    }
+    // add the additional resource types
+    for( int a = 1; a < m_nr_resource_types; a++ )
+    {
+        OCStackResult result2 = OCBindResourceTypeToResource(m_resourceHandle, m_RESOURCE_TYPE[a].c_str());
+        if (result2 != OC_STACK_OK)
+            std::cerr << "Could not bind resource type:" << m_RESOURCE_INTERFACE[a] << std::endl;
+    }
+
+    if(OC_STACK_OK != result)
+    {
+        throw std::runtime_error(
+                std::string("BinarySwitchResource failed to start")+std::to_string(result));
+    }
+
+    m_send_notification_flag = false;
+    m_notify_thread_active = true;
+    m_notify_thread = new std::thread(&BinarySwitchResource::notifyObservers, this);
+
+}
+
+BinarySwitchResource::~BinarySwitchResource()
+{
+    m_notify_thread_active = false;
+    m_cv.notify_all();
+    if(m_notify_thread->joinable())
+    {
+        m_notify_thread->join();
+    }
+}
+
+OC::OCRepresentation BinarySwitchResource::get(OC::QueryParamsMap queries)
+{
+    OC_UNUSED(queries);
+
+    m_rep.setValue(m_var_name_rt,  m_var_value_rt );
+    m_rep.setValue(m_var_name_n, m_var_value_n );
+    m_rep.setValue(m_var_name_if,  m_var_value_if );
+    m_rep.setValue(m_var_name_value, m_var_value_value );
+
+    return m_rep;
+}
+
+OCEntityHandlerResult BinarySwitchResource::post(OC::QueryParamsMap queries, const OC::OCRepresentation& rep)
+{
+    OCEntityHandlerResult ehResult = OC_EH_OK;
+    OC_UNUSED(queries);
+
+    try {
+        if (rep.hasAttribute(m_var_name_value))
+        {
+            // value exist in payload
+
+        }
+    }
+    catch (std::exception& e)
+    {
+        std::cout << e.what() << std::endl;
+    }
+
+    // TODO add check on array contents out of range, etc..
+
+    if (ehResult == OC_EH_OK)
+    {
+        // no error: assign the variables
+
+        // array only works for integer, boolean, numbers and strings
+        // TODO: make it also work with array of objects
+        try {
+            if (rep.hasAttribute(m_var_name_rt))
+            {
+                rep.getValue(m_var_name_rt, m_var_value_rt);
+                int first = 1;
+                std::cout << "\t\t" << "property 'rt' : " ;
+                for(auto myvar: m_var_value_rt)
+                {
+                    if(first)
+                    {
+                        std::cout << myvar;
+                        first = 0;
+                    }
+                    else
+                    {
+                        std::cout << "," << myvar;
+                    }
+                }
+                std::cout <<  std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'rt' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+
+        try {
+            if (rep.getValue(m_var_name_n, m_var_value_n ))
+            {
+                std::cout << "\t\t" << "property 'n' : " << m_var_value_n << std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'n' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+
+        // array only works for integer, boolean, numbers and strings
+        // TODO: make it also work with array of objects
+        try {
+            if (rep.hasAttribute(m_var_name_if))
+            {
+                rep.getValue(m_var_name_if, m_var_value_if);
+                int first = 1;
+                std::cout << "\t\t" << "property 'if' : " ;
+                for(auto myvar: m_var_value_if)
+                {
+                    if(first)
+                    {
+                        std::cout << myvar;
+                        first = 0;
+                    }
+                    else
+                    {
+                        std::cout << "," << myvar;
+                    }
+                }
+                std::cout <<  std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'if' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+
+        try {
+            if (rep.getValue(m_var_name_value, m_var_value_value ))
+            {
+                std::cout << "\t\t" << "property 'value': " << m_var_value_value << std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'value' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+        if (m_send_notification_flag)
+        {
+            m_cv.notify_all();
+        }
+    }
+    return ehResult;
+}
+
+void BinarySwitchResource::notifyObservers(void) {
+    // TODO add code to handle the other resource properties.
+    //std::vector<std::string> prev_rt = m_var_value_rt;
+    //std::string prev_n = m_var_value_n;
+    //std::vector<std::string> prev_if = m_var_value_if;
+    bool prev_value = this->m_var_value_value;
+    std::unique_lock<std::mutex> cv_lock(m_cv_mutex);
+    while (m_notify_thread_active)
+    {
+        m_cv.wait(cv_lock);
+        if(m_send_notification_flag)
+        {
+            m_send_notification_flag = false;
+            std::cout << this->m_var_value_n << " Changed:" << std::endl;
+            std::cout << "\t Switch value - from " << (prev_value ? "ON" : "OFF") << " to " << (this->m_var_value_value ? "ON" : "OFF") << std::endl;
+
+            prev_value = this->m_var_value_value;
+
+            OCPlatform::notifyAllObservers(this->m_resourceHandle);
+        }
+    }
+}
+
+OCEntityHandlerResult BinarySwitchResource::entityHandler(std::shared_ptr<OC::OCResourceRequest> request)
+{
+    OCEntityHandlerResult ehResult = OC_EH_ERROR;
+    //std::cout << "In entity handler for BinarySwitchResource " << std::endl;
+
+    if(request)
+    {
+        std::cout << "In entity handler for BinarySwitchResource, URI is : "
+                << request->getResourceUri() << std::endl;
+
+        // Check for query params (if any)
+        QueryParamsMap queries = request->getQueryParameters();
+        if (!queries.empty())
+        {
+            std::cout << "\nQuery processing up to entityHandler" << std::endl;
+        }
+        for (auto it : queries)
+        {
+            std::cout << "Query key: " << it.first << " value : " << it.second
+                    << std::endl;
+        }
+        // get the value, so that we can AND it to check which flags are set
+        int requestFlag = request->getRequestHandlerFlag();
+
+        if(requestFlag & RequestHandlerFlag::RequestFlag)
+        {
+            // request flag is set
+            auto pResponse = std::make_shared<OC::OCResourceResponse>();
+            pResponse->setRequestHandle(request->getRequestHandle());
+            pResponse->setResourceHandle(request->getResourceHandle());
+
+            if(request->getRequestType() == "GET")
+            {
+                std::cout<<"BinarySwitchResource Get Request"<< std::endl;
+
+                pResponse->setResourceRepresentation(get(queries), "");
+                if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                {
+                    ehResult = OC_EH_OK;
+                }
+            }
+
+            else if(request->getRequestType() == "POST")
+            {
+                std::cout <<"BinarySwitchResource Post Request"<<std::endl;
+                bool  handle_post = true;
+
+                if (queries.size() > 0)
+                {
+                    for (const auto &eachQuery : queries)
+                    {
+                        std::string key = eachQuery.first;
+                        if (key.compare(INTERFACE_KEY) == 0)
+                        {
+                            std::string value = eachQuery.second;
+                            if (in_updatable_interfaces(value) == false)
+                            {
+                                std::cout << "Update request received via interface: " << value
+                                        << " . This interface is not authorized to update resource!!" << std::endl;
+                                pResponse->setResponseResult(OCEntityHandlerResult::OC_EH_FORBIDDEN);
+                                handle_post = false;
+                                ehResult = OC_EH_ERROR;
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (handle_post)
+                {
+                    ehResult = post(queries, request->getResourceRepresentation());
+                    if (ehResult == OC_EH_OK)
+                    {
+                        pResponse->setResourceRepresentation(get(queries), "");
+                    }
+                    else
+                    {
+                        pResponse->setResponseResult(OCEntityHandlerResult::OC_EH_ERROR);
+                    }
+                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                    {
+                        // TODO: if there are observers inform the observers
+                        //OCStackResult sResult;
+                        // update all observers with the new value
+                        // not sure if this is an blocking call
+                        //sResult = OCPlatform::notifyListOfObservers(   m_resourceHandle,
+                        //                                               m_interestedObservers,
+                        //                                               pResponse);
+                    }
+                }
+            }
+            else
+            {
+                std::cout << "BinarySwitchResource unsupported request type (delete,put,..)"
+                        << request->getRequestType() << std::endl;
+                pResponse->setResponseResult(OC_EH_ERROR);
+                OCPlatform::sendResponse(pResponse);
+                ehResult = OC_EH_ERROR;
+            }
+        }
+
+        if(requestFlag & RequestHandlerFlag::ObserverFlag)
+        {
+            // observe flag is set
+            std::cout << "\t\trequestFlag : Observer\n" << std::endl;
+            ObservationInfo observationInfo = request->getObservationInfo();
+            if(ObserveAction::ObserveRegister == observationInfo.action)
+            {
+                // add observer
+                m_interestedObservers.push_back(observationInfo.obsId);
+            }
+            else if(ObserveAction::ObserveUnregister == observationInfo.action)
+            {
+                // delete observer
+                m_interestedObservers.erase(std::remove(
+                        m_interestedObservers.begin(),
+                        m_interestedObservers.end(),
+                        observationInfo.obsId),
+                        m_interestedObservers.end());
+            }
+            ehResult = OC_EH_OK;
+        }
+    }
+    return ehResult;
+}
diff --git a/resource/examples/ocf_light/BinarySwitchResource.h b/resource/examples/ocf_light/BinarySwitchResource.h
new file mode 100644 (file)
index 0000000..7a81b4a
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * BinarySwitchResource.h
+ */
+
+#ifndef EXAMPLE_OCF_LIGHT_BINARYSWITCHRESOURCE_H_
+#define EXAMPLE_OCF_LIGHT_BINARYSWITCHRESOURCE_H_
+
+#include <vector>
+#include <atomic>
+#include <thread>
+#include <condition_variable>
+
+#include "Resource.h"
+
+#include "OCApi.h"
+#include "OCRepresentation.h"
+
+class BinarySwitchResource : public Resource
+{
+    public:
+        /*
+        * constructor
+        */
+        BinarySwitchResource();
+        virtual ~BinarySwitchResource();
+
+    private:
+
+        /*
+        * function to make the payload for the retrieve function (e.g. GET) /binaryswitch
+        * @param queries  the query parameters for this call
+        */
+        OC::OCRepresentation get(OC::QueryParamsMap queries);
+
+        /*
+        * function to parse the payload for the update function (e.g. POST) /binaryswitch
+        * @param queries  the query parameters for this call
+        * @param rep  the response to get the property values from
+        * @return OCEntityHandlerResult ok or not ok indication
+        */
+        OCEntityHandlerResult post(OC::QueryParamsMap queries, const OC::OCRepresentation& rep);
+
+        std::atomic<bool> m_notify_thread_active;
+        std::thread* m_notify_thread;
+
+        std::atomic<bool> m_send_notification_flag;
+        std::mutex m_cv_mutex;
+        std::condition_variable m_cv;
+        void notifyObservers(void);
+
+        // resource types and interfaces as array..
+        std::string m_RESOURCE_TYPE[1]; // rt value (as an array)
+        std::string m_RESOURCE_INTERFACE[2]; // interface if (as an array)
+        std::string m_IF_UPDATE[3]; // updateble interfaces
+        int m_nr_resource_types;
+        int m_nr_resource_interfaces;
+        OC::ObservationIds m_interestedObservers;
+
+        // member variables for path: /binaryswitch
+
+        std::vector<std::string>  m_var_value_rt;
+        std::string m_var_name_rt; // the name for the attribute
+
+        std::string m_var_value_n; // the value for the attribute
+        std::string m_var_name_n; // the name for the attribute
+
+
+        std::vector<std::string>  m_var_value_if;
+        std::string m_var_name_if; // the name for the attribute
+
+        bool m_var_value_value; // the value for the attribute
+        std::string m_var_name_value; // the name for the attribute
+        protected:
+        /*
+        * function to check if the interface is
+        * @param  interface_name the interface name used during the request
+        * @return true: updatable interface
+        */
+        bool in_updatable_interfaces(std::string interface_name)
+        {
+            for (int i=0; i<3; i++)
+            {
+                if (m_IF_UPDATE[i].compare(interface_name) == 0)
+                    return true;
+            }
+            return false;
+        }
+
+        /*
+        * the entity handler for this resource
+        * @param request the incoming request to handle
+        * @return OCEntityHandlerResult ok or not ok indication
+        */
+        virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OC::OCResourceRequest> request);
+};
+
+#endif /* EXAMPLE_OCF_LIGHT_BINARYSWITCHRESOURCE_H_ */
diff --git a/resource/examples/ocf_light/DimmingLightServer.cpp b/resource/examples/ocf_light/DimmingLightServer.cpp
new file mode 100644 (file)
index 0000000..c046c8e
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * DimmingLightServer.cpp
+ */
+#include <iostream>
+
+#include "DimmingLightServer.h"
+#include "OCPlatform.h"
+
+using namespace OC;
+
+DimmingLightServer::DimmingLightServer(void):
+m_binaryswitchInstance(),
+m_dimmingInstance()
+{
+    std::cout << "Running DimmingLightServer constructor" << std::endl;
+}
+
+DimmingLightServer::~DimmingLightServer(void)
+{
+    std::cout << "Running DimmingLightServer destructor" << std::endl;
+}
diff --git a/resource/examples/ocf_light/DimmingLightServer.h b/resource/examples/ocf_light/DimmingLightServer.h
new file mode 100644 (file)
index 0000000..e78633b
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * DimmingLightServer.h
+ */
+
+#ifndef EXAMPLE_OCF_LIGHT_DIMMINGLIGHTSERVER_H_
+#define EXAMPLE_OCF_LIGHT_DIMMINGLIGHTSERVER_H_
+
+#include "BinarySwitchResource.h"
+#include "DimmingResource.h"
+
+class DimmingLightServer
+{
+public:
+    /**
+     *  constructor
+     *  creates all resources from the resource classes.
+     */
+    DimmingLightServer(void);
+
+    /**
+     *  destructor
+     *
+     */
+    ~DimmingLightServer(void);
+
+private:
+    // Resources that are part of this server
+    BinarySwitchResource  m_binaryswitchInstance;
+    DimmingResource  m_dimmingInstance;
+};
+
+#endif /* EXAMPLE_OCF_LIGHT_DIMMINGLIGHTSERVER_H_ */
diff --git a/resource/examples/ocf_light/DimmingResource.cpp b/resource/examples/ocf_light/DimmingResource.cpp
new file mode 100644 (file)
index 0000000..1a0fbcc
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * DimmingResource.cpp
+ */
+#include <iostream>
+
+#include "DimmingResource.h"
+#include "OCPlatform.h"
+
+#define INTERFACE_KEY "if"
+
+using namespace OC;
+namespace PH = std::placeholders;
+
+DimmingResource::DimmingResource():
+        m_notify_thread_active{true},
+        m_notify_thread{nullptr},
+        m_send_notification_flag{false},
+        m_cv_mutex{},
+        m_cv{},
+        m_nr_resource_types{1},
+        m_nr_resource_interfaces{2},
+        m_interestedObservers{},
+        m_var_value_dimmingSetting{100},
+        m_var_value_n{},
+        m_var_value_if{},
+        m_var_value_rt{}
+{
+    std::cout << "- Running: DimmingResource constructor" << std::endl;
+    std::string resourceURI = "/dimming";
+
+    // VS2013 will fail list initialization so use array initialization
+    m_RESOURCE_TYPE[0] = "oic.r.light.dimming";
+    m_RESOURCE_INTERFACE[0] = "oic.if.baseline";
+    m_RESOURCE_INTERFACE[1] = "oic.if.a";
+    m_IF_UPDATE[0] = "oic.if.a";
+    m_IF_UPDATE[1] = "oic.if.rw";
+    m_IF_UPDATE[2] = "oic.if.baseline";
+    m_var_name_dimmingSetting = "dimmingSetting";
+    m_var_name_n = "n";
+    m_var_name_if = "if";
+    m_var_name_rt = "rt";
+
+    // initialize member variables /dimming
+    m_var_value_dimmingSetting = 0; // current value of property "dimmingSetting"
+    m_var_value_n = "";  // current value of property "n"
+    // initialize vector if
+    m_var_value_if.push_back("oic.if.baseline");
+    m_var_value_if.push_back("oic.if.a");
+    // initialize vector rt
+    m_var_value_rt.push_back("oic.r.light.dimming");
+
+    EntityHandler cb = std::bind(&DimmingResource::entityHandler, this,PH::_1);
+    //uint8_t resourceProperty = 0;
+    OCStackResult result = OCPlatform::registerResource(m_resourceHandle,
+            resourceURI,
+            m_RESOURCE_TYPE[0],
+            m_RESOURCE_INTERFACE[0],
+            cb,
+            OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE );
+
+    // add the additional interfaces
+    std::cout << "\t" << "# resource interfaces: " << m_nr_resource_interfaces << std::endl;
+    std::cout << "\t" << "# resource types     : " << m_nr_resource_types << std::endl;
+    for( int a = 1; a < m_nr_resource_interfaces; a++)
+    {
+        OCStackResult result1 = OCBindResourceInterfaceToResource(m_resourceHandle, m_RESOURCE_INTERFACE[a].c_str());
+        if (result1 != OC_STACK_OK)
+            std::cerr << "Could not bind interface:" << m_RESOURCE_INTERFACE[a] << std::endl;
+    }
+    // add the additional resource types
+    for( int a = 1; a < m_nr_resource_types; a++ )
+    {
+        OCStackResult result2 = OCBindResourceTypeToResource(m_resourceHandle, m_RESOURCE_TYPE[a].c_str());
+        if (result2 != OC_STACK_OK)
+            std::cerr << "Could not bind resource type:" << m_RESOURCE_INTERFACE[a] << std::endl;
+    }
+
+    if(OC_STACK_OK != result)
+    {
+        throw std::runtime_error(
+                std::string("DimmingResource failed to start")+std::to_string(result));
+    }
+
+    m_send_notification_flag = false;
+    m_notify_thread_active = true;
+    m_notify_thread = new std::thread(&DimmingResource::notifyObservers, this);
+}
+
+DimmingResource::~DimmingResource()
+{
+    m_notify_thread_active = false;
+    m_cv.notify_all();
+    if(m_notify_thread->joinable())
+    {
+        m_notify_thread->join();
+    }
+}
+
+OC::OCRepresentation DimmingResource::get(OC::QueryParamsMap queries)
+{
+    OC_UNUSED(queries);
+
+    m_rep.setValue(m_var_name_dimmingSetting, m_var_value_dimmingSetting );
+    m_rep.setValue(m_var_name_n, m_var_value_n );
+    m_rep.setValue(m_var_name_if,  m_var_value_if );
+    m_rep.setValue(m_var_name_rt,  m_var_value_rt );
+
+    return m_rep;
+}
+
+OCEntityHandlerResult DimmingResource::post(OC::QueryParamsMap queries, const OC::OCRepresentation& rep)
+{
+    OCEntityHandlerResult ehResult = OC_EH_OK;
+    OC_UNUSED(queries);
+
+    try {
+        if (rep.hasAttribute(m_var_name_dimmingSetting))
+        {
+            // allocate the variable
+            int value;
+            // get the actual value from the payload
+            rep.getValue(m_var_name_dimmingSetting, value);
+
+            // value exist in payload
+        }
+    }
+    catch (std::exception& e)
+    {
+        std::cout << e.what() << std::endl;
+    }
+
+    // TODO add check on array contents out of range, etc..
+    if (ehResult == OC_EH_OK)
+    {
+        // no error: assign the variables
+
+        try {
+            // value exist in payload
+            if (rep.getValue(m_var_name_dimmingSetting, m_var_value_dimmingSetting ))
+            {
+                std::cout << "\t\t" << "property 'dimmingSetting': " << m_var_value_dimmingSetting << std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'dimmingSetting' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+
+        try {
+            if (rep.getValue(m_var_name_n, m_var_value_n ))
+            {
+                std::cout << "\t\t" << "property 'n' : " << m_var_value_n << std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'n' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+
+        // array only works for integer, boolean, numbers and strings
+        // TODO: make it also work with array of objects
+        try {
+            if (rep.hasAttribute(m_var_name_if))
+            {
+                rep.getValue(m_var_name_if, m_var_value_if);
+                int first = 1;
+                std::cout << "\t\t" << "property 'if' : " ;
+                for(auto myvar: m_var_value_if)
+                {
+                    if(first)
+                    {
+                        std::cout << myvar;
+                        first = 0;
+                    }
+                    else
+                    {
+                        std::cout << "," << myvar;
+                    }
+                }
+                std::cout <<  std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'if' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+
+        // array only works for integer, boolean, numbers and strings
+        // TODO: make it also work with array of objects
+        try {
+            if (rep.hasAttribute(m_var_name_rt))
+            {
+                rep.getValue(m_var_name_rt, m_var_value_rt);
+                int first = 1;
+                std::cout << "\t\t" << "property 'rt' : " ;
+                for(auto myvar: m_var_value_rt)
+                {
+                    if(first)
+                    {
+                        std::cout << myvar;
+                        first = 0;
+                    }
+                    else
+                    {
+                        std::cout << "," << myvar;
+                    }
+                }
+                std::cout <<  std::endl;
+                m_send_notification_flag = true;
+            }
+            else
+            {
+                std::cout << "\t\t" << "property 'rt' not found in the representation" << std::endl;
+            }
+        }
+        catch (std::exception& e)
+        {
+            std::cout << e.what() << std::endl;
+        }
+        if (m_send_notification_flag)
+        {
+            m_cv.notify_all();
+        }
+    }
+    return ehResult;
+}
+
+void DimmingResource::notifyObservers(void) {
+    // TODO add code to handle the other resource properties.
+    //std::vector<std::string> prev_rt = m_var_value_rt;
+    //std::string prev_n = m_var_value_n;
+    //std::vector<std::string> prev_if = m_var_value_if;
+    int prev_dimmingSetting = this->m_var_value_dimmingSetting;
+    std::unique_lock<std::mutex> cv_lock(m_cv_mutex);
+    while (m_notify_thread_active)
+    {
+        m_cv.wait(cv_lock);
+        std::this_thread::sleep_for(std::chrono::seconds(1));
+        if(m_send_notification_flag)
+        {
+            m_send_notification_flag = false;
+            std::cout << this->m_var_value_n << " Changed:" << std::endl;
+            std::cout << "\t Switch value - from " << prev_dimmingSetting << " to " << this->m_var_value_dimmingSetting << std::endl;
+
+            prev_dimmingSetting = this->m_var_value_dimmingSetting;
+
+            OCPlatform::notifyAllObservers(this->m_resourceHandle);
+        }
+    }
+}
+
+OCEntityHandlerResult DimmingResource::entityHandler(std::shared_ptr<OC::OCResourceRequest> request)
+{
+    OCEntityHandlerResult ehResult = OC_EH_ERROR;
+    //std::cout << "In entity handler for DimmingResource " << std::endl;
+
+    if(request)
+    {
+        std::cout << "In entity handler for DimmingResource, URI is : "
+                << request->getResourceUri() << std::endl;
+
+        // Check for query params (if any)
+        QueryParamsMap queries = request->getQueryParameters();
+        if (!queries.empty())
+        {
+            std::cout << "\nQuery processing up to entityHandler" << std::endl;
+        }
+        for (auto it : queries)
+        {
+            std::cout << "Query key: " << it.first << " value : " << it.second
+                    << std::endl;
+        }
+        // get the value, so that we can AND it to check which flags are set
+        int requestFlag = request->getRequestHandlerFlag();
+
+        if(requestFlag & RequestHandlerFlag::RequestFlag)
+        {
+            // request flag is set
+            auto pResponse = std::make_shared<OC::OCResourceResponse>();
+            pResponse->setRequestHandle(request->getRequestHandle());
+            pResponse->setResourceHandle(request->getResourceHandle());
+
+            if(request->getRequestType() == "GET")
+            {
+                std::cout<<"DimmingResource Get Request"<< std::endl;
+
+                pResponse->setResourceRepresentation(get(queries), "");
+                if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                {
+                    ehResult = OC_EH_OK;
+                }
+            }
+
+            else if(request->getRequestType() == "POST")
+            {
+                std::cout <<"DimmingResource Post Request"<<std::endl;
+                bool  handle_post = true;
+
+                if (queries.size() > 0)
+                {
+                    for (const auto &eachQuery : queries)
+                    {
+                        std::string key = eachQuery.first;
+                        if (key.compare(INTERFACE_KEY) == 0)
+                        {
+                            std::string value = eachQuery.second;
+                            if (in_updatable_interfaces(value) == false)
+                            {
+                                std::cout << "Update request received via interface: " << value
+                                        << " . This interface is not authorized to update resource!!" << std::endl;
+                                pResponse->setResponseResult(OCEntityHandlerResult::OC_EH_FORBIDDEN);
+                                handle_post = false;
+                                ehResult = OC_EH_ERROR;
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (handle_post)
+                {
+                    ehResult = post(queries, request->getResourceRepresentation());
+                    if (ehResult == OC_EH_OK)
+                    {
+                        pResponse->setResourceRepresentation(get(queries), "");
+                    }
+                    else
+                    {
+                        pResponse->setResponseResult(OCEntityHandlerResult::OC_EH_ERROR);
+                    }
+                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                    {
+                        // TODO: if there are observers inform the observers
+                        //OCStackResult sResult;
+                        // update all observers with the new value
+                        // not sure if this is an blocking call
+                        //sResult = OCPlatform::notifyListOfObservers(   m_resourceHandle,
+                        //                                               m_interestedObservers,
+                        //                                               pResponse);
+                    }
+                }
+            }
+            else
+            {
+                std::cout << "DimmingResource unsupported request type (delete,put,..)"
+                        << request->getRequestType() << std::endl;
+                pResponse->setResponseResult(OC_EH_ERROR);
+                OCPlatform::sendResponse(pResponse);
+                ehResult = OC_EH_ERROR;
+            }
+        }
+
+        if(requestFlag & RequestHandlerFlag::ObserverFlag)
+        {
+            // observe flag is set
+            std::cout << "\t\trequestFlag : Observer\n" << std::endl;
+            ObservationInfo observationInfo = request->getObservationInfo();
+            if(ObserveAction::ObserveRegister == observationInfo.action)
+            {
+                // add observer
+                m_interestedObservers.push_back(observationInfo.obsId);
+            }
+            else if(ObserveAction::ObserveUnregister == observationInfo.action)
+            {
+                // delete observer
+                m_interestedObservers.erase(std::remove(
+                        m_interestedObservers.begin(),
+                        m_interestedObservers.end(),
+                        observationInfo.obsId),
+                        m_interestedObservers.end());
+            }
+            ehResult = OC_EH_OK;
+        }
+    }
+    return ehResult;
+}
diff --git a/resource/examples/ocf_light/DimmingResource.h b/resource/examples/ocf_light/DimmingResource.h
new file mode 100644 (file)
index 0000000..1406c6a
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * DimmingResource.h
+ */
+
+#ifndef EXAMPLE_OCF_LIGHT_DIMMINGRESOURCE_H_
+#define EXAMPLE_OCF_LIGHT_DIMMINGRESOURCE_H_
+
+#include <vector>
+#include <atomic>
+#include <thread>
+#include <condition_variable>
+
+#include "Resource.h"
+
+#include "OCApi.h"
+#include "OCRepresentation.h"
+
+class DimmingResource : public Resource
+{
+public:
+    /*
+     * constructor
+     */
+    DimmingResource();
+    virtual ~DimmingResource();
+private:
+
+    /*
+     * function to make the payload for the retrieve function (e.g. GET) /dimming
+     * @param queries  the query parameters for this call
+     */
+    OC::OCRepresentation get(OC::QueryParamsMap queries);
+
+    /*
+     * function to parse the payload for the update function (e.g. POST) /dimming
+     * @param queries  the query parameters for this call
+     * @param rep  the response to get the property values from
+     * @return OCEntityHandlerResult ok or not ok indication
+     */
+    OCEntityHandlerResult post(OC::QueryParamsMap queries, const OC::OCRepresentation& rep);
+
+
+    std::atomic<bool> m_notify_thread_active;
+    std::thread* m_notify_thread;
+
+    std::atomic<bool> m_send_notification_flag;
+    std::mutex m_cv_mutex;
+    std::condition_variable m_cv;
+    void notifyObservers(void);
+
+    // resource types and interfaces as array..
+    std::string m_RESOURCE_TYPE[1]; // rt value (as an array)
+    std::string m_RESOURCE_INTERFACE[2]; // interface if (as an array)
+    std::string m_IF_UPDATE[3]; // updateble interfaces
+    int m_nr_resource_types;
+    int m_nr_resource_interfaces;
+    OC::ObservationIds m_interestedObservers;
+
+    // member variables for path: /dimming
+    int m_var_value_dimmingSetting; // the value for the attribute
+    std::string m_var_name_dimmingSetting; // the name for the attribute
+
+    std::string m_var_value_n; // the value for the attribute
+    std::string m_var_name_n; // the name for the attribute
+
+
+    std::vector<std::string>  m_var_value_if;
+    std::string m_var_name_if; // the name for the attribute
+
+
+    std::vector<std::string>  m_var_value_rt;
+    std::string m_var_name_rt; // the name for the attribute
+protected:
+    /*
+     * function to check if the interface is
+     * @param  interface_name the interface name used during the request
+     * @return true: updatable interface
+     */
+    bool in_updatable_interfaces(std::string interface_name)
+    {
+        for (int i=0; i<3; i++)
+        {
+            if (m_IF_UPDATE[i].compare(interface_name) == 0)
+                return true;
+        }
+        return false;
+    }
+
+    /*
+     * the entity handler for this resource
+     * @param request the incoming request to handle
+     * @return OCEntityHandlerResult ok or not ok indication
+     */
+    virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OC::OCResourceRequest> request);
+};
+
+#endif /* EXAMPLE_OCF_LIGHT_DIMMINGRESOURCE_H_ */
diff --git a/resource/examples/ocf_light/PICS.json b/resource/examples/ocf_light/PICS.json
new file mode 100644 (file)
index 0000000..81a9751
--- /dev/null
@@ -0,0 +1,30 @@
+{\r
+    "device": "test1",\r
+    "company": "Open Connectivity Foundation",\r
+    "role": "Server",\r
+    "supportedVerticalProfile": [\r
+        "Smart Home"\r
+    ],\r
+    "supportedDeviceTypes": [\r
+        "oic.d.light"\r
+    ],\r
+    "icv": "ocf.1.0.0",\r
+    "dmv": "ocf.res.1.3.0, ocf.sh.1.3.0",\r
+    "resources": [\r
+    \r
+  \r
+"oic.r.switch.binary",\r
+  \r
+"oic.r.light.dimming"\r
+],\r
+    "jurisdictionSwitch": false,\r
+    "OTM": [\r
+        "oic.sec.doxm.jw"\r
+    ],\r
+    "contentFormatVersion": [ "1.0.0" ],\r
+    "acceptVersion": [ "1.0.0" ],\r
+\r
+    "multiValueQuerySupport": false,\r
+    "observableOICRES": true,\r
+    "persistentDeviceuuid": false\r
+}
\ No newline at end of file
diff --git a/resource/examples/ocf_light/Platform.cpp b/resource/examples/ocf_light/Platform.cpp
new file mode 100644 (file)
index 0000000..21218a8
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Platform.cpp
+ *
+ *  Created on: Feb 12, 2018
+ *      Author: georgena
+ */
+#include <iostream>
+
+#include "OCPlatform.h"
+#include "Platform.h"
+
+using namespace OC;
+
+/**
+ *  server_fopen
+ *  opens file
+ *  implements redirection to open:
+ * - initial security settings
+ * - introspection file
+ * @param path path+filename of the file to open
+ * @param mode mode of the file to open
+ * @return the filehandle of the opened file (or error)
+ */
+FILE* server_fopen(const char* path, const char* mode)
+{
+    FILE* fileptr = NULL;
+
+    if (0 == strcmp(path, OC_SECURITY_DB_DAT_FILE_NAME))
+    {
+        // reading the security initial setup file
+        fileptr = fopen("server_security.dat", mode);
+        std::cout << "reading security file 'server_security.dat' ptr: " << fileptr << std::endl;
+        return fileptr;
+    }
+    else if (0 == strcmp(path, OC_INTROSPECTION_FILE_NAME))
+    {
+        // reading the introspection file
+        fileptr = fopen("server_introspection.dat", mode);
+        std::cout << "reading introspection file  'server_introspection.dat' ptr: " << fileptr << std::endl;
+        return fileptr;
+    }
+    else
+    {
+        std::cout << "persistent storage - server_fopen: " << path << std::endl;
+        return fopen(path, mode);
+    }
+}
+
+// Create persistent storage handlers
+OCPersistentStorage ps{server_fopen, fread, fwrite, fclose, unlink};
+
+Platform::Platform(void)
+{
+    std::cout << "Running Platform constructor" << std::endl;
+    dataModelVersions.push_back("ocf.res.1.3.0");
+    dataModelVersions.push_back("ocf.sh.1.3.0");
+    // create the platform
+    PlatformConfig cfg
+    {
+        ServiceType::InProc,
+        ModeType::Server,
+        &ps
+    };
+    OCPlatform::Configure(cfg);
+    setPlatformInfo(m_platformId, m_manufacturerName, m_manufacturerLink,
+                    m_modelNumber, m_dateOfManufacture, m_platformVersion, m_operatingSystemVersion,
+                    m_hardwareVersion, m_firmwareVersion, m_supportLink, m_systemTime);
+
+}
+
+Platform::~Platform(void)
+{
+    std::cout << "Running Platform destructor" << std::endl;
+    deletePlatformInfo();
+}
+
+OCStackResult Platform::start(void)
+{
+    return OCPlatform::start();
+}
+
+OCStackResult Platform::registerPlatformInfo(void)
+{
+    OCStackResult result = OC_STACK_ERROR;
+    result = OCPlatform::registerPlatformInfo(platformInfo);
+    return result;
+}
+
+
+OCPlatformInfo* Platform::getPlatformInfo(void)
+{
+    return &platformInfo;
+}
+
+OCStackResult Platform::stop(void)
+{
+    return OCPlatform::stop();
+}
+
+/**
+ *  DuplicateString
+ *
+ * @param targetString  destination string, will be allocated
+ * @param sourceString  source string, e.g. will be copied
+
+ *  TODO: don't use strncpy
+ */
+void DuplicateString(char ** targetString, std::string sourceString)
+{
+    *targetString = new char[sourceString.length() + 1];
+    strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
+}
+
+void Platform::setPlatformInfo(std::string platformID, std::string manufacturerName,
+        std::string manufacturerUrl, std::string modelNumber, std::string dateOfManufacture,
+        std::string platformVersion, std::string operatingSystemVersion,
+        std::string hardwareVersion, std::string firmwareVersion, std::string supportUrl,
+        std::string systemTime)
+{
+    DuplicateString(&platformInfo.platformID, platformID);
+    DuplicateString(&platformInfo.manufacturerName, manufacturerName);
+    DuplicateString(&platformInfo.manufacturerUrl, manufacturerUrl);
+    DuplicateString(&platformInfo.modelNumber, modelNumber);
+    DuplicateString(&platformInfo.dateOfManufacture, dateOfManufacture);
+    DuplicateString(&platformInfo.platformVersion, platformVersion);
+    DuplicateString(&platformInfo.operatingSystemVersion, operatingSystemVersion);
+    DuplicateString(&platformInfo.hardwareVersion, hardwareVersion);
+    DuplicateString(&platformInfo.firmwareVersion, firmwareVersion);
+    DuplicateString(&platformInfo.supportUrl, supportUrl);
+    DuplicateString(&platformInfo.systemTime, systemTime);
+}
+
+void Platform::deletePlatformInfo(void)
+{
+    delete[] platformInfo.platformID;
+    delete[] platformInfo.manufacturerName;
+    delete[] platformInfo.manufacturerUrl;
+    delete[] platformInfo.modelNumber;
+    delete[] platformInfo.dateOfManufacture;
+    delete[] platformInfo.platformVersion;
+    delete[] platformInfo.operatingSystemVersion;
+    delete[] platformInfo.hardwareVersion;
+    delete[] platformInfo.firmwareVersion;
+    delete[] platformInfo.supportUrl;
+    delete[] platformInfo.systemTime;
+}
+
+/**
+ *  SetDeviceInfo
+ *  Sets the device information ("oic/d"), from the globals
+
+ * @return OC_STACK_ERROR or OC_STACK_OK
+ */
+OCStackResult Platform::setDeviceInfo()
+{
+    OCStackResult result = OC_STACK_ERROR;
+
+    OCResourceHandle handle = OCGetResourceHandleAtUri(OC_RSRVD_DEVICE_URI);
+    if (handle == NULL)
+    {
+        std::cout << "Failed to find resource " << OC_RSRVD_DEVICE_URI << std::endl;
+        return result;
+    }
+    result = OCBindResourceTypeToResource(handle, deviceType.c_str());
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to add device type" << std::endl;
+        return result;
+    }
+
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
+            dataModelVersions);
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to set data model versions" << std::endl;
+        return result;
+    }
+
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion);
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to set spec version" << std::endl;
+        return result;
+    }
+
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+            protocolIndependentID);
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to set piid" << std::endl;
+        return result;
+    }
+
+    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DEVICE_NAME, deviceName);
+    if (result != OC_STACK_OK)
+    {
+        std::cout << "Failed to set device name" << std::endl;
+        return result;
+    }
+    return OC_STACK_OK;
+}
diff --git a/resource/examples/ocf_light/Platform.h b/resource/examples/ocf_light/Platform.h
new file mode 100644 (file)
index 0000000..fe2ff3f
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Platform.h
+ */
+
+#ifndef EXAMPLE_OCF_LIGHT_PLATFORM_H_
+#define EXAMPLE_OCF_LIGHT_PLATFORM_H_
+
+#include <vector>
+#include <string>
+#include "OCPlatform.h"
+
+class Platform
+{
+public:
+    Platform(void);
+    virtual ~Platform(void);
+
+    OCStackResult start(void);
+    OCStackResult registerPlatformInfo(void);
+    OCPlatformInfo* getPlatformInfo(void);
+    OCStackResult stop(void);
+
+    /**
+     *  SetDeviceInfo
+     *  Sets the device information ("oic/d"), from the globals
+
+     * @return OC_STACK_ERROR or OC_STACK_OK
+     */
+    OCStackResult setDeviceInfo(void);
+
+private:
+    // Set of strings for each of platform Info fields
+    std::string m_platformId = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+    std::string m_manufacturerName = "ocf";
+    std::string m_manufacturerLink = "https://ocf.org/";
+    std::string m_modelNumber = "ModelNumber";
+    std::string m_dateOfManufacture = "2017-12-01";
+    std::string m_platformVersion = "1.0";
+    std::string m_operatingSystemVersion = "myOS";
+    std::string m_hardwareVersion = "1.0";
+    std::string m_firmwareVersion = "1.0";
+    std::string m_supportLink = "https://ocf.org/";
+    std::string m_systemTime = "2017-12-01T12:00:00.52Z";
+
+    /**
+     *  SetPlatformInfo
+     *  Sets the platform information ("oic/p"), from the globals
+
+     * @param platformID the platformID
+     * @param manufacturerName the manufacturerName
+     * @param manufacturerUrl the manufacturerUrl
+     * @param modelNumber the modelNumber
+     * @param platformVersion the platformVersion
+     * @param operatingSystemVersion the operatingSystemVersion
+     * @param hardwareVersion the hardwareVersion
+     * @param firmwareVersion the firmwareVersion
+     * @param supportUrl the supportUrl
+     * @param systemTime the systemTime
+     */
+    void setPlatformInfo(std::string platformID, std::string manufacturerName,
+            std::string manufacturerUrl, std::string modelNumber, std::string dateOfManufacture,
+            std::string platformVersion, std::string operatingSystemVersion,
+            std::string hardwareVersion, std::string firmwareVersion, std::string supportUrl,
+            std::string systemTime);
+
+    /**
+     *  deletePlatformInfo
+     *  Deletes the allocated platform information
+     */
+    void deletePlatformInfo(void);
+    // OCPlatformInfo Contains all the platform info to be stored
+    OCPlatformInfo platformInfo;
+
+public:
+    std::string  protocolIndependentID = "fa008167-3bbf-4c9d-8604-c9bcb96cb712";
+
+    // Set of strings for each of device info fields
+    std::string  deviceName = "Binary Switch";
+    std::string  deviceType = "oic.d.light";
+    std::string  specVersion = "ocf.1.0.0";
+    std::vector<std::string> dataModelVersions;
+};
+
+#endif /* EXAMPLE_OCF_LIGHT_PLATFORM_H_ */
diff --git a/resource/examples/ocf_light/Resource.h b/resource/examples/ocf_light/Resource.h
new file mode 100644 (file)
index 0000000..ed2fe61
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * resource.h
+ */
+#ifndef EXAMPLE_OCF_LIGHT_RESOURCE_H_
+#define EXAMPLE_OCF_LIGHT_RESOURCE_H_
+
+#include "octypes.h"
+#include "OCRepresentation.h"
+#include "OCResourceRequest.h"
+
+/*
+* default class, so that we have to define less variables/functions.
+*/
+class Resource
+{
+public:
+    virtual ~Resource() { };
+protected:
+    OCResourceHandle m_resourceHandle;
+    OC::OCRepresentation m_rep;
+    virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OC::OCResourceRequest> request)=0;
+};
+
+#endif /* EXAMPLE_OCF_LIGHT_RESOURCE_H_ */
diff --git a/resource/examples/ocf_light/SConscript b/resource/examples/ocf_light/SConscript
new file mode 100644 (file)
index 0000000..b1e0165
--- /dev/null
@@ -0,0 +1,36 @@
+#******************************************************************
+#
+# Copyright 2018 Intel 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.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('examples_env')
+
+examples_env.AppendUnique(CPPPATH=[
+    Dir('.').srcnode().path
+])
+
+ocf_light_files = [
+    'dimming_light_server.cpp',
+    'BinarySwitchResource.cpp',
+    'DimmingLightServer.cpp',
+    'DimmingResource.cpp',
+    'Platform.cpp',
+]
+
+output = examples_env.Program(ocf_light_files)
+
diff --git a/resource/examples/ocf_light/dimming_light_server.cpp b/resource/examples/ocf_light/dimming_light_server.cpp
new file mode 100644 (file)
index 0000000..c76f110
--- /dev/null
@@ -0,0 +1,95 @@
+//******************************************************************\r
+//\r
+// Copyright 2017 Open Connectivity Foundation\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+#include <signal.h>\r
+#include <string>\r
+#include <iostream>\r
+\r
+#ifdef HAVE_WINDOWS_H\r
+#include <windows.h>\r
+#endif\r
+\r
+#include "DimmingLightServer.h"\r
+#include "Platform.h"\r
+\r
+using namespace OC;\r
+\r
+#define INTERFACE_KEY "if"\r
+\r
+#ifdef __unix__\r
+// global needs static, otherwise it can be compiled out and then Ctrl-C does not work\r
+static int quit = 0;\r
+// handler for the signal to stop the application\r
+void handle_signal(int signal)\r
+{\r
+    OC_UNUSED(signal);\r
+    quit = 1;\r
+}\r
+#endif\r
+\r
+// main application\r
+// starts the server \r
+int main()\r
+{\r
+    Platform platform;\r
+    OC_VERIFY(platform.start() == OC_STACK_OK);\r
+    std::cout << "oic/p" << std::endl;\r
+    // initialize "oic/p"\r
+    if(platform.registerPlatformInfo() != OC_STACK_OK)\r
+    {\r
+        std::cout << "Platform Registration (oic/p) failed\n";\r
+    }\r
+    // initialize "oic/d"\r
+    std::cout << "oic/d" << std::endl;\r
+    if(platform.setDeviceInfo() != OC_STACK_OK)\r
+    {\r
+        std::cout << "Device Registration (oic/d) failed\n";\r
+    }\r
+\r
+    std::cout << "device type: " <<  platform.deviceType << std::endl;\r
+    std::cout << "platformID: " <<  platform.getPlatformInfo()->platformID << std::endl;\r
+    std::cout << "platform independent: " << platform.protocolIndependentID << std::endl;\r
+\r
+    // create the server\r
+    DimmingLightServer server;\r
+\r
+#ifdef __unix__\r
+    struct sigaction sa;\r
+    sigfillset(&sa.sa_mask);\r
+    sa.sa_flags = 0;\r
+    sa.sa_handler = handle_signal;\r
+    sigaction(SIGINT, &sa, NULL);\r
+\r
+    std::cout << "Press Ctrl-C to quit...." << std::endl;\r
+    do\r
+    {\r
+        usleep(2000000);\r
+    }\r
+    while (quit != 1);\r
+#endif\r
+\r
+#if defined(_WIN32)\r
+    std::cout << "Press Ctrl-C to quit...." << std::endl;\r
+    // we will keep the server alive for at most 30 minutes\r
+    std::this_thread::sleep_for(std::chrono::minutes(30));\r
+#endif\r
+    OC_VERIFY(platform.stop() == OC_STACK_OK);\r
+\r
+    return 0;\r
+}\r
diff --git a/resource/examples/ocf_light/oic_svr_db_server_mvjustworks.dat b/resource/examples/ocf_light/oic_svr_db_server_mvjustworks.dat
new file mode 100644 (file)
index 0000000..f00b2d8
Binary files /dev/null and b/resource/examples/ocf_light/oic_svr_db_server_mvjustworks.dat differ
diff --git a/resource/examples/ocf_light/readme.md b/resource/examples/ocf_light/readme.md
new file mode 100644 (file)
index 0000000..52f3c9d
--- /dev/null
@@ -0,0 +1,181 @@
+# Template: IOTivity C++ server\r
+\r
+The generated code acts as an simulator:\r
+- it creates values at start update\r
+- handles incoming requests, \r
+    - stores the values on POST\r
+    - respond on GET by giving out the stored values\r
+\r
+## what is generated:\r
+        \r
+- server.cpp implementation code\r
+    - per resource an class is generated.\r
+        - constructor\r
+            - creates the resource\r
+        - has entity handler\r
+            - get function to use the variables to create the return payload\r
+            - post function to assign the variables from the request payload\r
+                - single type: integer, number and strings \r
+                - arrays \r
+                    - array members are set for an GET\r
+                    - array members are retrieved from an POST\r
+                    - only arrays of a single type are handled.\r
+                        e.g. array of int, array of strings, array of number\r
+                        NOT handled: array of objects.\r
+                        - TODO: add complex objecs, see garage example of how to next objects (see client and server side)\r
+                - checks on minimum, maximum and readOnly, no update of the value if this occurs \r
+                - check if the correct interface is used (oic.if.a or oic.if.rw)\r
+    - main \r
+        - creates all classes\r
+        - creates the device\r
+        - installs the reader for\r
+            - introspection device data file (IDD)\r
+            - security file (SVR) contents\r
+            these files needs to be installed/copied where the the executable is.\r
+           \r
+- svr_server.json  - not used !!!\r
+    default json definition of the secure virtual resources (svr)\r
+    - just works\r
+    - not onboarded\r
+    - not tested, not used yet.\r
+- oic_svr_db_server_mvjustworks.dat\r
+    - copy from iotivity-1.3.1\resource\csdk\security\provisioning\r
+    - security: just works\r
+    - used in CTT testing (e.g. it can onboard the device!), and CTT can talk to the device.\r
+- PICS.json\r
+    - pics for CTT testing\r
+    - security: just works.\r
\r
+          \r
+            \r
+## what is missing/incorrect:\r
+- handling query params (none interfaces)\r
+- handling observe\r
+- manual update of resource data, e.g. out of bounds so that one can trigger this to pass CTT.\r
+- creation/deletion of resources (PUT/DELETE functions)\r
+- no correct makefile/scons file, so we do not yet know how to insert this in the IOTivity tree and then compile\r
+    - see for manual changes below\r
+\r
+# notes:\r
+- only tested on windows\r
+- readOnly params like: "precision", "maximumsaturation" from oic.r.colour.chroma is crashing the device when running the CTT\r
+    - to avoid this: remove these properties from the generated device.\r
+\r
+\r
+## SCONS adaption in resource/examples\r
+\r
+old :\r
+```\r
+######################################################################\r
+# Source files and Targets\r
+######################################################################\r
+example_names = [\r
+    'simpleserver', 'simpleclient',\r
+    'simpleclientserver',\r
+    'directpairingclient',\r
+    'devicediscoveryserver', 'devicediscoveryclient',\r
+    'simpleserverHQ', 'simpleclientHQ',\r
+    ]\r
+\r
+if target_os not in ['windows', 'msys_nt']:\r
+    example_names += [\r
+        'fridgeserver', 'fridgeclient',\r
+        'presenceserver', 'presenceclient',\r
+        'roomserver', 'roomclient',\r
+        'garageserver',\r
+        'garageclient',\r
+        'groupserver',\r
+        'groupclient',\r
+        'lightserver',\r
+        'threadingsample',\r
+        'server',\r
+        'observer',\r
+        ]\r
+    if 'CLIENT' in examples_env.get('RD_MODE'):\r
+        examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include'])\r
+        examples_env.AppendUnique(LIBS = ['resource_directory'])\r
+        example_names += ['rdclient']\r
+\r
+examples = map(make_single_file_cpp_program, example_names)\r
+\r
+```\r
+new :\r
+```\r
+######################################################################\r
+# Source files and Targets\r
+######################################################################\r
+example_names = [\r
+    'server', \r
+    ]\r
+\r
+if target_os not in ['windows', 'msys_nt']:\r
+    example_names += [\r
+        'fridgeserver', 'fridgeclient',\r
+        'presenceserver', 'presenceclient',\r
+        'roomserver', 'roomclient',\r
+        'garageserver',\r
+        'garageclient',\r
+        'groupserver',\r
+        'groupclient',\r
+        'lightserver',\r
+        'threadingsample',\r
+        'server',\r
+        'observer',\r
+        ]\r
+    if 'CLIENT' in examples_env.get('RD_MODE'):\r
+        examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include'])\r
+        examples_env.AppendUnique(LIBS = ['resource_directory'])\r
+        example_names += ['rdclient']\r
+\r
+examples = map(make_single_file_cpp_program, example_names)\r
+```\r
+\r
+## WINDOWS run.bat changes:\r
+```\r
+REM *** BUILD OPTIONS ***\r
+\r
+if "!RUN_ARG!"=="server" (\r
+  cd %BUILD_DIR%\resource\examples\r
+  REM %DEBUG% simpleserver.exe\r
+  %DEBUG% server.exe\r
+) else if "!RUN_ARG!"=="client" (\r
+```\r
+\r
+# build on windows\r
+in top directory:\r
+```\r
+run.bat build server -noTest\r
+```\r
+\r
+# run on windows\r
+in top directory:\r
+```\r
+run.bat server\r
+```\r
+\r
+\r
+## CTT info\r
+\r
+When CTT pops up:\r
+"reset to onboarding state" means one needs to: \r
+1. Stop your device\r
+2. Reset/replace security databases with a new/unowned one.\r
+    e.g. copy the ORIGINAL security file to the executable directory.\r
+3. Start your device.\r
+\r
+Note if the IUT crashes during testing one has to reset the security state to not onboarded.\r
+this is mentioned in the test case log of CTT when the CTT can't reset the device state properly.\r
+\r
+\r
+# CTT PICS information\r
+\r
+- IOTivity implements the next optional virtual security resources\r
+    currently there is no mechanism available to remove those from the implementatino.\r
+    hence they must be listed in the PICS:\r
+    - oic.r.crl, oic.r.csr, oic.r.roles \r
+- oic/res\r
+    This resource must be listed as none observable.\r
+    \r
+    \r
+\r
+\r
diff --git a/resource/examples/ocf_light/server_introspection.dat b/resource/examples/ocf_light/server_introspection.dat
new file mode 100644 (file)
index 0000000..f37e3b3
Binary files /dev/null and b/resource/examples/ocf_light/server_introspection.dat differ
diff --git a/resource/examples/ocf_light/server_security.dat b/resource/examples/ocf_light/server_security.dat
new file mode 100644 (file)
index 0000000..1b6beca
Binary files /dev/null and b/resource/examples/ocf_light/server_security.dat differ
diff --git a/resource/examples/ocf_light/server_security.dat-org b/resource/examples/ocf_light/server_security.dat-org
new file mode 100644 (file)
index 0000000..1b6beca
Binary files /dev/null and b/resource/examples/ocf_light/server_security.dat-org differ
diff --git a/resource/examples/ocf_light/svr_server-justworks.json b/resource/examples/ocf_light/svr_server-justworks.json
new file mode 100644 (file)
index 0000000..2912645
--- /dev/null
@@ -0,0 +1,62 @@
+{\r
+    "acl": {\r
+        "aclist2": [\r
+            {\r
+                "aceid": 1,\r
+                "subject": { "conntype": "anon-clear" },\r
+                "resources": [\r
+                    { "href": "/oic/res" },\r
+                    { "href": "/oic/d" },\r
+                    { "href": "/oic/p"}\r
+                ],\r
+                "permission": 2\r
+            },\r
+            {\r
+                "aceid": 2,\r
+                "subject": { "conntype": "auth-crypt" },\r
+                "resources": [\r
+                    { "href": "/oic/res" },\r
+                    { "href": "/oic/d" },\r
+                    { "href": "/oic/p"}\r
+                ],\r
+                "permission": 2\r
+            },\r
+            {\r
+                "aceid": 3,\r
+                "subject": { "conntype": "anon-clear" },\r
+                "resources": [\r
+                    { "href": "/oic/sec/doxm" }\r
+                ],\r
+                "permission": 14\r
+            },\r
+            {\r
+                "aceid": 4,\r
+                "subject": { "conntype": "auth-crypt" },\r
+                "resources": [\r
+                    { "href": "/oic/sec/doxm" },\r
+                    { "href": "/oic/sec/roles" }\r
+                ],\r
+                "permission": 14\r
+            }\r
+        ],\r
+        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+    },\r
+    "pstat": {\r
+        "dos": { "s": 1, "p": false },\r
+        "isop": false,\r
+        "cm": 2,\r
+        "tm": 0,\r
+        "om": 4,\r
+        "sm": 4,\r
+        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+    },\r
+    "doxm": {\r
+        "oxms": [0],\r
+        "oxmsel": 0,\r
+        "sct": 9,\r
+        "owned": false,\r
+        "deviceuuid": "12345678-1234-1234-1234-123456789012",\r
+        "devowneruuid": "00000000-0000-0000-0000-000000000000",\r
+        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+    }\r
+}\r
diff --git a/resource/examples/ocf_light/svr_server.json b/resource/examples/ocf_light/svr_server.json
new file mode 100644 (file)
index 0000000..5d03542
--- /dev/null
@@ -0,0 +1,76 @@
+{\r
+    "acl": {\r
+        "aclist2": [\r
+            {\r
+                "aceid": 1,\r
+                "subject": { "conntype": "anon-clear" },\r
+                "resources": [\r
+                    { "href": "/oic/res" },\r
+                    { "href": "/oic/d" },\r
+                    { "href": "/oic/p" },\r
+                    { "href": "/oic/sec/doxm" }\r
+                ],\r
+                "permission": 2\r
+            },\r
+            {\r
+                "aceid": 2,\r
+                "subject": { "conntype": "auth-crypt" },\r
+                "resources": [\r
+                    { "href": "/oic/res" },\r
+                    { "href": "/oic/d" },\r
+                    { "href": "/oic/p" },\r
+                    { "href": "/oic/sec/doxm" }\r
+                ],\r
+                "permission": 2\r
+            },\r
+            {\r
+                "aceid": 5,\r
+                "subject": {"uuid": "32323232-3232-3232-3232-323232323232"},\r
+                "resources":[\r
+                    { "href":"/a/led"}\r
+                ],\r
+                "permission": 7\r
+            }\r
+        ],\r
+        "rowneruuid": "32323232-3232-3232-3232-323232323232",\r
+        "rt": ["oic.r.acl"],\r
+        "if": ["oic.if.baseline"]\r
+    },\r
+    "pstat": {\r
+        "dos": { "s": 3, "p": false },\r
+        "isop": true,\r
+        "cm": 0,\r
+        "tm": 0,\r
+        "om": 4,\r
+        "sm": 4,\r
+        "rowneruuid": "132323232-3232-3232-3232-323232323232",\r
+        "rt": ["oic.r.pstat"],\r
+        "if": ["oic.if.baseline"]\r
+    },\r
+    "doxm": {\r
+        "oxms": [0],\r
+        "oxmsel": 0,\r
+        "sct": 1,\r
+        "owned": true,\r
+        "deviceuuid": "12345678-1234-1234-1234-123456789012",\r
+        "devowneruuid": "32323232-3232-3232-3232-323232323232",\r
+        "rowneruuid": "32323232-3232-3232-3232-323232323232",\r
+        "rt": ["oic.r.doxm"],\r
+        "if": ["oic.if.baseline"]\r
+    },\r
+    "cred":{\r
+        "creds": [\r
+            {\r
+                "credid": 1,\r
+                "subjectuuid": "32323232-3232-3232-3232-323232323232",\r
+                "credtype": 1,\r
+                "privatedata":{\r
+                    "data":"AAAAAAAAAAAAAAAA",\r
+                    "encoding": "oic.sec.encoding.raw"\r
+                }\r
+            }],\r
+        "rowneruuid": "32323232-3232-3232-3232-323232323232",\r
+        "rt": ["oic.r.cred"],\r
+        "if": ["oic.if.baseline"]\r
+    }\r
+}
\ No newline at end of file
diff --git a/resource/examples/ocf_light/svr_server.json.cbor b/resource/examples/ocf_light/svr_server.json.cbor
new file mode 100644 (file)
index 0000000..1b6beca
Binary files /dev/null and b/resource/examples/ocf_light/svr_server.json.cbor differ
index 0aae3ce..a6a487e 100644 (file)
@@ -224,15 +224,15 @@ std::string OCResource::setHost(const std::string& host)
 
     if (host.compare(0, sizeof(COAPS) - 1, COAPS) == 0)
     {
-        if (!OC_SECURE)
-        {
-            throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(),
-            m_interfaces.empty(), m_clientWrapper.expired(), false, false);
-        }
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
         prefix_len = sizeof(COAPS) - 1;
         m_devAddr.flags = static_cast<OCTransportFlags>(m_devAddr.flags | OC_SECURE);
         m_devAddr.adapter = OC_ADAPTER_IP;
         usingIpAddr = true;
+#else
+        throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(),
+        m_interfaces.empty(), m_clientWrapper.expired(), false, false);
+#endif
     }
     else if (host.compare(0, sizeof(COAP) - 1, COAP) == 0)
     {
@@ -248,15 +248,15 @@ std::string OCResource::setHost(const std::string& host)
     }
     else if (host.compare(0, sizeof(COAPS_TCP) - 1, COAPS_TCP) == 0)
     {
-        if (!OC_SECURE)
-        {
-            throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(),
-            m_interfaces.empty(), m_clientWrapper.expired(), false, false);
-        }
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
         prefix_len = sizeof(COAPS_TCP) - 1;
         m_devAddr.flags = static_cast<OCTransportFlags>(m_devAddr.flags | OC_SECURE);
         m_devAddr.adapter = OC_ADAPTER_TCP;
         usingIpAddr = true;
+#else
+        throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(),
+        m_interfaces.empty(), m_clientWrapper.expired(), false, false);
+#endif
     }
     else if (host.compare(0, sizeof(COAP_GATT) - 1, COAP_GATT) == 0)
     {
index 9eb469c..a8a085b 100644 (file)
@@ -273,7 +273,7 @@ static void *CHPParserExecuteMultiHandle(void* data)
                     char *contentType = NULL;
                     long responseCode;
 
-                    curl_easy_getinfo(easyHandle, CURLINFO_PRIVATE, &ptr);
+                    curl_easy_getinfo(easyHandle, CURLINFO_PRIVATE, (char**)&ptr);
                     curl_easy_getinfo(easyHandle, CURLINFO_EFFECTIVE_URL, &uri);
                     curl_easy_getinfo(easyHandle, CURLINFO_RESPONSE_CODE, &responseCode);
                     curl_easy_getinfo(easyHandle, CURLINFO_CONTENT_TYPE, &contentType);
index e6aa871..926a71f 100644 (file)
@@ -140,7 +140,7 @@ namespace OIC
                       *
                       * @return NSTopicsList  as pointer.
                       */
-                std::shared_ptr<NSTopicsList> getTopicList() const  throw (NSException);
+                std::shared_ptr<NSTopicsList> getTopicList() const noexcept(false);
 
                 /**
                      * Update Topic list that is wanted to be subscribed from provider
@@ -148,7 +148,7 @@ namespace OIC
                      * @param topicList - NSTopicsList of interested Topics.
                      * @return NSResult
                      */
-                NSResult updateTopicList(std::shared_ptr<NSTopicsList> topicList)  throw (NSException);
+                NSResult updateTopicList(std::shared_ptr<NSTopicsList> topicList) noexcept(false);
 
                 /**
                       * This method is for getting ProviderState from the Notification service provider.
@@ -162,7 +162,7 @@ namespace OIC
                       *
                       * @return subscribedState as NSProviderSubscribedState.
                       */
-                NSProviderSubscribedState getProviderSubscribedState() const  throw (NSException);
+                NSProviderSubscribedState getProviderSubscribedState() const noexcept(false);
 
                 /**
                       * This method is for requesting subscription of Notification service.
@@ -175,7 +175,7 @@ namespace OIC
                       *
                       * @return ::NS_OK or result code of NSResult
                       */
-                NSResult subscribe()  throw (NSException);
+                NSResult subscribe() noexcept(false);
 
                 /**
                       * Request to unsubscribe in order not to receive notification message from provider
@@ -185,13 +185,13 @@ namespace OIC
                       *
                       * @return ::NS_OK or result code of NSResult
                      */
-                NSResult unsubscribe()  throw (NSException);
+                NSResult unsubscribe() noexcept(false);
 
                 /**
                       * This method is for requesting subscription status from Provider of Notification service.
                       *
                       */
-                bool isSubscribed()  throw (NSException);
+                bool isSubscribed() noexcept(false);
 
                 /**
                       * This method is for Sending SyncInfo of Notification service.
@@ -200,7 +200,7 @@ namespace OIC
                       * @param type - NSSyncType of Notification service.
                       * @return ::NS_OK or result code of NSResult
                       */
-                NSResult sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type)  throw (NSException);
+                NSResult sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type) noexcept(false);
 
                 /**
                       * This method is for registering for listeners of Notification .
index 3478d30..ca2bb24 100644 (file)
@@ -103,7 +103,7 @@ namespace OIC
             return m_providerId;\r
         }\r
 \r
-        std::shared_ptr<NSTopicsList> NSProvider::getTopicList() const  throw (NSException)\r
+        std::shared_ptr<NSTopicsList> NSProvider::getTopicList() const noexcept(false)\r
         {\r
             NS_LOG(DEBUG, "getTopicList - IN");\r
             if (!isValid())\r
@@ -119,7 +119,7 @@ namespace OIC
             return topicList;\r
         }\r
 \r
-        NSResult NSProvider::updateTopicList(std::shared_ptr<NSTopicsList> topicList)  throw (NSException)\r
+        NSResult NSProvider::updateTopicList(std::shared_ptr<NSTopicsList> topicList) noexcept(false)\r
         {\r
             NS_LOG(DEBUG, "updateTopicList - IN");\r
             if (!isValid())\r
@@ -203,7 +203,7 @@ namespace OIC
             return m_state;\r
         }\r
 \r
-        NSProviderSubscribedState NSProvider::getProviderSubscribedState() const  throw (NSException)\r
+        NSProviderSubscribedState NSProvider::getProviderSubscribedState() const noexcept(false)\r
         {\r
             NS_LOG_V(DEBUG, "getProviderSubscribedState  state : %d", (int)m_subscribedState);\r
             if (!isValid())\r
@@ -213,7 +213,7 @@ namespace OIC
             return m_subscribedState;\r
         }\r
 \r
-        NSResult NSProvider::subscribe()  throw (NSException)\r
+        NSResult NSProvider::subscribe() noexcept(false)\r
         {\r
             NS_LOG(DEBUG, "Subscribe - IN");\r
             if (!isValid())\r
@@ -225,7 +225,7 @@ namespace OIC
             return result;\r
         }\r
 \r
-        NSResult NSProvider::unsubscribe()  throw (NSException)\r
+        NSResult NSProvider::unsubscribe() noexcept(false)\r
         {\r
             NS_LOG(DEBUG, "unsubscribe - IN");\r
             if (!isValid())\r
@@ -237,7 +237,7 @@ namespace OIC
             return result;\r
         }\r
 \r
-        bool NSProvider::isSubscribed()  throw (NSException)\r
+        bool NSProvider::isSubscribed() noexcept(false)\r
         {\r
             NS_LOG(DEBUG, "isSubscribed - IN");\r
             if (!isValid())\r
@@ -252,7 +252,7 @@ namespace OIC
             return false;\r
         }\r
 \r
-        NSResult NSProvider::sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type)  throw (NSException)\r
+        NSResult NSProvider::sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type) noexcept(false)\r
         {\r
             NS_LOG(DEBUG, "SendSyncInfo - IN");\r
             if (!isValid())\r
index c9ed359..3e96bb8 100644 (file)
@@ -113,7 +113,7 @@ std::shared_ptr<OIC::Service::NSConsumer> printAvailableConsumers()
     return consumer;
 }
 
-int main()
+int main(void)
 {
     int num = 0;
     pthread_t processThread = 0;
index b4b32ae..f2a07d6 100644 (file)
@@ -160,7 +160,7 @@ void input(char * buffer)
     buffer[i] = '\0';
 }
 
-int main()
+int main(void)
 {
     int num = 0;
     pthread_t processThread = 0;
index 95d7446..14052db 100644 (file)
@@ -75,7 +75,7 @@ NSResult NSStartConsumer(NSConsumerConfig config);
  * Terminate notification service for consumer
  * @return ::NS_OK or result code of NSResult
  */
-NSResult NSStopConsumer();
+NSResult NSStopConsumer(void);
 
 /**
  * Request to discover to remote address as parameter.
@@ -98,7 +98,7 @@ NSResult NSConsumerSubscribeMQService(const char * serverAddress, const char * t
  * Request discovery manually
  * @return ::NS_OK or result code of NSResult
  */
-NSResult NSRescanProvider();
+NSResult NSRescanProvider(void);
 
 /**
  * Request to subscribe notification message resource of provider
index 3d9f73e..07f8307 100644 (file)
@@ -415,7 +415,7 @@ NSResult NSFreeMediaContents(NSMediaContents * obj)
     return NS_OK;
 }
 
-NSMessage * NSInitializeMessage()
+NSMessage * NSInitializeMessage(void)
 {
     NSMessage * msg = (NSMessage *)OICMalloc(sizeof(NSMessage));
 
@@ -462,7 +462,7 @@ OCRepPayloadValue* NSPayloadFindValue(const OCRepPayload* payload, const char* n
     return NULL;
 }
 
-NSTopicList * NSInitializeTopicList()
+NSTopicList * NSInitializeTopicList(void)
 {
     NSTopicList * topicList = (NSTopicList *)OICMalloc(sizeof(NSTopicList));
 
index f4e71e3..3ba1920 100644 (file)
@@ -38,7 +38,7 @@
 OCEntityHandlerRequest *NSCopyOCEntityHandlerRequest(OCEntityHandlerRequest *);\r
 NSResult NSFreeOCEntityHandlerRequest(OCEntityHandlerRequest *);\r
 \r
-NSMessage * NSInitializeMessage();\r
+NSMessage * NSInitializeMessage(void);\r
 NSResult NSFreeMessage(NSMessage *);\r
 NSMessage * NSDuplicateMessage(NSMessage *);\r
 \r
@@ -49,7 +49,7 @@ NSSyncInfo * NSGetSyncInfo(OCPayload * payload);
 NSResult NSFreeConsumer(NSConsumer *);\r
 NSConsumer * NSDuplicateConsumer(NSConsumer *);\r
 \r
-NSTopicList * NSInitializeTopicList();\r
+NSTopicList * NSInitializeTopicList(void);\r
 \r
 void NSDuplicateSetPropertyString(OCRepPayload **, const char *, const char *);\r
 void NSDuplicateSetPropertyInt(OCRepPayload ** msgPayload, const char * name, int64_t value);\r
index 42a65a3..3439271 100644 (file)
@@ -31,7 +31,7 @@ static bool NSIsExtraValue(const char * name);
 static void NSCopyPayloadValueArray(OCRepPayloadValue* dest, OCRepPayloadValue* source);
 static OCRepPayloadValue * NSCopyPayloadValue(OCRepPayloadValue * value);
 
-pthread_mutex_t ** NSGetStackMutex()
+pthread_mutex_t ** NSGetStackMutex(void)
 {
     static pthread_mutex_t * g_stackMutext = NULL;
     if (g_stackMutext == NULL)
@@ -44,7 +44,7 @@ pthread_mutex_t ** NSGetStackMutex()
     return & g_stackMutext;
 }
 
-char ** NSGetConsumerId()
+char ** NSGetConsumerId(void)
 {
     static char * g_consumerId = NULL;
     return & g_consumerId;
@@ -91,7 +91,7 @@ char * NSMakeRequestUriWithConsumerId(const char * uri)
     return retQuery;
 }
 
-bool * NSGetBoneIsStartedConsumer()
+bool * NSGetBoneIsStartedConsumer(void)
 {
     static bool g_isStartedConsumer = false;
 
@@ -112,12 +112,12 @@ void NSSetIsStartedConsumer(bool setValue)
     }
 }
 
-bool NSIsStartedConsumer()
+bool NSIsStartedConsumer(void)
 {
     return * NSGetBoneIsStartedConsumer();
 }
 
-NSProviderStateCallback * NSGetProviderChangedCb()
+NSProviderStateCallback * NSGetProviderChangedCb(void)
 {
     static NSProviderStateCallback g_changedCb = NULL;
 
@@ -175,7 +175,7 @@ void NSProviderChanged(NSProvider * provider, NSProviderState response)
     NSOICFree(thread);
 }
 
-NSSyncInfoReceivedCallback * NSGetBoneNotificationSyncCb()
+NSSyncInfoReceivedCallback * NSGetBoneNotificationSyncCb(void)
 {
     static NSSyncInfoReceivedCallback g_syncCb = NULL;
 
@@ -215,7 +215,7 @@ void NSNotificationSync(NSSyncInfo * sync)
     NSOICFree(thread);
 }
 
-NSMessageReceivedCallback  * NSGetBoneMessagePostedCb()
+NSMessageReceivedCallback  * NSGetBoneMessagePostedCb(void)
 {
     static NSMessageReceivedCallback  g_postCb = NULL;
 
@@ -227,7 +227,7 @@ void NSSetMessagePostedCb(NSMessageReceivedCallback  cb)
     * NSGetBoneMessagePostedCb() = cb;
 }
 
-NSMessageReceivedCallback  NSGetMessagePostedCb()
+NSMessageReceivedCallback  NSGetMessagePostedCb(void)
 {
     return * NSGetBoneMessagePostedCb();
 }
index 2100b22..3c8efd4 100644 (file)
@@ -96,7 +96,7 @@ typedef struct
 
 } NSSyncInfo_internal;
 
-bool NSIsStartedConsumer();
+bool NSIsStartedConsumer(void);
 void NSSetIsStartedConsumer(bool setValue);
 
 void NSSetProviderChangedCb(NSProviderStateCallback cb);
@@ -108,7 +108,7 @@ void NSMessagePost(NSMessage * obj);
 void NSSetNotificationSyncCb(NSSyncInfoReceivedCallback cb);
 void NSNotificationSync(NSSyncInfo * sync);
 
-char ** NSGetConsumerId();
+char ** NSGetConsumerId(void);
 void NSSetConsumerId(char * cId);
 
 char * NSMakeRequestUriWithConsumerId(const char * uri);
index 70edd55..cfc9a7a 100644 (file)
@@ -53,7 +53,7 @@ NSResult NSStartConsumer(NSConsumerConfig config)
     return NS_OK;
 }
 
-NSResult NSStopConsumer()
+NSResult NSStopConsumer(void)
 {
     bool isStartedConsumer = NSIsStartedConsumer();
     NS_VERIFY_NOT_NULL(isStartedConsumer == true ? (void *) 1 : NULL, NS_ERROR);
@@ -169,7 +169,7 @@ NSResult NSConsumerSendSyncInfo(const char * providerId, uint64_t messageId, NSS
     return NSConsumerPushEvent(syncTask);
 }
 
-NSResult NSRescanProvider()
+NSResult NSRescanProvider(void)
 {
     bool isStartedConsumer = NSIsStartedConsumer();
     NS_VERIFY_NOT_NULL(isStartedConsumer == true ? (void *) 1 : NULL, NS_ERROR);
index 40a4192..e457553 100644 (file)
@@ -45,19 +45,19 @@ typedef struct
 } NSMessageStateList;
 
 // Mutex of MessageState storage
-pthread_mutex_t ** NSGetMessageListMutex();
-void NSLockMessageListMutex();
-void NSUnlockMessageListMutex();
+pthread_mutex_t ** NSGetMessageListMutex(void);
+void NSLockMessageListMutex(void);
+void NSUnlockMessageListMutex(void);
 
 // Function for MessageState
-NSMessageStateList * NSGetMessageStateList();
+NSMessageStateList * NSGetMessageStateList(void);
 NSMessageStateLL * NSFindMessageState(uint64_t msgId);
 bool NSUpdateMessageState(uint64_t msgId, NSSyncType state);
 bool NSDeleteMessageState(uint64_t msgId);
 bool NSInsertMessageState(uint64_t msgId, NSSyncType state);
-void NSDestroyMessageStateList();
+void NSDestroyMessageStateList(void);
 
-NSCacheList ** NSGetProviderCacheList()
+NSCacheList ** NSGetProviderCacheList(void)
 {
     static NSCacheList * providerCache = NULL;
     return & providerCache;
@@ -68,7 +68,7 @@ void NSSetProviderCacheList(NSCacheList * cache)
     *(NSGetProviderCacheList()) = cache;
 }
 
-void NSDestroyInternalCachedList()
+void NSDestroyInternalCachedList(void)
 {
     NSCacheList * cache = *(NSGetProviderCacheList());
     if (cache)
@@ -154,7 +154,7 @@ NSResult NSProviderCacheUpdate(NSProvider_internal * provider)
     return NS_OK;
 }
 
-void NSCancelAllSubscription()
+void NSCancelAllSubscription(void)
 {
     NSCacheList * ProviderCache = *(NSGetProviderCacheList());
     if (!ProviderCache)
@@ -523,7 +523,7 @@ void NSConsumerInternalTaskProcessing(NSTask * task)
 }
 
 // implements of MessageState function
-pthread_mutex_t ** NSGetMessageListMutex()
+pthread_mutex_t ** NSGetMessageListMutex(void)
 {
     static pthread_mutex_t * g_mutex = NULL;
     if (g_mutex == NULL)
@@ -536,19 +536,19 @@ pthread_mutex_t ** NSGetMessageListMutex()
     return & g_mutex;
 }
 
-void NSLockMessageListMutex()
+void NSLockMessageListMutex(void)
 {
     NS_LOG_V(DEBUG, "%s", __func__);
     pthread_mutex_lock(*NSGetMessageListMutex());
 }
 
-void NSUnlockMessageListMutex()
+void NSUnlockMessageListMutex(void)
 {
     NS_LOG_V(DEBUG, "%s", __func__);
     pthread_mutex_unlock(*NSGetMessageListMutex());
 }
 
-NSMessageStateList ** NSGetMessageStateListAddr()
+NSMessageStateList ** NSGetMessageStateListAddr(void)
 {
     static NSMessageStateList * g_messageStateList = NULL;
     if (g_messageStateList == NULL)
@@ -563,7 +563,7 @@ NSMessageStateList ** NSGetMessageStateListAddr()
     return & g_messageStateList;
 }
 
-NSMessageStateList * NSGetMessageStateList()
+NSMessageStateList * NSGetMessageStateList(void)
 {
     return * NSGetMessageStateListAddr();
 }
@@ -693,7 +693,7 @@ bool NSInsertMessageState(uint64_t msgId, NSSyncType state)
     return true;
 }
 
-void NSDestroyMessageStateList()
+void NSDestroyMessageStateList(void)
 {
     NS_LOG_V(DEBUG, "%s", __func__);
     NSLockMessageListMutex();
index 4d567e5..27a11bd 100644 (file)
@@ -29,19 +29,19 @@ extern "C" {
 #include "NSConsumerMemoryCache.h"
 #include "NSConsumerCommunication.h"
 
-NSCacheList ** NSGetMessageCacheList();
+NSCacheList ** NSGetMessageCacheList(void);
 
 void NSSetMessageCacheList(NSCacheList *);
 
-NSCacheList ** NSGetProviderCacheList();
+NSCacheList ** NSGetProviderCacheList(void);
 
-void NSCancelAllSubscription();
+void NSCancelAllSubscription(void);
 
 void NSSetProviderCacheList(NSCacheList *);
 
-void NSDestroyMessageCacheList();
+void NSDestroyMessageCacheList(void);
 
-void NSDestroyInternalCachedList();
+void NSDestroyInternalCachedList(void);
 
 NSMessage * NSMessageCacheFind(const char *);
 
index 366ef8c..6a83d29 100644 (file)
@@ -22,7 +22,7 @@
 #include "oic_malloc.h"
 #include "oic_string.h"
 
-pthread_mutex_t * NSGetCacheMutex()
+pthread_mutex_t * NSGetCacheMutex(void)
 {
     static pthread_mutex_t * g_NSCacheMutex = NULL;
     if (g_NSCacheMutex == NULL)
@@ -35,7 +35,7 @@ pthread_mutex_t * NSGetCacheMutex()
     return g_NSCacheMutex;
 }
 
-NSCacheList * NSConsumerStorageCreate()
+NSCacheList * NSConsumerStorageCreate(void)
 {
     pthread_mutex_t * mutex = NSGetCacheMutex();
     pthread_mutex_lock(mutex);
index fc7aaaf..4688734 100644 (file)
@@ -30,13 +30,13 @@ extern "C" {
 #include <pthread.h>
 #include "NSConsumerCommon.h"
 
-NSCacheList * NSConsumerStorageCreate();
+NSCacheList * NSConsumerStorageCreate(void);
 NSCacheElement * NSConsumerStorageRead(NSCacheList * list, const char * findId);
 NSResult NSConsumerStorageWrite(NSCacheList * list, NSCacheElement * newObj);
 NSResult NSConsumerStorageDelete(NSCacheList * list, const char * delId);
 NSResult NSConsumerStorageDestroy(NSCacheList * list);
 
-pthread_mutex_t * NSGetCacheMutex();
+pthread_mutex_t * NSGetCacheMutex(void);
 
 bool NSConsumerCompareIdCacheData(NSCacheType type, void * data, const char * id);
 
index d48d897..587761f 100644 (file)
@@ -36,7 +36,7 @@ void NSConnectionStateListener(const CAEndpoint_t * info, bool isConnected);
 
 void NSAdapterStateListener(CATransportAdapter_t adapter, bool enabled);
 
-OCDoHandle * getPresenceHandle()
+OCDoHandle * getPresenceHandle(void)
 {
     static OCDoHandle g_PresenceHandle = NULL;
 
@@ -44,7 +44,7 @@ OCDoHandle * getPresenceHandle()
 }
 
 
-NSResult NSConsumerListenerInit()
+NSResult NSConsumerListenerInit(void)
 {
     // TODO replace with comment lines when enable network monitor of IP Adapter
     CARegisterNetworkMonitorHandler(NSAdapterStateListener, NSConnectionStateListener);
@@ -69,7 +69,7 @@ NSResult NSConsumerListenerInit()
     return NS_OK;
 }
 
-void NSConsumerListenerTermiate()
+void NSConsumerListenerTermiate(void)
 {
     CAUnregisterNetworkMonitorHandler(NSAdapterStateListener, NSConnectionStateListener);
     OCCancel(*getPresenceHandle(), NS_QOS, NULL, 0);
index fb1f55a..a6f779c 100644 (file)
@@ -31,9 +31,9 @@ extern "C" {
 #include "NSCommon.h"
 #include "ocstack.h"
 
-NSResult NSConsumerListenerInit();
+NSResult NSConsumerListenerInit(void);
 
-void NSConsumerListenerTermiate();
+void NSConsumerListenerTermiate(void);
 
 #ifdef __cplusplus
 }
index 89495e7..2881884 100644 (file)
@@ -24,7 +24,7 @@
 #include "oic_malloc.h"
 #include "NSConsumerCommon.h"
 
-NSConsumerQueue * NSCreateQueue()
+NSConsumerQueue * NSCreateQueue(void)
 {
     NSConsumerQueue * newQueue = (NSConsumerQueue *)OICMalloc(sizeof(NSConsumerQueue));
     NS_VERIFY_NOT_NULL(newQueue, NULL);
index 4e23761..efaa24f 100644 (file)
@@ -40,7 +40,7 @@ typedef struct
     NSConsumerQueueObject * tail;
 } NSConsumerQueue;
 
-NSConsumerQueue * NSCreateQueue();
+NSConsumerQueue * NSCreateQueue(void);
 
 void NSDestroyQueue(NSConsumerQueue *);
 
index 6414b6c..d6038a3 100644 (file)
@@ -57,7 +57,7 @@ static pthread_mutex_t g_start_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static NSConsumerQueue * g_queue = NULL;
 
-NSResult NSConsumerMessageHandlerInit()
+NSResult NSConsumerMessageHandlerInit(void)
 {
     pthread_mutex_lock(&g_start_mutex);
 
@@ -111,7 +111,7 @@ NSResult NSConsumerPushEvent(NSTask * task)
     return NS_OK;
 }
 
-void NSConsumerMessageHandlerExit()
+void NSConsumerMessageHandlerExit(void)
 {
     pthread_mutex_lock(&g_start_mutex);
 
index 2217e5b..682d0e1 100644 (file)
@@ -33,9 +33,9 @@ extern "C" {
 #include "NSStructs.h"
 #include "NSConsumerCommon.h"
 
-NSResult NSConsumerMessageHandlerInit();
+NSResult NSConsumerMessageHandlerInit(void);
 
-void NSConsumerMessageHandlerExit();
+void NSConsumerMessageHandlerExit(void);
 
 extern NSResult NSConsumerPushEvent(NSTask *);
 
index d132b1c..906e8a9 100644 (file)
@@ -23,7 +23,7 @@
 #include "NSConstants.h"
 #include "NSConsumerCommon.h"
 
-NSResult NSConsumerSystemInit()
+NSResult NSConsumerSystemInit(void)
 {
     return NS_OK;
 }
index 942580a..c673b5c 100644 (file)
@@ -27,7 +27,7 @@ extern "C" {
 
 #include "NSCommon.h"
 
-NSResult NSConsumerSystemInit();
+NSResult NSConsumerSystemInit(void);
 
 #ifdef __cplusplus
 }
index 36655d8..607e65e 100644 (file)
@@ -115,7 +115,7 @@ void NSDestroyThreadHandle(NSConsumerThread * handle)
     pthread_mutex_unlock(&g_create_mutex);
 }
 
-void NSThreadDetach()
+void NSThreadDetach(void)
 {
     pthread_detach(pthread_self());
 }
index a78fb5a..51ecbea 100644 (file)
@@ -61,7 +61,7 @@ void NSThreadStop(NSConsumerThread *);
 
 void NSDestroyThreadHandle(NSConsumerThread *);
 
-void NSThreadDetach();
+void NSThreadDetach(void);
 
 #ifdef __cplusplus
 }
index 9452103..ea0a6c2 100644 (file)
@@ -20,7 +20,7 @@
 \r
 #include "NSProviderDiscovery.h"\r
 \r
-NSResult NSStartPresence()\r
+NSResult NSStartPresence(void)\r
 {\r
     NS_LOG(DEBUG, "NSStartPresence()");\r
 \r
@@ -34,7 +34,7 @@ NSResult NSStartPresence()
     return NS_OK;\r
 }\r
 \r
-NSResult NSStopPresence()\r
+NSResult NSStopPresence(void)\r
 {\r
     NS_LOG(DEBUG, "NSStopPresence()");\r
 \r
index c020ecb..6512fdf 100644 (file)
@@ -26,7 +26,7 @@
 #include "NSProviderScheduler.h"\r
 #include "NSProviderResource.h"\r
 \r
-NSResult NSStartPresence();\r
-NSResult NSStopPresence();\r
+NSResult NSStartPresence(void);\r
+NSResult NSStopPresence(void);\r
 \r
 #endif /* _NS_PROVIDER_DISCOVERY_H_ */\r
index 0d22960..3a6eea4 100644 (file)
@@ -39,13 +39,13 @@ bool initProvider = false;
 pthread_mutex_t nsInitMutex;
 pthread_cond_t nstopicCond;
 
-void initializeMutex()
+void initializeMutex(void)
 {
     static pthread_mutex_t initMutex = PTHREAD_MUTEX_INITIALIZER;
     nsInitMutex = initMutex;
 }
 
-void NSInitialize()
+void NSInitialize(void)
 {
     NS_LOG(DEBUG, "NSSetList - IN");
 
@@ -59,7 +59,7 @@ void NSInitialize()
     NS_LOG(DEBUG, "NSSetList - OUT");
 }
 
-void NSDeinitailize()
+void NSDeinitailize(void)
 {
     NSProviderStorageDestroy(consumerSubList);
     NSProviderStorageDestroy(consumerTopicList);
index 950dcdf..9db1f29 100644 (file)
@@ -34,7 +34,7 @@
         } \\r
     }\r
 \r
-NSCacheList * NSProviderStorageCreate()\r
+NSCacheList * NSProviderStorageCreate(void)\r
 {\r
     pthread_mutex_lock(&NSCacheMutex);\r
     NSCacheList * newList = (NSCacheList *) OICMalloc(sizeof(NSCacheList));\r
index df2733d..f7e81ea 100644 (file)
@@ -31,7 +31,7 @@
 #include "oic_string.h"\r
 #include "NSUtil.h"\r
 \r
-NSCacheList * NSProviderStorageCreate();\r
+NSCacheList * NSProviderStorageCreate(void);\r
 NSCacheElement * NSProviderStorageRead(NSCacheList * list, const char * findId);\r
 NSResult NSProviderStorageWrite(NSCacheList * list, NSCacheElement * newObj);\r
 NSResult NSProviderStorageDelete(NSCacheList * list, const char * delId);\r
index e43ebd3..18679f8 100644 (file)
@@ -32,6 +32,6 @@
 #include "oic_malloc.h"\r
 #include "NSUtil.h"\r
 \r
-NSResult NSRegisterResource();\r
+NSResult NSRegisterResource(void);\r
 \r
 #endif /* _NS_PROVIDER_NOTIFICATION_H_ */\r
index 41a0086..fe29f06 100644 (file)
@@ -234,7 +234,7 @@ NSResult NSCreateResource(char *uri)
     return NS_OK;
 }
 
-NSResult NSRegisterResource()
+NSResult NSRegisterResource(void)
 {
     NS_LOG(DEBUG, "NSRegisterResource - IN");
 
@@ -251,7 +251,7 @@ NSResult NSRegisterResource()
     return NS_OK;
 }
 
-NSResult NSUnRegisterResource()
+NSResult NSUnRegisterResource(void)
 {
     NS_LOG(DEBUG, "NSUnRegisterResource - IN");
 
index 1b27e19..061e411 100644 (file)
@@ -53,9 +53,9 @@ NSResult NSCreateResource(char *uri);
 
 NSResult NSPublishResourceToCloud(char *host);
 
-NSResult NSRegisterResource();
+NSResult NSRegisterResource(void);
 
-NSResult NSUnRegisterResource();
+NSResult NSUnRegisterResource(void);
 
 NSResult NSPutNotificationResource(bool policy, OCResourceHandle * handle);
 
index 5495b78..d4ddd19 100644 (file)
@@ -34,7 +34,7 @@ void * NSSubScriptionSchedule(void *ptr);
 void * NSNotificationSchedule(void *ptr);\r
 void * NSTopicSchedule(void * ptr);\r
 \r
-bool NSInitScheduler()\r
+bool NSInitScheduler(void)\r
 {\r
     NS_LOG(DEBUG, "NSInitScheduler - IN");\r
 \r
@@ -52,7 +52,7 @@ bool NSInitScheduler()
     return true;\r
 }\r
 \r
-bool NSStartScheduler()\r
+bool NSStartScheduler(void)\r
 {\r
     int i = 0;\r
 \r
@@ -110,7 +110,7 @@ bool NSStartScheduler()
     return true;\r
 }\r
 \r
-bool NSStopScheduler()\r
+bool NSStopScheduler(void)\r
 {\r
     NS_LOG(DEBUG, "NSStopScheduler - IN");\r
     int i = 0;\r
index 78f9be6..4c63998 100644 (file)
@@ -48,10 +48,10 @@ extern void * NSSubScriptionSchedule(void *ptr);
 extern void * NSNotificationSchedule(void *ptr);\r
 extern void * NSTopicSchedule(void * ptr);\r
 \r
-void NSSetList();\r
-bool NSInitScheduler();\r
-bool NSStartScheduler();\r
-bool NSStopScheduler();\r
+void NSSetList(void);\r
+bool NSInitScheduler(void);\r
+bool NSStartScheduler(void);\r
+bool NSStopScheduler(void);\r
 void NSPushQueue(NSSchedulerType, NSTaskType, void*);\r
 void NSFreeData(NSSchedulerType, NSTask * );\r
 \r
index c2df9b1..bbbcf74 100644 (file)
@@ -21,7 +21,7 @@
 #include "NSProviderSubscription.h"\r
 #include "NSProviderListener.h"\r
 \r
-NSResult NSInitSubscriptionList()\r
+NSResult NSInitSubscriptionList(void)\r
 {\r
     NS_LOG(DEBUG, "NSInitSubscriptionList - IN");\r
 \r
index eaec122..58e8dfc 100644 (file)
@@ -36,7 +36,7 @@
 \r
 NSCacheList * consumerSubList;\r
 \r
-NSResult NSInitSubscriptionList();\r
+NSResult NSInitSubscriptionList(void);\r
 NSResult NSSetSubscriptionAccessPolicy(bool policy);\r
 NSResult NSSendAccessPolicyResponse(OCEntityHandlerRequest *entityHandlerRequest);\r
 void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest,\r
index f2bb213..12d7497 100644 (file)
@@ -36,7 +36,7 @@ void NSSetProviderConnectionState(NSConnectionState state)
     NSProviderConnectionState = state;\r
 }\r
 \r
-NSConnectionState NSGetProviderConnectionState()\r
+NSConnectionState NSGetProviderConnectionState(void)\r
 {\r
     NS_LOG(DEBUG, "Change Connection State");\r
 \r
@@ -61,7 +61,7 @@ void NSInitProviderInfo(const char * userInfo)
     }\r
 }\r
 \r
-void NSDeinitProviderInfo()\r
+void NSDeinitProviderInfo(void)\r
 {\r
     NS_LOG(DEBUG, "NSDeinitProviderInfo");\r
 \r
@@ -87,14 +87,14 @@ void NSDeinitProviderInfo()
     providerInfo = NULL;\r
 }\r
 \r
-NSProviderInfo * NSGetProviderInfo()\r
+NSProviderInfo * NSGetProviderInfo(void)\r
 {\r
     NS_LOG_V(INFO_PRIVATE, "ProviderInfo: %s", providerInfo->providerId);\r
 \r
     return providerInfo;\r
 }\r
 \r
-bool NSGetPolicy()\r
+bool NSGetPolicy(void)\r
 {\r
     return NSPolicy;\r
 }\r
@@ -104,7 +104,7 @@ void NSSetPolicy(bool policy)
     NSPolicy = policy;\r
 }\r
 \r
-bool NSGetResourceSecurity()\r
+bool NSGetResourceSecurity(void)\r
 {\r
     return NSResourceSecurity;\r
 }\r
@@ -114,7 +114,7 @@ void NSSetResourceSecurity(bool secured)
     NSResourceSecurity = secured;\r
 }\r
 \r
-const char * NSGetUserInfo()\r
+const char * NSGetUserInfo(void)\r
 {\r
     return providerInfo->userInfo;\r
 }\r
index 18b82b8..cc07bd9 100644 (file)
 #include "NSUtil.h"
 
 void NSSetProviderConnectionState(NSConnectionState state);
-NSConnectionState NSGetProviderConnectionState();
+NSConnectionState NSGetProviderConnectionState(void);
 
 void NSInitProviderInfo(const char * userInfo);
-void NSDeinitProviderInfo();
-NSProviderInfo * NSGetProviderInfo();
-const char * NSGetUserInfo();
-bool NSGetPolicy();
+void NSDeinitProviderInfo(void);
+NSProviderInfo * NSGetProviderInfo(void);
+const char * NSGetUserInfo(void);
+bool NSGetPolicy(void);
 void NSSetPolicy(bool policy);
-bool NSGetResourceSecurity();
+bool NSGetResourceSecurity(void);
 void NSSetResourceSecurity(bool secured);
 
 #ifdef WITH_MQ
index e8931d7..5cbb850 100644 (file)
@@ -23,9 +23,9 @@
 #include "oic_malloc.h"
 #include <pthread.h>
 
-NSResult NSSendTopicUpdation();
+NSResult NSSendTopicUpdation(void);
 
-NSResult NSInitTopicList()
+NSResult NSInitTopicList(void)
 {
     NS_LOG(DEBUG, "NSInitTopicList - IN");
 
@@ -117,7 +117,7 @@ NSResult NSUnregisterTopic(const char * topicName)
     return result;
 }
 
-NSResult NSSendTopicUpdation()
+NSResult NSSendTopicUpdation(void)
 {
     NS_LOG(DEBUG, "NSSendTopicUpdation - IN");
 
index f75a1f5..8a61f67 100644 (file)
@@ -45,7 +45,7 @@ typedef struct {
 NSCacheList * consumerTopicList;\r
 NSCacheList * registeredTopicList;\r
 \r
-NSResult NSInitTopicList();\r
+NSResult NSInitTopicList(void);\r
 NSTopicList * NSGetTopics(char *consumerId);\r
 \r
 bool NSIsTopicSubscribed(char *consumerId, char *topic);\r
index afee0f9..b857d38 100644 (file)
@@ -27,13 +27,13 @@ url = https://api.tizen.org
 #Repo section example
 [repo.tizen_2_4_mobile_tm1_armv7l]
 #Build against repo's URL
-url = http://download.tizen.org/releases/2.4/2.4-mobile/tizen-2.4-mobile_20160531.3/repos/target-TM1/packages/
+url = http://cdn.download.tizen.org/releases/2.4/2.4-mobile/tizen-2.4-mobile_20160531.3/repos/target-TM1/packages/
 #Optional user and password, set if differ from profile's user and password
 #user =
 #passwd =
 
 [repo.tizen_2_4_base]
-url = http://download.tizen.org/releases/2.4/2.4-base/tizen-2.4-base_20151027.1/repos/standard/packages/
+url = http://cdn.download.tizen.org/releases/2.4/2.4-base/tizen-2.4-base_20151027.1/repos/standard/packages/
 
 #{ Tizen:3.0
 [profile.tizen_3_0]
@@ -41,10 +41,10 @@ repos=repo.tizen_3_0_base, repo.tizen_3_0
 buildroot=~/tmp/gbs/tmp-GBS-tizen_3_0
 
 [repo.tizen_3_0]
-url=http://download.tizen.org/snapshots/tizen/3.0-mobile/latest/repos/target-TM1/packages/
+url=http://cdn.download.tizen.org/snapshots/tizen/3.0-mobile/latest/repos/target-TM1/packages/
 
 [repo.tizen_3_0_base]
-url=http://download.tizen.org/releases/daily/tizen/3.0-base/latest/repos/arm/packages/
+url=http://cdn.download.tizen.org/releases/daily/tizen/3.0-base/latest/repos/arm/packages/
 #}
 
 #{ Tizen:4.0:Unified
@@ -53,10 +53,10 @@ repos=repo.tizen_4_0_base_x86_64, repo.tizen_4_0_unified_x86_64
 buildroot=~/tmp/gbs/tmp-GBS-tizen_4_0_unified_x86_64
 
 [repo.tizen_4_0_unified_x86_64]
-url=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/packages/
+url=http://cdn.download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/packages/
 
 [repo.tizen_4_0_base_x86_64]
-url=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/x86_64/packages/
+url=http://cdn.download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/x86_64/packages/
 
 
 [profile.tizen_4_0_unified_armv7l]
@@ -64,10 +64,10 @@ repos=repo.tizen_4_0_base_armv7l, repo.tizen_4_0_unified_armv7l
 buildroot=~/tmp/gbs/tmp-GBS-tizen_4_0_unified_armv7l/
 
 [repo.tizen_4_0_unified_armv7l]
-url=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/packages/
+url=http://cdn.download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/packages/
 
 [repo.tizen_4_0_base_armv7l]
-url=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/arm/packages/
+url=http://cdn.download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/arm/packages/
 
 #} Tizen:4.0:Unified