Merge "Fixing OCCancel with High_QOS in observe isn't deleting CB."
authorSudarshan Prasad <sudarshan.prasad@intel.com>
Wed, 7 Jan 2015 21:22:00 +0000 (21:22 +0000)
committerGerrit Code Review <gerrit@172.30.200.205>
Wed, 7 Jan 2015 21:22:00 +0000 (21:22 +0000)
resource/docs/Doxyfile
resource/docs/doxygenLayout.xml
resource/docs/guides/AboutOIC.txt [deleted file]
resource/docs/guides/Home.txt
resource/docs/guides/HowToGuidesIndex.txt [deleted file]
resource/docs/guides/ProgrammersGuide.txt [deleted file]
service/things-manager/sdk/src/GroupSynchronization.cpp

index 27e9c0f..eac8d33 100644 (file)
@@ -26,13 +26,13 @@ DOXYFILE_ENCODING      = UTF-8
 # identify the project. Note that if you do not use Doxywizard you need
 # to put quotes around the project name if it contains spaces.
 
-PROJECT_NAME           = "C++ SDK"
+PROJECT_NAME           = "IoTivity C++ SDK"
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number.
 # This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER         = "M1 Release"
+PROJECT_NUMBER         = 
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer
index 6cc3fa7..cb1f63a 100644 (file)
@@ -1,9 +1,6 @@
 <doxygenlayout version="1.0">
     <navindex>
         <tab type="mainpage" visible="yes" title="Home"/>
-        <tab type="user" url="@ref AboutOIC"   title="About OIC" />
-        <tab type="user" url="@ref OCGuides"   title="Programmer's Guide" />
-        <tab type="user" url="@ref OCHowTo"    title="How To..." />
         <tab type="classes" visible="yes" title="API Reference">
             <tab type="classlist" visible="yes" title=""/>
             <tab type="hierarchy" visible="yes" title="" intro=""/>
diff --git a/resource/docs/guides/AboutOIC.txt b/resource/docs/guides/AboutOIC.txt
deleted file mode 100644 (file)
index 04ee0bc..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*!
-
-@page AboutOIC About Open Interconnect Consortium
-
-@section WhoAreWe Who are we?
-
-\li We want to connect the next 25 billion devices for the Internet of Things.
-
-\li We want to provide secure and reliable device discovery and connectivity across multiple OSs and platforms.
-
-\li There are multiple proposals and forums driving different approaches... but no single solution addresses the majority of key requirements.
-
-\li We need industry consolidation around a common, interoperable approach.
-
-\li We need a broad industry consortium of companies to create a scalable solution.
-
-
-@section WhyAreWeDoingThis Why are we doing this?
-
-\li We are defining the specification, certification & branding to deliver reliable interoperability - a connectivity framework that abstracts complexity
-
-\li This standard will be an open specification that anyone can implement and is easy for developers to use
-
-\li It will include IP protection & branding for certified devices (via compliance testing) and service-level interoperability
-
-\li There will also be an Open Source implementation of the standard
-
-\li This Open Source implementation will be designed to enable application developers and device manufacturers to deliver interoperable products across Android, iOS, Windows, Linux, Tizen, and more.
-
-@section WhoNeedsThis Who needs this?
-
-\li Consumers, Enterprise, Industrial, Automotive, Health, etc. who want smart devices to easily interconnect and communicate with appliances, embedded devices, etc.
-
-\li Developers of operating systems, platforms, and applications who want their products to interoperate seamlessly across many brands and ecosystems.
-
-\li End users who want consistent levels of security and identity across smart devices down to the smallest connected appliance
-
-@section HowWillWeDeliverIt How will we deliver it?
-
-\li Our goal is to define a comprehensive communications framework to enable emerging applications in all key vertical markets.
-
-\li The framework must enable multiple new modes of communication, such as Peer-to-Peer, Mesh & Bridging, Reporting & Control, etc.
-
-\li The framework should include a consistent implementation of identity, authentication and security across the modes of User ID, Enterprise / Industrial ID & Credentials.
-
-\li It should include a sense of proximity for the Internet of Things and Wearable devices and include support for Onboarding and Provisioning.
-
-\li And the framework must support a "building block" architecture and provide an Open Source implementation
-
-
-*/
\ No newline at end of file
index 5202e8a..4131aff 100644 (file)
@@ -2,14 +2,12 @@
 
 @mainpage Welcome
 
-IoTivity runs as an open source project. This infrastructure can be used by OIC partners to contribute and co-work for the project. This document is for any developer trying to utilize the IoTivity project in building applications. This document includes:
+IoTivity is an open source software framework enabling seamless device-to-device connectivity to address the emerging needs of the Internet of Things. These API references are for any developer trying to utilize the IoTivity project for building applications.
 
-\li \ref OCGuides - High level overview of the API and how to use them
-
-\li \ref OCHowTo - contains guides and tutorials to help developers get started
-
-\li <a href="annotated.html"> API Reference </a> - provides a reference to all public APIs available to utilize the power of IoTivity.
+\li <a href="annotated.html"><strong>API References</strong></a><br />Provides a reference to all public APIs available to utilize the power of IoTivity.
 
+\li <a href="https://www.iotivity.org/documentation"><strong>Getting Started Guides and Tutorials</strong></a><br />Detailed getting started guides and tutorials can be found on the iotivity.org website.
 
+\li <a href="https://wiki.iotivity.org"><strong>Wiki</strong></a><br />Additional documentation can be found on the IoTivity Wiki.
 
 */
diff --git a/resource/docs/guides/HowToGuidesIndex.txt b/resource/docs/guides/HowToGuidesIndex.txt
deleted file mode 100644 (file)
index 0d8c717..0000000
+++ /dev/null
@@ -1,1556 +0,0 @@
-/*!\r
-\r
-@page OCHowTo How To... Guides\r
-\r
-@ref Guide_Representative_Devices "Sample representative devices used in these tutorials"\r
-\r
-@ref Guide_Stack_Init "How to initialize the stack"\r
-\r
-@ref Guide_Register_Resource "How to register a resource"\r
-\r
-@ref Guide_Find_Resource "How to find a resource"\r
-\r
-@ref Guide_PUT  "How to set resource state [PUT]"\r
-\r
-@ref Guide_GET "How to query resource state [GET]"\r
-\r
-@ref Guide_Observe "How to observe resource state [Observe]"\r
-\r
-\r
-\r
-********************************************************************\r
-\r
-\r
-@page Guide_Representative_Devices Representative Devices\r
-\r
-The best way to understand the concepts for IoTivity is through following an example and understanding the use case. The following devices are referred to throughout this document for use cases and basic operations. The details are listed here for reference so that implementers can compare the responses from these devices with their configuration to develop an understanding of what the responses mean.\r
-\r
-@section Rep_Light_Device Light devices (192.168.1.11-13)\r
-\r
-A lighting device that can handle up to two light bulbs with dimmers. Each light bulb resource has two attributes:\r
-\li Power: controls power and can have a value of 0 (off) or 1 (on)\r
-\li Level: current dimmer level with a value from 1 (low) to 10 (full)\r
-\r
-The separation of the attributes allows the light to return to the previous light level when the power is toggled.\r
-\r
-@subsection Rep_Light_Device_Description Description of resources on this device type\r
-\r
-<table cellspacing="0" cellpadding="0" border=1 >\r
-\r
-<tr>\r
-<td valign="top" ><b>Resource</b></td>\r
-<td valign="top" ><b>Description</b></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core</p></td>\r
-<td valign="top" ><p>Standard resource listing in JSON format.</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core/d</p></td>\r
-<td valign="top" ><p>Virtual (hidden) resource that describes the device. It is searchable and supports the JSON attributes listed in the appendix.</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/lights</p></td>\r
-<td valign="top" ><p>The resource collection that contains light resources</p>\r
-\r
-<p>rt=alpha.light</p>\r
-\r
-<p>if=oc.mi.ll (linked-list)</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/light/1</p></td>\r
-<td valign="top" ><p>The resource associated with the first light bulb attached to this device </p>\r
-\r
-<p>rt=alpha.light</p>\r
-\r
-<p>if=oc.mi.def (default)</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/light/2</p></td>\r
-<td valign="top" ><p>The resource associated with the second light bulb attached to this device</p>\r
-\r
-<p>rt=alpha.light</p>\r
-\r
-<p>if=oc.mi.def (default)</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-@subsection Rep_Light_Device_Resource_11 Resource(s) at 192.168.1.11\r
-\r
-This device contains a single light resource. The following lists the valid resources and their typical state:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<td valign="top" ><b>Resource</b></td>\r
-<td valign="top" ><b>Representation</b></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core</p></td>\r
-<td valign="top" ><p>[</p>\r
-\r
-<p>{ "href" : "/lights", "rt" : ["alpha.light"], "if" : ["oc.mi.ll"]},</p>\r
-\r
-<p>{ "href" : "/light/1", "rt" : ["alpha.light"], "if" : ["oc.mi.def"], "obs" : 1}</p>\r
-\r
-<p>]</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core/d</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"di" : "12345678-1234-1234-0000000000000011",</p>\r
-\r
-<p>"dn" : "Alpha Light Controller",</p>\r
-\r
-<p>"dd" : "A Light Controller"</p>\r
-\r
-<p>}</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/light/1</p></td>\r
-<td valign="top" ><p>{ "power" : 0, "level" : 4 }</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-\r
-@subsection Rep_Light_Device_Resource_12 Resource(s) at 192.168.1.12\r
-\r
-This device contains a single light resource. The following lists the valid resources and their typical state:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<td valign="top" ><b>Resource</b></td>\r
-<td valign="top" ><b>Representation</b></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core</p></td>\r
-<td valign="top" ><p>[</p>\r
-\r
-<p>{ "href" : "/lights", "rt" : ["alpha.light"], "if" : ["oc.mi.ll"]},</p>\r
-\r
-<p>{ "href" : "/light/2", "rt" : ["alpha.light"], "if" : ["oc.mi.def"], "obs":1}</p>\r
-\r
-<p>]</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core/d</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"di" : "12345678-1234-1234-0000000000000012",</p>\r
-\r
-<p>"dn" : "Alpha Light Controller",</p>\r
-\r
-<p>"dd" : "A Light Controller"</p>\r
-\r
-<p>}</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/light/2</p></td>\r
-<td valign="top" ><p>{ "power" : 1, "level" : 6 }</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-@subsection Rep_Light_Device_Resource_13 Resource(s) at 192.168.1.13\r
-\r
-This device contains two light resources. The following lists the valid resources and their typical state:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-\r
-<tr>\r
-<td valign="top" ><p>Resource</p></td>\r
-<td valign="top" ><p>Representation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core</p></td>\r
-<td valign="top" ><p>[</p>\r
-\r
-<p>{ "href" : "/lights", "rt" : ["alpha.light"], "if" : ["oc.mi.ll"]},</p>\r
-\r
-<p>{ "href" : "/light/1", "rt" : ["alpha.light"], "if" : ["oc.mi.def"], "obs":1},</p>\r
-\r
-<p>{ "href" : "/light/2", "rt" : ["alpha.light"], "if" : ["oc.mi.def"], "obs":1}</p>\r
-\r
-<p>]</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/oc/core/d</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"di" : "12345678-1234-1234-0000000000000013",</p>\r
-\r
-<p>"dn" : "Alpha Light Controller",</p>\r
-\r
-<p>"dd" : "A Light Controller"</p>\r
-\r
-<p>}</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/light/1</p></td>\r
-<td valign="top" ><p>{ "power" : 0, "level" : 8 }</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>/light/2</p></td>\r
-<td valign="top" ><p>{ "power" : 1, "level" : 10 }</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-@page Guide_Stack_Init Stack Initialization\r
-\r
-@section Stack_Init_SD Sequence Diagram\r
-\r
-@image html seq_stack_init.png\r
-\r
-@note API calls take only important parameters. We omitted some of the parameters for clarity.\r
-\r
-The asynchronous processing block handles incoming network traffic including packet processing, scheduled tasks including communication timeouts and callbacks to the application resulting from these activities.\r
\r
-@section Stack_Init_CPP Stack Initialization in C++\r
-\r
-@code {.cpp}\r
-    // Create PlatformConfig object\r
-    PlatformConfig cfg;\r
-    cfg.ipAddress = "134.134.161.33";\r
-    cfg.port = 5683;\r
-    cfg.mode = ModeType::Client;\r
-    cfg.serviceType = ServiceType::InProc;\r
-\r
-    // Create a OCPlatform instance.\r
-    // Note: Platform creation is synchronous call.\r
-    try\r
-    {\r
-        OCPlatform platform(cfg);\r
-    }catch(OCException& e)\r
-    {\r
-        //Handle error\r
-    }\r
- @endcode\r
-\r
-Stack initialization in C++ consists of:\r
-@li Creating a OCPlatform object with Platform configuration which allows definition of role operation (server or client), stack operation (in-process or out-of-process), etc.\r
-@note\r
-@li This is a synchronous call. The application will receive an exception if platform object creation fails.\r
-@li The C++ SDK handles all of the memory allocation and collection. Therefore, the application need not worry about memory management related to the stack.\r
-@li Platform creation happens on the main thread while the message pump happens on a worker thread.\r
-\r
-\r
-\r
-\r
-\r
-********************************************************************\r
-\r
-@page Guide_Register_Resource Registering A Resource\r
-\r
-Registering a resource requires two basic items:\r
-\li A handler to process requests from the stack, and\r
-\li A URI path to register the resource. \r
-The URI path should be rooted (in other words, start with a slash). The stack will construct the fully qualified URI by adding the URI authority to the provided URI path. For example, given a service running on port 5683 in a device at IP address 192.168.1.1, if the application registers a resource with a URI path "/light/1", the resulting fully qualified URI is "oc://192.168.1.1:5683/light/1", which uniquely identifies the resource's location (IP address port and path).\r
-@note Only one resource can be registered at a given URI.\r
\r
-@image HTML seq_register_resource_2.png\r
-\r
-@section Register_Resource_SD Sequence Diagram\r
-The following call sequence diagram outlines the operations performed in the stack when a resource is registered:\r
-\r
-@image HTML seq_register_resource.png\r
-\r
-<b>Step 1</b>:\r
-Assuming the application has created a valid OCPlatform object, the application registers a new resource with the stack by calling OCPlatform::registerResource(...).\r
-\r
-In this example, the call would take the form:\r
-\r
-       platform.registerResource(&handle, "/light/1", "light", "oc.mi.def", handler, OC_DISCOVERABLE)\r
-\r
-The handle is a reference to the resource that is used on other APIs. The URI path ("/light/1") is where on this server that the resource can be located. The URI path is unique; this call will fail if the application attempts to register another resource using an existing URI. The resource type ("light") and interface ("oc.mi.def") are properties of the resource used in the discovery process. The handler is a function called from the stack to process requests. The flags control how the stack should handle the resource. The OC_DISCOVERABLE flag indicates that the resource should be reported if a client performs a resource discovery on this server.\r
-\r
-<b>Step 2</b>:\r
-\r
-The OCPlatform::registerResource(...) method delegates the call to the appropriate instance of the stack (in-process or out-of-process via IPC).\r
-\r
-<b>Step 3</b>:\r
-The internal registerResource(...) method constructs a C++ entity handler and registers it with the C SDK using OCCreateResource(...).\r
-\r
-In this example, the call would take the form:\r
-\r
-       OCCreateResource(&handle, "light", "oc.mi.def", "/light/1", handler, OC_ DISCOVERABLE)\r
-\r
-Many of these parameters are passed through to the C SDK directly. However, the entity handler is a proxy function for the handler passed from OCPlatform::registerResource(...).\r
\r
-@section Register_Resource_CPP Register Resource in C++ [Server]\r
-\r
-@code{.cpp}\r
-    OCResourceHandle resourceHandle;\r
-    std::string resourceURI = "/light/1"; \r
-    std::string resourceTypeName = "alpha.light\r
-    std::string resourceInterface = DEFAULT_INTERFACE; \r
-    uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;\r
-\r
-    OCStackResult result = platform.registerResource(resourceHandle, \r
-                                                        resourceURI,\r
-                                                        resourceTypeName,\r
-                                                        resourceInterface,\r
-                                                        &entityHandler,\r
-                                                        resourceProperty);\r
-\r
-    if (OC_STACK_OK == result)\r
-    {\r
-        //Successfull\r
-    }\r
-\r
-\r
-@endcode\r
-\r
-\r
-\r
-********************************************************************\r
-\r
-@page Guide_Find_Resource Finding A Resource\r
-\r
-This operation returns all resources of given type on the network service. This operation is sent via multicast to all services. However, the filter limits the responders to just those that support the resource type in the query. Currently only exact matches are supported.\r
-\r
-@image HTML seq_find_resource_2.png\r
-\r
-@section Find_Resource_SD Sequence Diagram\r
-\r
-The following sequence diagram illustrates the resource discovery process over the network when using CoAP. The mechanism is different for Bluetooth, SSDP/HTTP, etc. In the case of CoAP, a 'get' request is sent via multicast to all IoTivity devices. Each device processes the query and responds if the request filter is satisfied. \r
-\r
-In the following example, the client requests all of the light resources with a resource type (rt). Both lights respond to the request, but the fan does not.\r
-\r
-@image HTML seq_find_resource_3.png\r
-\r
-\r
-The following sequence diagram describes the call sequence for discovery from the client side.\r
-@image HTML seq_find_resource.png\r
-\r
-Notes:\r
-\li Assuming that the client has a properly initialized OCPlatform object, a C++ SDK client can discover resources by calling OCPlatform::findResources(...).\r
-\r
-In this example, the call would take the form:\r
-\r
-       platform.findResources("", "/oc/core?rt=alpha.light", findHandler)\r
-\r
-The first parameter is the URI authority (target host), which, when empty, indicates that this is for all nodes. The second parameter ("/oc/core?rt=alpha.light") is the URI path and URI query. The URI path ("/oc/core") indicates the resource and the URI query ("rt=alpha.light") is the filter.\r
-\r
-\li The SDK call findResources(...) internally delegates the call directly to the in-process or to the out-of process stack via IPC based on the stack configuration.\r
-\li Within the stack, findResource(...) calls the C API function OCDoResource(...). In this example, the call is OCDoResource(&handle, OC_REST_GET, "/oc/core?rt=alpha.light", 0, 0, OC_NON_CONFIRMABLE,  ...)\r
-\li OCDoResource determines which transport is needed to dispatch the request and delegates the call. In the case of CoAP, the following calls are made:\r
-       - Calls OCDoCoapResource(OC_REST_GET, OC_NON_CONFIRMABLE, token, "/oc/core?rt=alpha.light", 0). The token in this example is a nonce that ties a CoAP response back to the CoAP request. Internally, this method creates the CoAP PDU for dispatching.\r
-       - Calls coap_send(context, host, pdu), which is a wrapper for the implementation below.\r
-       - Calls coap_send_impl(context, host, packet), which dispatches the packet to the socket and does the appropriate CoAP bookkeeping.\r
-       - Calls OCSend(socket, buffer, size...), which is a wrapper for the socket implementation as the functions for dispatching a UDP packet can vary in the embedded systems.\r
-\li Servers that offer the resource on the network will reply to the query. The message pump that is evoked from the OCProcess(...) function in the C SDK receives these response packets and dispatches them to the callback associated with the original request based on the CoAP message ID. These responses will come back at the timing defined by their servers. The client stack has timeouts for these responses that are listed in the appendices.\r
-\li As previously mentioned, the stack matches the response to the original request using the message ID and send the results to the callback associated with the request. At this level, the raw payload is presented in JSON format. It is the responsibility of the callback passed to OCDoResource(...) to parse this result.\r
-\li The C++ SDK provides a callback to OCDoResource(...) that will parse the results, construct collections of OCResource objects from the response, and pass them to a C++ client using the handler passed to the platform.findResource(...) method. The handler will be called once for each resource server that responds to the query.\r
-\r
-Notes:\r
-\li Some of the API call parameters have been omitted for brevity.\r
-\li The findResource() method can be used in the following ways:\r
-       - Find all resources on the network that match the provided criteria\r
-       - Query a specific (single) server for the resources that it provides matching the provided criteria\r
-\li The findResource() method may be used multiple times to find a resource\r
-\li The findResource() callback is called from the message pump thread in multithreaded environments\r
-\li Blocking in the findResource() callback will block other stack processing including servicing the network I/O which can cause delays and missed packets.\r
-\r
-<b>Detailed server call sequence diagram</b>\r
-The following sequence diagram illustrates the call sequence for discovery from the server side. \r
-\r
-@note When the request is sent to all nodes, all nodes will run through this sequence.\r
-\r
-@image HTML seq_find_resource_4.png\r
-\r
-Notes:\r
-\li The discovery request under CoAP is handled like any other resource GET request. The request can be received via unicast or multicast, but the response, if any, is always sent via unicast.\r
-\li The stack dispatches the request to an entity handler that is defined by the stack.\r
-\li The handler for "/oc/core", processes the URI query, if any, and builds a list of resources that match the criteria and returns the result in JSON to the network transport.\r
-\li In the case of CoAP, if the request is made to all nodes (multicast) and the resource list is empty, no response is sent to the clients. If the request is directed (unicast) or the resource list has results, the response is sent unicast back the client.\r
-\r
-\r
-@section Find_Resource_CPP Register Resource in C++ [Client]\r
-\r
-@code{.cpp}\r
-// Callback to found resources\r
-    void foundResource(std::shared_ptr<OCResource> resource)\r
-    {\r
-            \r
-    std::string resourceURI;\r
-    std::string hostAddress;\r
-    try\r
-    {\r
-        // Do some operations with resource object.\r
-        if(resource)\r
-        {\r
-            std::cout<<"DISCOVERED Resource:"<<std::endl;\r
-            // Get the resource URI\r
-            resourceURI = resource->uri();\r
-            std::cout << "\tURI of the resource: " << resourceURI << std::endl;\r
-\r
-            // Get the resource host address\r
-            hostAddress = resource->host();\r
-            std::cout << "\tHost address of the resource: " << hostAddress << std::endl;\r
-\r
-            // Get the resource types\r
-            std::cout << "\tList of resource types: " << std::endl;\r
-            for(auto &resourceTypes : resource->getResourceTypes())\r
-            {\r
-                std::cout << "\t\t" << resourceTypes << std::endl;\r
-            }\r
-\r
-            // Get the resource interfaces\r
-            std::cout << "\tList of resource interfaces: " << std::endl;\r
-            for(auto &resourceInterfaces : resource->getResourceInterfaces())\r
-            {\r
-                std::cout << "\t\t" << resourceInterfaces << std::endl;\r
-            }\r
-\r
-            if(resourceURI == "/a/light1")\r
-            {\r
-                // Found interested resource\r
-            }\r
-        }\r
-        else\r
-        {\r
-            // Resource is invalid\r
-            std::cout << "Resource is invalid" << std::endl;\r
-        }\r
-\r
-    }\r
-    catch(std::exception& e)\r
-    {\r
-        //log\r
-    }\r
-\r
-    }\r
-\r
-\r
-    try\r
-    {\r
-        OCPlatform platform(cfg);\r
-\r
-        // Find all resources\r
-        platform.findResource("", "coap://224.0.1.187/oc/core?rt=alpha.light", &foundResource);\r
-\r
-    }catch(OCException& e)\r
-    {\r
-        //Handle Error\r
-    }\r
-\r
-\r
-@endcode\r
-\r
-@section Find_Resource_OTA_Request Over the air Request\r
-\r
-The request is sent to all nodes on the network:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Note(s)</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>224.0.1.187:5683</p></td>\r
-<td valign="top" ><p>Multicast packet</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>NON, GET, MID=0x7d40</p></td>\r
-<td valign="top" ><p>Multicast discovery request should be non-confirmable</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>oc</p></td>\r
-<td rowspan="3" valign="top" ><p>"/oc/core?rt=alpha.light"</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>core</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Query</p></td>\r
-<td valign="top" ><p>rt=alpha.light</p></td>\r
-<td valign="middle" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Accept</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-\r
-</table>\r
-\r
-\r
-\r
-@section Find_Resource_OTA_Response Over the air Response(s)\r
-\r
-Assuming that all of the representative devices (see @ref Guide_Representative_Devices "Representative Devices") are online, three responses are expected. Only the three devices with light resources respond; the list of resources has been filtered to contain just the resources that match the criteria.\r
-\r
-<b>From 192.168.1.11</b>:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, CONTENT, MID=0x7d40</p></td>\r
-<td valign="top" ><p>Success w/content</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Content</p>\r
-\r
-<p>Format</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>[</p>\r
-\r
-<p>{ "href" : "/light/1", "rt":["alpha.light"], "if":["oc.mi.def"], "obs":1}</p>\r
-\r
-<p>]</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-<b>From 192.168.1.12</b>:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, CONTENT, MID=0x7d40</p></td>\r
-<td valign="top" ><p>Success w/content</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Content</p>\r
-\r
-<p>Format</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>[</p>\r
-\r
-<p>{ "href" : "/light/2", "rt":["alpha.light"], "if":["oc.mi.def"], "obs":1}</p>\r
-\r
-<p>]</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-<b>From 192.168.1.13</b>:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, CONTENT, MID=0x7d40</p></td>\r
-<td valign="top" ><p>Success w/content</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Content</p>\r
-\r
-<p>Format</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>[</p>\r
-\r
-<p>{ "href" : "/light/1", "rt":["alpha.light"], "if":["oc.mi.def"], "obs":1},</p>\r
-\r
-<p>{ "href" : "/light/2", "rt":["alpha.light"], "if":["oc.mi.def"], "obs":1}</p>\r
-\r
-<p>]</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-********************************************************************\r
-\r
-@page Guide_PUT Setting a resource state [PUT]\r
-\r
-This operation sets the value of a simple resource. In this example, we turn on a light resource and set the brightness to 50%.\r
-\r
-@section PUT_SD Sequence Diagram\r
-\r
-@image HTML seq_put.png\r
-\r
-Steps:\r
-1.     The client application calls resource.put(...) to set representation of resource. \r
-Example call: \r
-resource.put(attributeMap, queryParamsMap, &onPut);   \r
-2.     Client SDK internally calls the setResourceAttributes function of the client wrapper.\r
-Example call:\r
-OCDoResource(OC_REST_PUT, "//192.168.1.11/light/1, 0, 0, OC_CONFIRMABLE, callback);\r
-3.     Send PUT request to remote device\r
-4.     The OCProcess() service function (server-side message pump) reads the packet from the socket and dispatches the request to the entity handler for the provided URI.\r
-5.     The entity handler, which was provided by an upper layer when the resource was registered, parses the representation and in the case of the C++ API passes the results to the upper layer handler. In a C only environment, the results would also be processed in the entity handler.\r
-6.     The upper layer entity handler written by the app developer/vendor is invoked, and response is formed accordingly.\r
-7.     The upper layer entity handler returns success or failure with a response.\r
-8.     Returns   success or failure to lower layer for transmission to client.\r
-9.     Returns success or failure to lower layer for transmission to client.\r
-10.    Returns success or failure to lower layer for transmission to client.\r
-11.    Result is formatted and sent over network to client\r
-12.    The OCProcess() service function (client-side message pump) reads results and passes the results back to the client application via the callback passed to OCDoResource\r
-\r
-\r
-@section PUT__Client_CPP Set Resource's State [PUT] in C++ [Client]\r
-\r
-@code{.cpp}\r
-void putLightRepresentation(std::shared_ptr<OCResource> resource)\r
-{\r
-    if(resource)\r
-    {\r
-        OCRepresentation rep;\r
-\r
-        std::cout << "Putting light representation..."<<std::endl;\r
-        // Create AttributeMap\r
-        AttributeMap attributeMap;\r
-        // Add the attribute name and values in the attribute map\r
-        AttributeValues stateVal;\r
-        stateVal.push_back("true");\r
-\r
-        AttributeValues powerVal;\r
-        powerVal.push_back("10");\r
-\r
-        attributeMap["state"] = stateVal;\r
-        attributeMap["power"] = powerVal;\r
-\r
-        // Create QueryParameters Map and add query params (if any)\r
-        QueryParamsMap queryParamsMap;\r
-\r
-        rep.setAttributeMap(attributeMap);\r
-\r
-        // Invoke resource's put API with attribute map, query map and the callback parameter\r
-        resource->put(rep, queryParamsMap, &onPut);\r
-    }\r
-}\r
-\r
-// callback handler on PUT request\r
-void onPut(const OCRepresentation& rep, const int eCode)\r
-{\r
-    if(eCode == SUCCESS_RESPONSE)\r
-    {\r
-        std::cout << "PUT request was successful" << std::endl;\r
-\r
-        AttributeMap attributeMap = rep.getAttributeMap();\r
-\r
-        for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)\r
-        {\r
-            std::cout << "\tAttribute name: "<< it->first << " value: ";\r
-            for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)\r
-            {\r
-                std::cout <<"\t"<< *valueItr << " ";\r
-            }\r
-\r
-            std::cout << std::endl;\r
-        }\r
-\r
-        std::vector<OCRepresentation> children = rep.getChildren();\r
-\r
-        for(auto oit = children.begin(); oit != children.end(); ++oit)\r
-        {\r
-            attributeMap = oit->getAttributeMap();\r
-\r
-            for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)\r
-            {\r
-                std::cout << "\tAttribute name: "<< it->first << " value: ";\r
-                for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)\r
-                {\r
-                    std::cout <<"\t"<< *valueItr << " ";\r
-                }\r
-\r
-                std::cout << std::endl;\r
-            }\r
-        }\r
-\r
-    }\r
-    else\r
-    {\r
-        std::cout << "onPut Response error: " << eCode << std::endl;\r
-        std::exit(-1);\r
-    }\r
-}\r
-\r
-@endcode\r
-\r
-@section PUT_Server_CPP Set Resource's State [PUT] in C++ [Server]\r
-\r
-@code{.cpp}\r
-//Entity handle sample for PUT\r
-            if(requestType == "PUT")\r
-            {\r
-                cout << "\t\t\trequestType : PUT\n";\r
-\r
-                // Check for query params (if any)\r
-                QueryParamsMap queryParamsMap = request->getQueryParameters();\r
-\r
-                cout << "\t\t\tquery params: \n";\r
-                for(auto it = queryParamsMap.begin(); it != queryParamsMap.end(); it++)\r
-                {\r
-                    cout << "\t\t\t\t" << it->first << ":" << it->second << endl;\r
-                }\r
-\r
-                // Get the representation from the request\r
-                OCRepresentation rep = request->getResourceRepresentation();\r
-\r
-                myLightResource.setRepresentation(rep); // See code snippet below\r
-\r
-                // Do related operations related to PUT request // See code snippet below\r
-                rep = myLightResource.getRepresentation();\r
-\r
-                if(response)\r
-                {\r
-                    \r
-                    response->setErrorCode(200);\r
-\r
-                    auto findRes = queryParamsMap.find("if");\r
-\r
-                    if(findRes != queryParamsMap.end())\r
-                    {\r
-                        response->setResourceRepresentation(rep, findRes->second);\r
-                    }\r
-                    else\r
-                    {\r
-                        response->setResourceRepresentation(rep, DEFAULT_INTERFACE);\r
-                    }\r
-                }\r
-}\r
-\r
-    void setRepresentation(OCRepresentation& light)\r
-    {\r
-        AttributeMap attributeMap = light.getAttributeMap();\r
-\r
-        if(attributeMap.find("state") != attributeMap.end() && attributeMap.find("power") != attributeMap.end())\r
-        {\r
-            cout << "\t\t\t" << "Received representation: " << endl;\r
-            cout << "\t\t\t\t" << "power: " << attributeMap["power"][0] << endl;\r
-            cout << "\t\t\t\t" << "state: " << attributeMap["state"][0] << endl;\r
-\r
-            m_state = attributeMap["state"][0].compare("true") == 0;\r
-            m_power= std::stoi(attributeMap["power"][0]);\r
-        }\r
-    }\r
-\r
-    OCRepresentation getRepresentation()\r
-    {\r
-        OCRepresentation light;\r
-\r
-        light.setUri(m_lightUri);\r
-\r
-        std::vector<std::string> interfaces;\r
-        //interfaces.push_back(m_lightInterface);\r
-\r
-        light.setResourceInterfaces(interfaces);\r
-\r
-        std::vector<std::string> types;\r
-        //types.push_back(m_lightType);\r
-\r
-        light.setResourceTypes(types);\r
-\r
-        AttributeMap attributeMap;\r
-        AttributeValues stateVal;\r
-        if(m_state)\r
-        {\r
-            stateVal.push_back("true");\r
-        }\r
-        else\r
-        {\r
-            stateVal.push_back("false");\r
-        }\r
-\r
-        AttributeValues powerVal;\r
-        powerVal.push_back(to_string(m_power));\r
-\r
-        attributeMap["state"] = stateVal;\r
-        attributeMap["power"] = powerVal;\r
-\r
-        light.setAttributeMap(attributeMap);\r
-\r
-        return light;\r
-    }\r
-\r
-@endcode\r
-\r
-\r
-@section PUT_OTA_Response Over the air request\r
-\r
-In this example, we are pushing state to one of the lights. At this point, the resource was discovered by its type, and we understand its interface and the attributes exposed by the resource.\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-\r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Note(s)</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.13:5683</p></td>\r
-<td valign="top" ><p>Unicast packet</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>CON, PUT, MID=0x7d41</p></td>\r
-<td valign="top" ><p>Confirmation is requested</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>light</p></td>\r
-<td rowspan="2" valign="top" ><p>"/light/1"</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>1</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Content-Type</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"power" : 1,</p>\r
-\r
-<p>"level" : 5</p>\r
-\r
-<p>}</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-@section PUT_OTA_Response Over the air response(s)\r
-\r
-Assuming that the request is valid and the resource is able to complete the transition, the following represents a successful change in state.\r
-\r
-<b>From 192.168.1.13</b>:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-\r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, CHANGED, MID=0x7d41</p></td>\r
-<td valign="top" ><p>Success (changed)</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-**********************************************************************\r
-\r
-@page Guide_GET Querying resource State [GET]\r
-\r
-This operation fetches the value of a simple resource. In this example, we fetch the state from the light resource.\r
-\r
-@section GET_SD Sequence Diagram\r
-@image HTML seq_get.png\r
-\r
-Steps:\r
-1.     The client application calls resource.get(...) to retrieve a representation from the resources.\r
-2.     The call is marshalled to the stack which is either running in-process or out-of-process (daemon).\r
-3.     The C API is called to dispatch the request. The call may look like the following:\r
-OCDoResource(OC_REST_GET, "//192.168.1.11/light/1, 0, 0, OC_CONFIRMABLE, callback); \r
-4.     Where CoAP is used as a transport, the lower stack will send a GET request to the target server.\r
-5.     On the server side, the OCProcess() function (message pump) receives and parses the request from the socket, then dispatches it to the correct entity handler based on the URI of the request.\r
-6.     Where the C++ API is used, the C++ entity handler parses the payload and marshals it to the client application depending on if the server stack is running in-process or out-of-process (daemon).\r
-7.     The C++ SDK passes it up the C++ handler associated with the OCResource.\r
-8.     The handler returns the result code and representation to the SDK.\r
-9.     The SDK marshals the result code and representation to the C++ entity handler.\r
-10.    The entity handler returns the result code and representation to the CoAP protocol.\r
-11.    The CoAP protocol transports the results to the client device.\r
-12.    The results are returned the OCDoResource callback.\r
-13.    The results are returned to the C++ client application's asyncResultCallback.\r
-\r
-@section GET_Client_CPP Querying resource State [GET] in C++ [Client]\r
-@code{.cpp}\r
-// Local function to get representation of light resource\r
-void getLightRepresentation(std::shared_ptr<OCResource> resource)\r
-{\r
-    if(resource)\r
-    {\r
-        std::cout << "Getting Light Representation..."<<std::endl;\r
-        // Invoke resource's get API with the callback parameter\r
-\r
-        QueryParamsMap test;\r
-        resource->get(test, &onGet);\r
-    }\r
-}\r
-\r
-// callback handler on GET request\r
-void onGet(const OCRepresentation& rep, const int eCode)\r
-{\r
-    if(eCode == SUCCESS_RESPONSE)\r
-    {\r
-        std::cout << "GET request was successful" << std::endl;\r
-\r
-        AttributeMap attributeMap = rep.getAttributeMap();\r
-\r
-        std::cout << "Resource URI: " << rep.getUri() << std::endl;\r
-\r
-        for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)\r
-        {\r
-            std::cout << "\tAttribute name: "<< it->first << " value: ";\r
-            for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)\r
-            {\r
-                std::cout <<"\t"<< *valueItr << " ";\r
-            }\r
-\r
-            std::cout << std::endl;\r
-        }\r
-\r
-        std::vector<OCRepresentation> children = rep.getChildren();\r
-\r
-        for(auto oit = children.begin(); oit != children.end(); ++oit)\r
-        {\r
-            std::cout << "Child Resource URI: " << oit->getUri() << std::endl;\r
-\r
-            attributeMap = oit->getAttributeMap();\r
-\r
-            for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)\r
-            {\r
-                std::cout << "\tAttribute name: "<< it->first << " value: ";\r
-                for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)\r
-                {\r
-                    std::cout <<"\t"<< *valueItr << " ";\r
-                }\r
-\r
-                std::cout << std::endl;\r
-            }\r
-        }\r
-\r
-        putLightRepresentation(curResource);\r
-    }\r
-    else\r
-    {\r
-        std::cout << "onGET Response error: " << eCode << std::endl;\r
-        std::exit(-1);\r
-    }\r
-}\r
-\r
-\r
-@endcode\r
-\r
-@section GET_Server_CPP Querying resource State [GET] in C++ [Server]\r
-@code{.cpp}\r
-\r
-// Handling GET request in Entity handler            \r
-if(requestType == "GET")\r
-            {\r
-                cout << "\t\t\trequestType : GET\n";\r
-\r
-                // Check for query params (if any)\r
-                QueryParamsMap queryParamsMap = request->getQueryParameters();\r
-\r
-                cout << "\t\t\tquery params: \n";\r
-                for(QueryParamsMap::iterator it = queryParamsMap.begin(); it != queryParamsMap.end(); it++)\r
-                {\r
-                    cout << "\t\t\t\t" << it->first << ":" << it->second << endl;\r
-                }\r
-\r
-                // Process query params and do required operations ..\r
-\r
-                // Get the representation of this resource at this point and send it as response\r
-                // AttributeMap attributeMap;\r
-                OCRepresentation rep;\r
-                rep = myLightResource.getRepresentation();\r
-\r
-                if(response)\r
-                {\r
-                    // TODO Error Code\r
-                    response->setErrorCode(200);\r
-\r
-                    auto findRes = queryParamsMap.find("if");\r
-\r
-                    if(findRes != queryParamsMap.end())\r
-                    {\r
-                        response->setResourceRepresentation(rep, findRes->second);\r
-                    }\r
-                    else\r
-                    {\r
-                        response->setResourceRepresentation(rep, DEFAULT_INTERFACE);\r
-                    }\r
-                }\r
-            }\r
-\r
-\r
-@endcode\r
-\r
-\r
-@section GET_OTA_Response Over the air request\r
-\r
-In this example, we are querying state from one of the lights. At this point, the resource was discovered by its type, and we understand its interface and the attributes that the resource exposes.\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Note(s)</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.11:5683</p></td>\r
-<td valign="top" ><p>Unicast packet</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>CON, GET, MID=0x7d42</p></td>\r
-<td valign="top" ><p>Confirmation is requested</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>light</p></td>\r
-<td rowspan="2" valign="top" ><p>"/light/1"</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>1</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Accept</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-@section GET_OTA_Response Over the air response(s)\r
-\r
-Assuming that the request is valid, we expect the following reply from the resource.\r
-\r
-<b>From 192.168.1.11</b>:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, CONTENT, MID=0x7d42</p></td>\r
-<td valign="top" ><p>Success w/Content</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Content</p>\r
-\r
-<p>Type</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"power" : 0,</p>\r
-\r
-<p>"level" : 10</p>\r
-\r
-<p>}</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-\r
-**********************************************************************\r
-\r
-@page Guide_Observe Observing resource state [Observe]\r
-\r
-This operation fetches and registers as an observer for the value of a simple resource. In this example, we fetch the state of the light resource. For more implementation details, see "Observing Resources in CoAP" listed in the referenced documents. (https://datatracker.ietf.org/doc/draft-ietf-core-observe/?include_text=1)\r
-\r
-The handling of observation registration is application specific. It should not be assumed that a resource is observable, or a resource can handle any specific number of observers. If the server responds with a success (2.xx) code, the registration is considered successful.\r
-\r
-Notifications from the server to the client may be confirmable or non-confirmable. If the client returns a RST message, the observation registration should be dropped immediately. If the client fails to acknowledge a number of confirmable requests, the server should assume that the client has abandoned the observation and drop the registration.\r
-\r
-If the observed resource is removed, the server sends a NOTFOUND status to all observers.\r
-\r
-If an observed resource fails to notify a client before the max-age of a resource value update, the client should attempt to re-register the observation.\r
-\r
-\r
-@section Observe_SD Sequence Diagram\r
-@image HTML seq_observe.png\r
-\r
-Steps:\r
-1.     The client application calls resource.observe(...) to retrieve a representation from the resources.\r
-2.     The call is marshalled to the stack which is either running in-process or out-of-process (daemon).\r
-3.     The C API is called to dispatch the request. The call may look like this:\r
-OCDoResource(OC_REST_GET | OC_REST_OBSERVE, "//192.168.1.11/light/1, 0, 0, OC_CONFIRMABLE, callback);\r
-4.     Where CoAP is used as a transport, the lower stack will send a GET request to the target server. The primary difference between a GET request and an observe request is that the observe request contains an observe option indicating that, in addition to querying this resource, the client wishes to get notifications if/when the resource state changes.\r
-5.     On the server side, the OCProcess() function (message pump) receives and parses the request from the socket, then dispatches it to the correct entity handler based on the URI of the request. The request to the entity handler will indicate that the request is both a query and subscription request. The entity handler MAY take note of this, but it is not responsible to tracking the observers. The stack tracks the observers of record.\r
-6.     Where the C++ API is used the C++ entity handler parses the payload and marshals it to the client application depending on if the server stack is running in-process or out-of-process (daemon).\r
-7.     The C++ SDK passes it up the C++ handler associated with the OCResource.\r
-8.     The handler returns the result code and representation to the SDK.\r
-9.     The SDK marshals the result code and representation to the C++ entity handler.\r
-10.    The entity handler returns the result code and representation to the CoAP protocol.\r
-11.    The CoAP protocol transport the results to the client device.\r
-12.    The results are returned to the OCDoResource callback.\r
-13.    The results are returned to the C++ client application's asyncResultCallback.\r
-14.    If the entity handler has registered   observers, it will periodically be called with the observe flag set so that it may sample or poll underlying hardware to determine if the state has changes.\r
-15.    When the application has deemed that the resource state has changed either via polling (entity handler observe) or via external signal, the application should call OCNotifyObservers(). This tells the stack the observers need updating.\r
-16.    For each observer of a changed resource, the entity handler is called to generate a representation that is transmitted to the observing clients. \r
-17.    Where CoAP is used as a transport, a packet with content is sent to the devices that have observing clients. The packets may be confirmable or non-confirmable based on application needs.\r
-18.    The client-side OCProcess function (message pump) receives the message and matches it to the original request based on the CoAP token ID and dispatches the appropriate \r
-C API callback.\r
-19.    The C API callback passes the final results to the C++ client application's asyncResultCallback.\r
-20.    When the C++ client no longer desires to receive notifications from the server, it calls observation cancellation method cancelObserve(). \r
-21.    The C++ cancellation method calls the OCCancel() function from the C API.\r
-22.    OCCancel() finds the observation that is associated with the operation and sends an observe deregistration request to the server.\r
-\r
-\r
-@section Observe_Client_CPP Observing resource state [Observe] in C++ [Client]\r
-@code{.cpp}\r
-      if (OBSERVE_TYPE_TO_USE == ObserveType::Observe)\r
-            std::cout << endl << "Observe is used." << endl << endl;\r
-        else if (OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)\r
-            std::cout << endl << "ObserveAll is used." << endl << endl;\r
-\r
-        QueryParamsMap test;\r
-\r
-        curResource->observe(OBSERVE_TYPE_TO_USE, test, &onObserve);\r
-\r
-// callback\r
-void onObserve(const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)\r
-{\r
-    if(eCode == SUCCESS_RESPONSE)\r
-    {\r
-        AttributeMap attributeMap = rep.getAttributeMap();\r
-\r
-        std::cout << "OBSERVE RESULT:"<<std::endl;\r
-        std::cout << "\tSequenceNumber: "<< sequenceNumber << endl;\r
-        for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)\r
-        {\r
-            std::cout << "\tAttribute name: "<< it->first << " value: ";\r
-            for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)\r
-            {\r
-                std::cout <<"\t"<< *valueItr << " ";\r
-            }\r
-\r
-            std::cout << std::endl;\r
-        }\r
-\r
-        if(observe_count() > 30)\r
-        {\r
-            std::cout<<"Cancelling Observe..."<<std::endl;\r
-            OCStackResult result = curResource->cancelObserve();\r
-\r
-            std::cout << "Cancel result: "<< result <<std::endl;\r
-            sleep(10);\r
-            std::cout << "DONE"<<std::endl;\r
-            std::exit(0);\r
-        }\r
-    }\r
-    else\r
-    {\r
-        std::cout << "onObserve Response error: " << eCode << std::endl;\r
-        std::exit(-1);\r
-    }\r
-}\r
-\r
-\r
-@endcode\r
-\r
-\r
-\r
-@section Observe_Server_CPP Observing resource state [Observe] in C++ [Server]\r
-@code{.cpp}\r
-// Handling observe in server's entity handler        \r
-if(requestFlag == RequestHandlerFlag::ObserverFlag)\r
-        {\r
-            pthread_t threadId;\r
-\r
-            cout << "\t\trequestFlag : Observer\n";\r
-            gObservation = 1;\r
-\r
-            static int startedThread = 0;\r
-\r
-            // Observation happens on a different thread in ChangeLightRepresentation function.\r
-            // If we have not created the thread already, we will create one here.\r
-            if(!startedThread)\r
-            {\r
-                pthread_create (&threadId, NULL, ChangeLightRepresentation, (void *)NULL);\r
-                startedThread = 1;\r
-            }\r
-\r
-// ChangeLightRepresentaion is an observation function,\r
-// which notifies any changes to the resource to stack\r
-// via notifyObservers\r
-void * ChangeLightRepresentation (void *param)\r
-{\r
-    // This function continuously monitors for the changes\r
-    while (1)\r
-    {\r
-        sleep (5);\r
-\r
-        if (gObservation)\r
-        {\r
-            // If under observation if there are any changes to the light resource\r
-            // we call notifyObservors\r
-            //\r
-            // For demostration we are changing the power value and notifying.\r
-            myLightResource.m_power += 10;\r
-\r
-            cout << "\nPower updated to : " << myLightResource.m_power << endl;\r
-            cout << "Notifying observers with resource handle: " << myLightResource.getHandle() << endl;\r
-\r
-            OCStackResult result = OCPlatform::notifyObservers(myLightResource.getHandle());\r
-\r
-            if(OC_STACK_NO_OBSERVERS == result)\r
-            {\r
-                cout << "No More observers, stopping notifications" << endl;\r
-                gObservation = 0;\r
-            }\r
-        }\r
-    }\r
-\r
-    return NULL;\r
-}\r
-\r
-\r
-@endcode\r
-\r
-\r
-\r
-\r
-@section Oberve_OTA_Response Over the air request\r
-\r
-The following observation request is basically a GET request with the observation option set.\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-<tr>\r
-<td valign="top" ><p>Fields</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Notes</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.11:5683</p></td>\r
-<td valign="top" ><p>Unicast packet</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>CON, GET, MID=0x7d44, TOK=0x3f</p></td>\r
-<td valign="top" ><p>Confirmation requested</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Observe</p></td>\r
-<td valign="top" ><p>Register (0)</p></td>\r
-<td valign="top" ><p>This indicates registration</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>Light</p></td>\r
-<td valign="top" ><p>"/light/1 "</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>URI-Path</p></td>\r
-<td valign="top" ><p>1</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Accept</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p>Requesting result in JSON</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-@section Observe_OTA_Response Over the air response(s)\r
-\r
-A successful observe request would be similar to the following:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, CONTENT, MID=0x7d44, TOK=0x3f</p></td>\r
-<td valign="top" ><p>Success w/content</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Observe</p></td>\r
-<td valign="top" ><p>12</p></td>\r
-<td valign="top" ><p>Sequence number for ordering</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Max-Age</p></td>\r
-<td valign="top" ><p>30</p></td>\r
-<td valign="top" ><p>Indicates that the value is fresh for 30 seconds.</p>\r
-\r
-<p>It also indicates that the server should send an</p>\r
-\r
-<p>update within this time period.</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Content</p>\r
-\r
-<p>Type</p></td>\r
-<td valign="top" ><p>application/json</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"power" : 0,</p>\r
-\r
-<p>"level" : 10</p>\r
-\r
-<p>}</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-<b>Subsequent Notifications from 192.168.1.1 </b>\r
-\r
-If the light resource is being observed and the light transitions from an off state to an on state, a notification is sent to the client from the server. The following is an example of such a notification:\r
-\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.1:5683</p></td>\r
-<td valign="top" ><p>Client Address</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>CON, CONTENT, MID=0x7D45, TOK=0x3f</p></td>\r
-<td valign="top" ><p>Content, Can be confirmable or non-confirmable</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Observe</p></td>\r
-<td valign="top" ><p>15</p></td>\r
-<td valign="top" ><p>Monotonically increasing until overflow</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Max-Age</p></td>\r
-<td valign="top" ><p>30</p></td>\r
-<td valign="top" ><p>Indicates that the value is fresh for 30 seconds.</p>\r
-\r
-<p>It also indicates that the server should send an</p>\r
-\r
-<p>update within this time period.</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Payload</p></td>\r
-<td valign="top" ><p>{</p>\r
-\r
-<p>"power" : 1,</p>\r
-\r
-<p>"level" : 10</p>\r
-\r
-<p>}</p></td>\r
-<td valign="top" ><p><br />\r
-</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-Since the above notification was marked confirmable, the client should acknowledge the notification with a packet such as the following:\r
-\r
-<table cellspacing="0" cellpadding="0" border=1> \r
-\r
-<tr>\r
-<td valign="top" ><p>Field</p></td>\r
-<td valign="top" ><p>Value</p></td>\r
-<td valign="top" ><p>Explanation</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Address</p></td>\r
-<td valign="top" ><p>192.168.1.11:5683</p></td>\r
-<td valign="top" ><p>Unicast packet</p></td>\r
-</tr>\r
-\r
-<tr>\r
-<td valign="top" ><p>Header</p></td>\r
-<td valign="top" ><p>ACK, MID=0x7D45, TOK=0x3f</p></td>\r
-<td valign="top" ><p>Success</p></td>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-\r
-\r
-**********************************************************************\r
-\r
-\r
-*/\r
diff --git a/resource/docs/guides/ProgrammersGuide.txt b/resource/docs/guides/ProgrammersGuide.txt
deleted file mode 100644 (file)
index 78f7d46..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/*!\r
-\r
-\r
-@page OCGuides Programmer's Guide\r
-\r
-\r
-This document covers the architecture and basic operations of the Iotivity Resource API stack, including sample coverage of protocol, flows, APIs and some use cases. It is intended to provide context for the developers using IoTivity APIs and provide a high level architectural overview.\r
-\r
-@section Stack_Blocks Stack Blocks\r
-\r
-The Resource API stack consists of several thin layers of software. In unconstrained environments such as Android*, iOS*, or Microsoft* Windows*, the stack provides APIs in C and C++ which allow developers to talk to both constrained and unconstrained devices via IP networks, with potential support for additional network protocols and wireless technologies. In the first release, the key technologies for connectivity include UDP/IP and the Constrained Application Protocol (CoAP).
-\r
-@image html stack_diagram.png\r
-\r
-@section Terminology Terminology\r
-\r
-<b>Device</b>\r
-A constrained device that has the Thin Block stack installed which enabled one or more services for other Thin Block or Unified Block devices to consume.\r
-\r
-<b>Resource</b>\r
-A resource is a component in a server that can be viewed and controlled by another Thin Block or Unified Block device. There are different resource types, for example a temperature sensor, a light controller etc.\r
-\r
-Resources can be arranged in a hierarchal manner to form a tree of resources. This generic method of structure enables one to model many different topologies of resources.\r
-\r
-@li Example: A light controller could be a resource.\r
-@li Example: A light array could be a set of resources organized in a flat (non-hierarchical) manner.\r
-@li Example: A garage door opener could be a resource; it could host two resources - light and lock.\r
-\r
-A more detailed description of resources and management of resources along with code snippets is provided later in this document.\r
-\r
-<b>Operations</b>\r
-Operations are actions that a Thin Block or Unified Block can perform on attributes associated with a particular resource. Resource attributes can have different operations on it based on the nature of the resource type. Fundamentally, these are GET and PUT operations. Additionally, attributes can also be declared to be observable to enable remote devices to subscribe to changes.\r
-\r
-@li Example: One of the child resources on the garage door opener is the light control; it has a GET operation that allows a device to get the current light state (on / off).\r
-\r
-@section Functionally Functionally\r
-\r
-The initial release of IoTivity includes functionally for:\r
- @li @ref Guide_Register_Resource "Resource registration"\r
- @li @ref Guide_Find_Resource "Resource discovery"\r
- @li Device discovery with filtering\r
- @li Property attributes (@ref Guide_GET "get"/ @ref Guide_PUT "set"/ @ref Guide_Observe "observe")\r
- @li Resource tree (resources having sub-resources)\r
- @li Presence notification service defined as a virtual resource (not detailed in this document)\r
-\r
-@section External_References External References \r
-\r
-The following references may provide guidance to this document.\r
- @note In some places, the IoTivity design may differ from the CoRE specifications. In these cases, please consider the CoRE specifications as informative but not definitive on the Iotivity design and architecture.\r
-\r
- @li The Constrained Application Protocol (CoAP) - https://datatracker.ietf.org/doc/rfc7252\r
- @li Constrained RESTful Environments (CoRE) Link Format - https://datatracker.ietf.org/doc/rfc6690\r
- @li Observing Resources in CoAP - https://datatracker.ietf.org/doc/draft-ietf-core-observe\r
- @li CoRE Interfaces (expired draft) - https://datatracker.ietf.org/doc/draft-ietf-core-interfaces\r
-\r
-@section Protocol Protocol Message Format(s)\r
-\r
-The OIC protocol (abbreviated to OC in code) is a REST-like interface similar to HTTP and CoAP. However, it is   a one level up abstraction of the those protocols to allow the addition of additional transports including Bluetooth Classic, Bluetooth Smart (BLE), Zigbee or others in the future. To that end, every attempt has been made to keep CoAP and HTTP specific aspects from being expressed directly in the OIC protocol. The following sections  describe how specific transports are used to support the OIC protocol and abstractions.\r
-\r
-@subsection Protocol_CoAP Constrained Application Protocol (CoAP)\r
-\r
-Constrained Application Protocol is one of the IoTivity supported transports. It is designed to be used in very simple devices and is particularly targeted for small, low power devices like sensors, switches, etc. The protocol is modeled after HTTP and provides easy translation between HTTP and CoAP. It is UDP-based (instead of TCP), providing support for multicast.\r
-\r
-CoAP is now a standard (RFC7252) as defined by the Internet Engineering Task Force (IETF) Constrained RESTful environments (CoRE) Working Group. Additional RFCs and drafts cover higher order behaviors.\r
-\r
-<b>Message format</b>\r
-The following table contains a brief overview of the contents of a CoAP packet. Use it as a cheat sheet for the following discussion. For details on the Constrain Resource Protocol, see http://datatracker.ietf.org/doc/rfc7252/?include_text=1.\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<th valign="top" ><p>Field</p></th>\r
-<th valign="top" ><p>Value</p></th>\r
-<th valign="top" ><p>Short</p>\r
-\r
-<p>Hand</p></th>\r
-<th valign="top" ><p>Notes</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Address</p></th>\r
-<th valign="top" ><p>&lt;Device IPD&gt;:&lt;port&gt;</p>\r
-\r
-<p>224.0.1.187:5683</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p>Device IP address and port multicast group IP address and port</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Version</p></th>\r
-<th valign="top" ><p>Version 1 (01b)</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p>Constant</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Type</p></th>\r
-<th valign="top" ><p>Confirmable (00b)</p>\r
-\r
-<p>Non-confirmable (01b)</p>\r
-\r
-<p>Acknowledgement (10b)</p>\r
-\r
-<p>Reset (11b)</p></th>\r
-<th valign="top" ><p>CON</p>\r
-\r
-<p>NON</p>\r
-\r
-<p>ACK</p>\r
-\r
-<p>RST</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Token</p>\r
-\r
-<p>Length</p></th>\r
-<th valign="top" ><p>Xxxxb</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p>Length of the token. Valid values are between 0 and 8.</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Code</p></th>\r
-<th valign="top" ><p>Request (0.xx)</p>\r
-\r
-<p>Success (2.xx)</p>\r
-\r
-<p>Client error (4.xx)</p>\r
-\r
-<p>Server error (5.xx)</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p>Common requests and responses:</p>\r
-\r
-<p>GET (0.01)</p>\r
-\r
-<p>CREATED (2.01)</p>\r
-\r
-<p>CHANGED (2.04)</p>\r
-\r
-<p>CONTENT (2.05)</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Message</p>\r
-\r
-<p>ID</p></th>\r
-<th valign="top" ><p>0xXXXX</p></th>\r
-<th valign="top" ><p>MID</p></th>\r
-<th valign="top" ><p>Generated by sender</p>\r
-\r
-<p>Allows receiver to de-duplicate requests</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Token</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p>TOK</p></th>\r
-<th valign="top" ><p>Generated by client to match REQ to RESP</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Options</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p>*</p></th>\r
-<th valign="top" ><p>Contains the URI path and query, request and response headers</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Payload</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-<th valign="top" ><p><br />\r
-</p></th>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-<b>Short-hand notation</b>\r
-\r
-The following two tables provide examples of request and response packets with explanations on the meaning of the short-hand notation used through the description of the queries and replies.\r
-\r
-@note Acknowledgements can come back separate from content. For the purposes of understanding the semantics of the query and responses, we will assume that all responses come back immediately. In production, requests can be acknowledged and the contents sent back at a later time. In addition, retry logic, de-duplication, congestion control and other features of the CoAP protocol libraries are neglected here.\r
-\r
-<b>Request example</b>\r
-\r
-In this example, the request is to the CoRE "core" resource in the well-known namespace. It provides a simple example of a multicast request to a compound URI with a query section.\r
-\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<th valign="top" ><p>Fields</p></th>\r
-<th valign="top" ><p>Sample Values</p></th>\r
-<th valign="top" ><p>Explanation</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Address</p></th>\r
-<th valign="top" ><p>224.0.1.187:5683</p></th>\r
-<th valign="top" ><p>Multicast packet address</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Header</p></th>\r
-<th valign="top" ><p>NON, GET, MID=0x7D40</p></th>\r
-<th valign="top" ><p>Non-confirmable</p>\r
-\r
-<p>GET (code=0.01)</p>\r
-\r
-<p>Message ID = 0x7D40</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Token</p></th>\r
-<th valign="top" ><p>0x75, 0x55</p></th>\r
-<th valign="top" ><p>Token Length = s</p>\r
-\r
-<p>Token = 0x75, 0x55</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>URI-Path</p></th>\r
-<th valign="top" ><p>oc</p></th>\r
-<th rowspan="4" valign="top" ><p>"/oc/core?rt=sensor&if=core.ll"</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>URI-Path</p></th>\r
-<th valign="top" ><p>core</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>URI-Query</p></th>\r
-<th valign="top" ><p>rt=sensor</p></th>\r
-<th valign="middle" ><p><br />\r
-</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>URI-Query</p></th>\r
-<th valign="top" ><p>if=core.ll</p></th>\r
-<th valign="middle" ><p><br />\r
-</p></th>\r
-</tr>\r
-\r
-</table>\r
-\r
-<b>Acknowledged response example</b>\r
-\r
-In this example, the response is returned.\r
-@note The payload in this example is for demonstration of the packet format and not a valid discovery response.\r
-\r
-<table cellspacing="0" cellpadding="0" border=1>\r
-\r
-<tr>\r
-<th valign="top" ><p>Fields</p></th>\r
-<th valign="top" ><p>Sample Values</p></th>\r
-<th valign="top" ><p>Explanation</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Address</p></th>\r
-<th valign="top" ><p>192.168.0.0:5683</p></th>\r
-<th valign="top" ><p>Unicast packet</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Header</p></th>\r
-<th valign="top" ><p>ACK, CONTENT, MID=0x7D40</p></th>\r
-<th valign="top" ><p>Non-confirmable</p>\r
-\r
-<p>Content (code=2.05)</p>\r
-\r
-<p>Message ID = 0x7D40</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Token</p></th>\r
-<th valign="top" ><p>0x75, 0x55</p></th>\r
-<th valign="top" ><p>Token Length = 2</p>\r
-\r
-<p>Token = 0x75, 0x55</p></th>\r
-</tr>\r
-\r
-<tr>\r
-<th valign="top" ><p>Payload</p></th>\r
-<th valign="top" ><p>"Sample Payload"</p></th>\r
-<th valign="top" ><p>Raw content</p></th>\r
-</tr>\r
-\r
-</table>\r
-\r
-\r
-\r
-\r
-*/\r
index dd2c96c..9a448bb 100644 (file)
@@ -28,68 +28,76 @@ using namespace OC;
 namespace OIC
 {
 
-GroupSynchronization* GroupSynchronization::groupSyncnstance = NULL;
+    GroupSynchronization* GroupSynchronization::groupSyncnstance = NULL;
 
-GroupSynchronization* GroupSynchronization::getInstance()
-{
-    if (groupSyncnstance == NULL)
+    GroupSynchronization* GroupSynchronization::getInstance()
     {
-        groupSyncnstance = new GroupSynchronization();
+        if (groupSyncnstance == NULL)
+        {
+            groupSyncnstance = new GroupSynchronization();
+        }
+        return groupSyncnstance;
     }
-    return groupSyncnstance;
-}
 
-void GroupSynchronization::deleteInstance()
-{
-    if (groupSyncnstance)
+    void GroupSynchronization::deleteInstance()
     {
-        delete groupSyncnstance;
-        groupSyncnstance = NULL;
+        if (groupSyncnstance)
+        {
+            delete groupSyncnstance;
+            groupSyncnstance = NULL;
+        }
     }
-}
 
-OCStackResult GroupSynchronization::findGroup(
-        std::vector< std::string > collectionResourceTypes, FindCallback callback)
-{
-    cout << "GroupSynchronization::findGroup" << endl;
+    OCStackResult GroupSynchronization::findGroup(
+            std::vector< std::string > collectionResourceTypes, FindCallback callback)
+    {
+        cout << "GroupSynchronization::findGroup" << endl;
 
-    foundGroupResourceList.clear();
+        foundGroupResourceList.clear();
+        findCallback = callback;
 
-    findCallback = callback;
+        if (findCallback == NULL)
+        {
+            return OC_STACK_ERROR;
+        }
 
-    for (unsigned int i = 0; i < collectionResourceTypes.size(); ++i)
-    {
-        std::string query = "coap://224.0.1.187/oc/core?rt=";
-        query.append(collectionResourceTypes.at(i));
-        cout << "GroupSynchronization::findGroup - " << query << endl;
+        for (unsigned int i = 0; i < collectionResourceTypes.size(); ++i)
+        {
+            std::string query = "coap://224.0.1.187/oc/core?rt=";
+            query.append(collectionResourceTypes.at(i));
+            cout << "GroupSynchronization::findGroup - " << query << endl;
 
-        OCPlatform::findResource("", query,
-                std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
-    }
+            OCPlatform::findResource("", query,
+                    std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
+        }
 
-    // thread to check if GroupSynchronization::onFoundGroup is called or not.
-    std::thread t(std::bind(&GroupSynchronization::checkFindGroup, this));
-    t.detach();
+        // thread to check if GroupSynchronization::onFoundGroup is called or not.
+        std::thread t(std::bind(&GroupSynchronization::checkFindGroup, this));
+        t.detach();
 
-    return OC_STACK_OK;
-}
+        return OC_STACK_OK;
+    }
 
-OCStackResult GroupSynchronization::createGroup(std::string collectionResourceType)
-{
-    foundGroupResourceList.clear();
+    OCStackResult GroupSynchronization::createGroup(std::string collectionResourceType)
+    {
+        foundGroupResourceList.clear();
 
-    OCResourceHandle collectionResHandle = NULL;
-    OCResourceHandle groupSyncResHandle = NULL;
+        OCResourceHandle collectionResHandle = NULL;
+        OCResourceHandle groupSyncResHandle = NULL;
+
+        if (0 == collectionResourceType.length())
+        {
+            cout << "GroupSynchronization::createGroup : Error! Input params are wrong." << endl;
+            return OC_STACK_INVALID_PARAM;
+        }
 
-    if (0 != collectionResourceType.length())
-    {
         cout << "GroupSynchronization::createGroup - The created group is added." << endl;
 
         OCStackResult result;
 
         // creating master collection resource
         std::string collectionUri = "/" + collectionResourceType;
-        int i;
+        std::size_t i;
         while ((i = collectionUri.find(".")) != std::string::npos)
         {
             collectionUri.replace(i, 1, "/");
@@ -100,8 +108,7 @@ OCStackResult GroupSynchronization::createGroup(std::string collectionResourceTy
         std::string resourceInterface = DEFAULT_INTERFACE;
 
         result = OCPlatform::registerResource(collectionResHandle, collectionUri,
-                collectionResourceType, resourceInterface, NULL,
-                OC_DISCOVERABLE | OC_OBSERVABLE);
+                collectionResourceType, resourceInterface, NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
         if (result != OC_STACK_OK)
         {
             cout << "To register resource (" << collectionUri << ") was unsuccessful. result - "
@@ -109,75 +116,73 @@ OCStackResult GroupSynchronization::createGroup(std::string collectionResourceTy
             goto Error;
         }
 
-        OCPlatform::bindInterfaceToResource(collectionResHandle, GROUP_INTERFACE);
-        if (result != OC_STACK_OK)
         {
-            cout << "To bind Interface (collection) was unsuccessful. result - " << result
-                    << endl;
-        }
+            OCPlatform::bindInterfaceToResource(collectionResHandle, GROUP_INTERFACE);
+            if (result != OC_STACK_OK)
+            {
+                cout << "To bind Interface (collection) was unsuccessful. result - " << result
+                        << endl;
+            }
 
-        collectionResourceHandleList[collectionResourceType] = collectionResHandle;
+            collectionResourceHandleList[collectionResourceType] = collectionResHandle;
 
-        // creating master group sync resource
-        std::string groupSyncUri = collectionUri + "/groupsync";
-        std::string groupSyncResType = collectionResourceType + ".groupsync";
+            // creating master group sync resource
+            std::string groupSyncUri = collectionUri + "/groupsync";
+            std::string groupSyncResType = collectionResourceType + ".groupsync";
 
 //        cout << "GroupSynchronization::createGroup : groupSync uri - " << groupSyncUri
 //                << ", type - " << collectionResourceType << endl;
 
-        result = OCPlatform::registerResource(groupSyncResHandle, groupSyncUri,
-                groupSyncResType, resourceInterface,
-                std::bind(&GroupSynchronization::groupEntityHandler, this,
-                        std::placeholders::_1), OC_DISCOVERABLE | OC_OBSERVABLE);
-        if (result != OC_STACK_OK)
-        {
-            cout << "To register resource (groupsync) was unsuccessful. result - " << result
-                    << endl;
-            goto Error;
-        }
-
-        groupSyncResourceHandleList[collectionResourceType] = groupSyncResHandle;
+            result = OCPlatform::registerResource(groupSyncResHandle, groupSyncUri,
+                    groupSyncResType, resourceInterface,
+                    std::bind(&GroupSynchronization::groupEntityHandler, this,
+                            std::placeholders::_1), OC_DISCOVERABLE | OC_OBSERVABLE);
+            if (result != OC_STACK_OK)
+            {
+                cout << "To register resource (groupsync) was unsuccessful. result - " << result
+                        << endl;
+                goto Error;
+            }
 
-        return OC_STACK_OK;
-    }
-    else
-    {
-        cout << "GroupSynchronization::createGroup : Error! Input params are wrong." << endl;
-        return OC_STACK_INVALID_PARAM;
-    }
+            groupSyncResourceHandleList[collectionResourceType] = groupSyncResHandle;
 
-    Error:
+            return OC_STACK_OK;
+        }
+        Error:
 
-    if (collectionResHandle)
-    {
-        OCPlatform::unregisterResource(collectionResHandle);
-        auto iterator = collectionResourceHandleList.find(collectionResourceType);
-        if (iterator != collectionResourceHandleList.end())
+        if (collectionResHandle)
         {
-            collectionResourceHandleList.erase(iterator);
+            OCPlatform::unregisterResource(collectionResHandle);
+            auto iterator = collectionResourceHandleList.find(collectionResourceType);
+            if (iterator != collectionResourceHandleList.end())
+            {
+                collectionResourceHandleList.erase(iterator);
+            }
         }
-    }
 
-    if (groupSyncResHandle)
-    {
-        OCPlatform::unregisterResource(groupSyncResHandle);
-        auto iterator = groupSyncResourceHandleList.find(collectionResourceType);
-        if (iterator != groupSyncResourceHandleList.end())
+        if (groupSyncResHandle)
         {
-            groupSyncResourceHandleList.erase(iterator);
+            OCPlatform::unregisterResource(groupSyncResHandle);
+            auto iterator = groupSyncResourceHandleList.find(collectionResourceType);
+            if (iterator != groupSyncResourceHandleList.end())
+            {
+                groupSyncResourceHandleList.erase(iterator);
+            }
         }
-    }
 
-    return OC_STACK_NO_RESOURCE;
-}
+        return OC_STACK_NO_RESOURCE;
+    }
 
-OCStackResult GroupSynchronization::joinGroup(std::string collectionResourceType,
-        OCResourceHandle resourceHandle)
-{
-    if ((0 != collectionResourceType.length()) && (resourceHandle))
+    OCStackResult GroupSynchronization::joinGroup(std::string collectionResourceType,
+            OCResourceHandle resourceHandle)
     {
+        if ((0 == collectionResourceType.length()) || (!resourceHandle))
+        {
+            cout << "GroupSynchronization::joinGroup : Error! input params are wrong." << endl;
+            return OC_STACK_INVALID_PARAM;
+        }
         auto resIt = collectionResourceHandleList.find(collectionResourceType);
-        if (resIt == groupSyncResourceHandleList.end())
+        if (resIt == collectionResourceHandleList.end())
         {
             cout << "GroupSynchronization::joinGroup : error! There is no collection to join"
                     << endl;
@@ -210,21 +215,19 @@ OCStackResult GroupSynchronization::joinGroup(std::string collectionResourceType
         deviceResourceHandleList.push_back(resourceHandle);
 
         debugGroupSync();
-    }
-    else
-    {
-        cout << "GroupSynchronization::joinGroup : Error! input params are wrong." << endl;
-        return OC_STACK_INVALID_PARAM;
-    }
 
-    return OC_STACK_OK;
-}
+        return OC_STACK_OK;
+    }
 
-OCStackResult GroupSynchronization::joinGroup(const std::shared_ptr< OCResource > resource,
-        OCResourceHandle resourceHandle)
-{
-    if ((resource) && (resourceHandle))
+    OCStackResult GroupSynchronization::joinGroup(const std::shared_ptr< OCResource > resource,
+            OCResourceHandle resourceHandle)
     {
+        if ((!resource) || (!resourceHandle))
+        {
+            cout << "GroupSynchronization::joinGroup : Error! Input params are wrong." << endl;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         cout << "GroupSynchronization::joinGroup" << endl;
 
         // making representation to join group
@@ -291,23 +294,20 @@ OCStackResult GroupSynchronization::joinGroup(const std::shared_ptr< OCResource
 
         return OC_STACK_OK;
     }
-    else
-    {
-        cout << "GroupSynchronization::joinGroup : Error! Input params are wrong." << endl;
-        return OC_STACK_INVALID_PARAM;
-    }
-}
 
-OCStackResult GroupSynchronization::leaveGroup(std::string collectionResourceType,
-        OCResourceHandle resourceHandle)
-{
-    if ((0 != collectionResourceType.length()) && (resourceHandle))
+    OCStackResult GroupSynchronization::leaveGroup(std::string collectionResourceType,
+            OCResourceHandle resourceHandle)
     {
+        if ((0 == collectionResourceType.length()) || (!resourceHandle))
+        {
+            cout << "GroupSynchronization::leaveGroup : Error! Input params are wrong." << endl;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         cout << "GroupSynchronization::leaveGroup : collectionResourceType - "
                 << collectionResourceType << endl;
 
         OCResourceHandle collectionResHandle;
-
         auto handleIt = groupSyncResourceHandleList.find(collectionResourceType);
 
         // if groupSyncResourceHandleList has resourceType,
@@ -326,8 +326,7 @@ OCStackResult GroupSynchronization::leaveGroup(std::string collectionResourceTyp
 //            cout << "GroupSynchronization::leaveGroup : collection handle uri - "
 //                    << OCGetResourceUri(collectionResHandle) << endl;
 
-            OCStackResult result = OCPlatform::unbindResource(collectionResHandle,
-                    resourceHandle);
+            OCStackResult result = OCPlatform::unbindResource(collectionResHandle, resourceHandle);
             if (OC_STACK_OK == result)
             {
                 cout << "GroupSynchronization::leaveGroup : "
@@ -339,8 +338,8 @@ OCStackResult GroupSynchronization::leaveGroup(std::string collectionResourceTyp
                         << "To unbind resource was unsuccessful. result - " << result << endl;
             }
 
-            auto It = std::find(deviceResourceHandleList.begin(),
-                    deviceResourceHandleList.end(), resourceHandle);
+            auto It = std::find(deviceResourceHandleList.begin(), deviceResourceHandleList.end(),
+                    resourceHandle);
             if (It == deviceResourceHandleList.end()) // there is no resource handle to find
             {
                 result = OCPlatform::unregisterResource(resourceHandle);
@@ -438,32 +437,59 @@ OCStackResult GroupSynchronization::leaveGroup(std::string collectionResourceTyp
             else
             {
                 cout << "GroupSynchronization::leaveGroup : "
-                        << "groupSyncResource->put was unsuccessful. result - " << result
-                        << endl;
+                        << "groupSyncResource->put was unsuccessful. result - " << result << endl;
             }
 
             // deleting all remote resources. These are copied in onGetJoinedRemoteChild()
             deleteGroup(collectionResourceType);
         }
-    }
-    else
-    {
-        cout << "GroupSynchronization::leaveGroup : Error! Input params are wrong." << endl;
-        return OC_STACK_INVALID_PARAM;
-    }
 
-    return OC_STACK_OK;
-}
+        return OC_STACK_OK;
+    }
 
-void GroupSynchronization::deleteGroup(std::string collectionResourceType)
-{
-    if (0 != collectionResourceType.length())
+    void GroupSynchronization::deleteGroup(std::string collectionResourceType)
     {
+        if (0 == collectionResourceType.length())
+        {
+            cout << "GroupSynchronization::deleteGroup : Error! Input params are wrong." << endl;
+            return;
+        }
+
         cout << "GroupSynchronization::deleteGroup" << endl;
 
         OCStackResult result;
+        OCResourceHandle resourceHandle;
+
+        auto handleIt = groupSyncResourceHandleList.find(collectionResourceType);
+
+        // if groupSyncResourceHandleList has resourceType,
+        // group sync of this app created collection resource.
+        if (handleIt != groupSyncResourceHandleList.end())
+        {
+            resourceHandle = handleIt->second; // group sync resource handle
+            result = OCPlatform::unregisterResource(resourceHandle);
+            if (OC_STACK_OK == result)
+            {
+                cout << "GroupSynchronization::deleteGroup : "
+                        << "To unregister group sync resource handle was successful." << endl;
+            }
+            else
+            {
+                cout << "GroupSynchronization::deleteGroup : "
+                        << "To unregister group sync resource handle was unsuccessful. "
+                        << "result - " << result << endl;
+            }
 
-        auto handleIt = collectionResourceHandleList.find(collectionResourceType);
+            groupSyncResourceHandleList.erase(handleIt);
+        }
+
+        auto resourceIt = groupSyncResourceList.find(collectionResourceType);
+        if (resourceIt != groupSyncResourceList.end())
+        {
+            groupSyncResourceList.erase(resourceIt);
+        }
+
+        handleIt = collectionResourceHandleList.find(collectionResourceType);
         if (handleIt == collectionResourceHandleList.end())
         {
             cout << "GroupSynchronization::deleteGroup : "
@@ -478,9 +504,25 @@ void GroupSynchronization::deleteGroup(std::string collectionResourceType)
         if (handleListIt == childResourceHandleList.end())
         {
             cout << "GroupSynchronization::deleteGroup : "
-                    << "Error! There is no child resource list to delete." << endl;
+                    << "There is no child resource list to delete." << endl;
+
+            result = OCPlatform::unregisterResource(collectionResHandle);
+            if (result == OC_STACK_OK)
+            {
+                cout << "GroupSynchronization::deleteGroup : "
+                        << "To unregister collection resource handle was successful." << endl;
+            }
+            else
+            {
+                cout << "GroupSynchronization::deleteGroup : "
+                        << " To unregister collection resource handle was unsuccessful. result - "
+                        << result << endl;
+            }
+
+            debugGroupSync();
             return;
         }
+
         std::vector< OCResourceHandle > childList = handleListIt->second;
 
         childResourceHandleList.erase(handleListIt);
@@ -488,8 +530,8 @@ void GroupSynchronization::deleteGroup(std::string collectionResourceType)
         result = OCPlatform::unbindResources(collectionResHandle, childList);
         if (OC_STACK_OK == result)
         {
-            cout << "GroupSynchronization::deleteGroup : "
-                    << "To unbind resources was successful." << endl;
+            cout << "GroupSynchronization::deleteGroup : " << "To unbind resources was successful."
+                    << endl;
         }
         else
         {
@@ -498,7 +540,7 @@ void GroupSynchronization::deleteGroup(std::string collectionResourceType)
         }
 
         result = OCPlatform::unregisterResource(collectionResHandle);
-        if (result != OC_STACK_OK)
+        if (result == OC_STACK_OK)
         {
             cout << "GroupSynchronization::deleteGroup : "
                     << "To unregister collection resource handle was successful." << endl;
@@ -510,7 +552,6 @@ void GroupSynchronization::deleteGroup(std::string collectionResourceType)
                     << result << endl;
         }
 
-        OCResourceHandle resourceHandle;
         std::vector< OCResourceHandle >::iterator It;
 
         for (unsigned int i = 0; i < childList.size(); i++)
@@ -539,350 +580,318 @@ void GroupSynchronization::deleteGroup(std::string collectionResourceType)
             }
         }
 
-        handleIt = groupSyncResourceHandleList.find(collectionResourceType);
-
-        // if groupSyncResourceHandleList has resourceType,
-        // group sync of this app created collection resource.
-        if (handleIt != groupSyncResourceHandleList.end())
-        {
-            resourceHandle = handleIt->second; // group sync resource handle
-            result = OCPlatform::unregisterResource(resourceHandle);
-            if (OC_STACK_OK == result)
-            {
-                cout << "GroupSynchronization::deleteGroup : "
-                        << "To unregister group sync resource handle was successful." << endl;
-            }
-            else
-            {
-                cout << "GroupSynchronization::deleteGroup : "
-                        << "To unregister group sync resource handle was unsuccessful. "
-                        << "result - " << result << endl;
-            }
-
-            groupSyncResourceHandleList.erase(handleIt);
-        }
-
-        auto resourceIt = groupSyncResourceList.find(collectionResourceType);
-        if (resourceIt != groupSyncResourceList.end())
-        {
-            groupSyncResourceList.erase(resourceIt);
-        }
-
         debugGroupSync();
     }
-    else
+
+    std::map< std::string, OCResourceHandle > GroupSynchronization::getGroupList()
     {
-        cout << "GroupSynchronization::deleteGroup : Error! Input params are wrong." << endl;
+        return collectionResourceHandleList;
     }
-}
-
-std::map< std::string, OCResourceHandle > GroupSynchronization::getGroupList()
-{
-    return collectionResourceHandleList;
-}
 
-OCEntityHandlerResult GroupSynchronization::groupEntityHandler(
-        const std::shared_ptr< OCResourceRequest > request)
-{
-    cout << "GroupSynchronization::groupEntityHandler\n";
-
-    if (request)
+    OCEntityHandlerResult GroupSynchronization::groupEntityHandler(
+            const std::shared_ptr< OCResourceRequest > request)
     {
-        // Get the request type and request flag
-        std::string requestType = request->getRequestType();
-        int requestFlag = request->getRequestHandlerFlag();
+        cout << "GroupSynchronization::groupEntityHandler\n";
 
-        if (requestFlag == RequestHandlerFlag::InitFlag)
+        if (request)
         {
-            cout << "\trequestFlag : Init\n";
+            // Get the request type and request flag
+            std::string requestType = request->getRequestType();
+            int requestFlag = request->getRequestHandlerFlag();
 
-            // entity handler to perform resource initialization operations
-        }
-        else if (requestFlag == RequestHandlerFlag::RequestFlag)
-        {
-            cout << "\trequestFlag : Request\n";
-
-            // If the request type is GET
-            if (requestType == "GET")
+            if (requestFlag == RequestHandlerFlag::InitFlag)
             {
-                cout << "\t\trequestType : GET\n";
+                cout << "\trequestFlag : Init\n";
+
+                // entity handler to perform resource initialization operations
             }
-            else if (requestType == "PUT")
+            else if (requestFlag == RequestHandlerFlag::RequestFlag)
             {
-                cout << "\t\trequestType : PUT\n";
-
-                //get method name, group resource type and resource type to join group
-                OCRepresentation rp = request->getResourceRepresentation();
-                std::string methodType = rp.getValue< std::string >("method");
-                std::string collectionResourceType = rp.getValue< std::string >(
-                        "collectionResourceType");
-                std::string resourceType = rp.getValue< std::string >("resourceType");
+                cout << "\trequestFlag : Request\n";
 
-                cout << "\t\t\tmethod : " << methodType << endl;
-                cout << "\t\t\tcollection resourceType : " << collectionResourceType << endl;
-                cout << "\t\t\tresourceType : " << resourceType << endl;
-
-                auto handleIt = collectionResourceHandleList.find(collectionResourceType);
-                if (handleIt == collectionResourceHandleList.end())
+                // If the request type is GET
+                if (requestType == "GET")
                 {
-                    cout << "GroupSynchronization::groupEntityHandler : "
-                            << "Error! There is no collection resource handle to delete."
-                            << endl;
-                    return OC_EH_ERROR;
+                    cout << "\t\trequestType : GET\n";
                 }
-                collectionResourceHandle = handleIt->second;
-                // in case of join group it is used in onFindResource()
-
-                if (methodType == "joinGroup")
+                else if (requestType == "PUT")
                 {
-                    std::string resourceName = "coap://224.0.1.187/oc/core?rt=";
-                    resourceName += resourceType;
-                    cout << "\t\t\tresourceName : " << resourceName << endl;
+                    cout << "\t\trequestType : PUT\n";
 
-                    resourceRequest = request;
+                    //get method name, group resource type and resource type to join group
+                    OCRepresentation rp = request->getResourceRepresentation();
+                    std::string methodType = rp.getValue< std::string >("method");
+                    std::string collectionResourceType = rp.getValue< std::string >(
+                            "collectionResourceType");
+                    std::string resourceType = rp.getValue< std::string >("resourceType");
 
-                    OCPlatform::findResource("", resourceName,
-                            std::bind(&GroupSynchronization::onFindResource, this,
-                                    std::placeholders::_1));
-                }
-                else if (methodType == "leaveGroup")
-                {
-                    auto it = childResourceHandleList.find(collectionResourceHandle);
-                    if (it == childResourceHandleList.end())
+                    cout << "\t\t\tmethod : " << methodType << endl;
+                    cout << "\t\t\tcollection resourceType : " << collectionResourceType << endl;
+                    cout << "\t\t\tresourceType : " << resourceType << endl;
+
+                    auto handleIt = collectionResourceHandleList.find(collectionResourceType);
+                    if (handleIt == collectionResourceHandleList.end())
                     {
                         cout << "GroupSynchronization::groupEntityHandler : "
-                                << "Error! There is no child resource list." << endl;
+                                << "Error! There is no collection resource handle to delete."
+                                << endl;
                         return OC_EH_ERROR;
                     }
+                    collectionResourceHandle = handleIt->second;
+                    // in case of join group it is used in onFindResource()
 
-                    std::vector< OCResourceHandle > childList = it->second;
-                    OCResourceHandle resourceHandle;
-                    for (auto childIt = childList.begin(); childIt != childList.end();)
+                    if (methodType == "joinGroup")
                     {
-                        resourceHandle = (*childIt);
-                        char* type = (char*) OCGetResourceTypeName(resourceHandle, 0);
+                        std::string resourceName = "coap://224.0.1.187/oc/core?rt=";
+                        resourceName += resourceType;
+                        cout << "\t\t\tresourceName : " << resourceName << endl;
 
-                        if (0 == resourceType.compare(type))
+                        resourceRequest = request;
+
+                        OCPlatform::findResource("", resourceName,
+                                std::bind(&GroupSynchronization::onFindResource, this,
+                                        std::placeholders::_1));
+                    }
+                    else if (methodType == "leaveGroup")
+                    {
+                        auto it = childResourceHandleList.find(collectionResourceHandle);
+                        if (it == childResourceHandleList.end())
                         {
                             cout << "GroupSynchronization::groupEntityHandler : "
-                                    << "Found! The resource to leave is found. - " << type
-                                    << endl;
+                                    << "Error! There is no child resource list." << endl;
+                            return OC_EH_ERROR;
+                        }
 
-                            childIt = childList.erase(childIt++);
+                        std::vector< OCResourceHandle > childList = it->second;
+                        OCResourceHandle resourceHandle;
+                        for (auto childIt = childList.begin(); childIt != childList.end();)
+                        {
+                            resourceHandle = (*childIt);
+                            char* type = (char*) OCGetResourceTypeName(resourceHandle, 0);
 
-                            OCStackResult result = OCPlatform::unbindResource(
-                                    collectionResourceHandle, resourceHandle);
-                            if (OC_STACK_OK == result)
+                            if (0 == resourceType.compare(type))
                             {
                                 cout << "GroupSynchronization::groupEntityHandler : "
-                                        << "To unbind resource was successful." << endl;
-                            }
-                            else
-                            {
-                                cout << "GroupSynchronization::groupEntityHandler : "
-                                        << "To unbind resource was unsuccessful. result - "
-                                        << result << endl;
-                            }
+                                        << "Found! The resource to leave is found. - " << type
+                                        << endl;
+
+                                childIt = childList.erase(childIt++);
+
+                                OCStackResult result = OCPlatform::unbindResource(
+                                        collectionResourceHandle, resourceHandle);
+                                if (OC_STACK_OK == result)
+                                {
+                                    cout << "GroupSynchronization::groupEntityHandler : "
+                                            << "To unbind resource was successful." << endl;
+                                }
+                                else
+                                {
+                                    cout << "GroupSynchronization::groupEntityHandler : "
+                                            << "To unbind resource was unsuccessful. result - "
+                                            << result << endl;
+                                }
+
+                                result = OCPlatform::unregisterResource(resourceHandle);
+                                if (OC_STACK_OK == result)
+                                {
+                                    cout << "GroupSynchronization::groupEntityHandler : "
+                                            << "To unregister resource was successful." << endl;
+                                }
+                                else
+                                {
+                                    cout << "GroupSynchronization::groupEntityHandler : "
+                                            << "To unregister resource was unsuccessful. result - "
+                                            << result << endl;
+                                }
 
-                            result = OCPlatform::unregisterResource(resourceHandle);
-                            if (OC_STACK_OK == result)
-                            {
-                                cout << "GroupSynchronization::groupEntityHandler : "
-                                        << "To unregister resource was successful." << endl;
+//                            break;
                             }
                             else
                             {
-                                cout << "GroupSynchronization::groupEntityHandler : "
-                                        << "To unregister resource was unsuccessful. result - "
-                                        << result << endl;
+                                ++childIt;
                             }
 
-//                            break;
-                        }
-                        else
-                        {
-                            ++childIt;
                         }
 
-                    }
+                        childResourceHandleList[collectionResourceHandle] = childList;
 
-                    childResourceHandleList[collectionResourceHandle] = childList;
+                        debugGroupSync();
 
-                    debugGroupSync();
+                        auto pResponse = std::make_shared< OC::OCResourceResponse >();
+                        pResponse->setRequestHandle(request->getRequestHandle());
+                        pResponse->setResourceHandle(request->getResourceHandle());
+                        pResponse->setErrorCode(200);
+                        pResponse->setResponseResult(OC_EH_OK);
 
-                    auto pResponse = std::make_shared< OC::OCResourceResponse >();
-                    pResponse->setRequestHandle(request->getRequestHandle());
-                    pResponse->setResourceHandle(request->getResourceHandle());
-                    pResponse->setErrorCode(200);
-                    pResponse->setResponseResult(OC_EH_OK);
+                        OCRepresentation rep = request->getResourceRepresentation();
+                        pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
+                        if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                        {
+                            cout << "GroupSynchronization::groupEntityHandler : "
+                                    << "sendResponse is successful." << endl;
+                        }
+                    }
 
-                    OCRepresentation rep = request->getResourceRepresentation();
-                    pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
-                    if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+                    if (methodType != "") //TODO: Check groupmethodtype NULL
                     {
-                        cout << "GroupSynchronization::groupEntityHandler : "
-                                << "sendResponse is successful." << endl;
                     }
                 }
-
-                if (methodType != "") //TODO: Check groupmethodtype NULL
+                else if (requestType == "POST")
                 {
+                    // POST request operations
+                }
+                else if (requestType == "DELETE")
+                {
+                    // DELETE request operations
                 }
             }
-            else if (requestType == "POST")
-            {
-                // POST request operations
-            }
-            else if (requestType == "DELETE")
+            else if (requestFlag == RequestHandlerFlag::ObserverFlag)
             {
-                // DELETE request operations
+                cout << "\trequestFlag : Observer\n";
             }
         }
-        else if (requestFlag == RequestHandlerFlag::ObserverFlag)
+        else
         {
-            cout << "\trequestFlag : Observer\n";
+            std::cout << "Request invalid" << std::endl;
         }
+
+        return OC_EH_OK;
     }
-    else
+
+    void GroupSynchronization::onFindGroup(std::shared_ptr< OCResource > resource)
     {
-        std::cout << "Request invalid" << std::endl;
-    }
+        cout << "GroupSynchronization::onFindGroup" << endl;
 
-    return OC_EH_OK;
-}
+        try
+        {
+            if (resource)
+            {
+                // Debugging
+                std::string resourceURI;
+                std::string hostAddress;
 
-void GroupSynchronization::onFindGroup(std::shared_ptr< OCResource > resource)
-{
-    cout << "GroupSynchronization::onFindGroup" << endl;
+                // Get the resource URI
+                resourceURI = resource->uri();
+                cout << "\tURI of the resource: " << resourceURI << endl;
 
-    try
-    {
-        if (resource)
-        {
-//////////////////////////////////////////////////////////////////////////////////////////////////
-////////////debugging
-            std::string resourceURI;
-            std::string hostAddress;
+                // Get the resource host address
+                hostAddress = resource->host();
+                cout << "\tHost address of the resource: " << hostAddress << endl;
 
-            // Get the resource URI
-            resourceURI = resource->uri();
-            cout << "\tURI of the resource: " << resourceURI << endl;
+                hostAddress.append(resourceURI);
 
-            // Get the resource host address
-            hostAddress = resource->host();
-            cout << "\tHost address of the resource: " << hostAddress << endl;
+                // Get the resource types
+                cout << "\tList of resource types: " << endl;
 
-            hostAddress.append(resourceURI);
+                for (auto &resourceTypes : resource->getResourceTypes())
+                {
+                    cout << "\t\t" << resourceTypes << endl;
+                }
 
-            // Get the resource types
-            cout << "\tList of resource types: " << endl;
+                // Get the resource interfaces
+                cout << "\tList of resource interfaces: " << endl;
+                for (auto &resourceInterfaces : resource->getResourceInterfaces())
+                {
+                    cout << "\t\t" << resourceInterfaces << endl;
+                }
 
-            for (auto &resourceTypes : resource->getResourceTypes())
-            {
-                cout << "\t\t" << resourceTypes << endl;
+                if (false == IsSameGroup(resource))
+                {
+                    saveGroup(resource);
+                    findCallback(resource);
+                }
             }
-
-            // Get the resource interfaces
-            cout << "\tList of resource interfaces: " << endl;
-            for (auto &resourceInterfaces : resource->getResourceInterfaces())
+            else
             {
-                cout << "\t\t" << resourceInterfaces << endl;
+                // Resource is invalid
+                cout << "Resource is invalid" << endl;
+                findCallback(NULL);
             }
-//////////////////////////////////////////////////////////////////////////////////////////////////
 
-            if (false == IsSameGroup(resource))
-            {
-                saveGroup(resource);
-                findCallback(resource);
-            }
         }
-        else
+        catch (std::exception& e)
         {
-            // Resource is invalid
-            cout << "Resource is invalid" << endl;
-            findCallback(NULL);
+            //log(e.what());
         }
-
     }
-    catch (std::exception& e)
-    {
-        //log(e.what());
-    }
-}
 
-void GroupSynchronization::checkFindGroup(void)
-{
-    cout << "GroupSynchronization::checkFindGroup" << endl;
-
-    for (int i = 0; i < 15; i++)
+    void GroupSynchronization::checkFindGroup(void)
     {
-        std::chrono::milliseconds workTime(300);
-        std::this_thread::sleep_for(workTime);
-
-        std::lock_guard < std::mutex > guard(foundGroupMutex);
+        cout << "GroupSynchronization::checkFindGroup" << endl;
 
-        if (false == foundGroupResourceList.empty())
+        for (int i = 0; i < 15; i++)
         {
-            cout << "GroupSynchronization::checkFoundGroup : " << "Some group is received."
-                    << endl;
-            return;
-        }
-    }
+            std::chrono::milliseconds workTime(300);
+            std::this_thread::sleep_for(workTime);
 
-    cout << "GroupSynchronization::checkFoundGroup : "
-            << "It is failed to find resource within 3s." << endl;
+            std::lock_guard < std::mutex > guard(foundGroupMutex);
 
-    onFindGroup(NULL);
-    return;
-}
+            if (false == foundGroupResourceList.empty())
+            {
+                cout << "GroupSynchronization::checkFoundGroup : " << "Some group is received."
+                        << endl;
+                return;
+            }
+        }
 
-bool GroupSynchronization::IsSameGroup(std::shared_ptr< OCResource > resource)
-{
-    std::lock_guard < std::mutex > guard(foundGroupMutex);
+        cout << "GroupSynchronization::checkFoundGroup : "
+                << "It is failed to find resource within 3s." << endl;
 
-    if (true == foundGroupResourceList.empty())
-    {
-        cout << "GroupSynchronization::IsSameGroup : There is no found group." << endl;
-        return false;
+        onFindGroup(NULL);
+        return;
     }
 
-    std::string foundHostAddress, savedHostAddress;
-    foundHostAddress = resource->host();
+    bool GroupSynchronization::IsSameGroup(std::shared_ptr< OCResource > resource)
+    {
+        std::lock_guard < std::mutex > guard(foundGroupMutex);
+
+        if (true == foundGroupResourceList.empty())
+        {
+            cout << "GroupSynchronization::IsSameGroup : There is no found group." << endl;
+            return false;
+        }
+
+        std::string foundHostAddress, savedHostAddress;
+        foundHostAddress = resource->host();
 //    foundHostAddress.append (resource->uri());
 
-    for (unsigned int i = 0; i < foundGroupResourceList.size(); ++i)
-    {
-        savedHostAddress = (foundGroupResourceList.at(i))->host();
+        for (unsigned int i = 0; i < foundGroupResourceList.size(); ++i)
+        {
+            savedHostAddress = (foundGroupResourceList.at(i))->host();
 //        savedHostAddress.append ((foundGroupResourceList.at(i))->uri());
 //        cout << "GroupSynchronization::IsSameGroup : foundHostAddress - " << foundHostAddress
 //                << ", savedHostAddress - " << savedHostAddress << endl;
 
-        if (0 == foundHostAddress.compare(savedHostAddress.c_str()))
-        {
-            cout << "GroupSynchronization::IsSameGroup : Found! The same group is found."
-                    << endl;
-            return true;
+            if (0 == foundHostAddress.compare(savedHostAddress.c_str()))
+            {
+                cout << "GroupSynchronization::IsSameGroup : Found! The same group is found."
+                        << endl;
+                return true;
+            }
         }
-    }
 
-    cout << "GroupSynchronization::IsSameGroup :  There is no same group." << endl;
-    return false;
-}
+        cout << "GroupSynchronization::IsSameGroup :  There is no same group." << endl;
+        return false;
+    }
 
-void GroupSynchronization::saveGroup(std::shared_ptr< OCResource > resource)
-{
-    cout << "GroupSynchronization::saveGroup" << endl;
+    void GroupSynchronization::saveGroup(std::shared_ptr< OCResource > resource)
+    {
+        cout << "GroupSynchronization::saveGroup" << endl;
 
-    std::lock_guard < std::mutex > guard(foundGroupMutex);
+        std::lock_guard < std::mutex > guard(foundGroupMutex);
 
-    foundGroupResourceList.push_back(resource);
-}
+        foundGroupResourceList.push_back(resource);
+    }
 
-void GroupSynchronization::onJoinGroup(const HeaderOptions& headerOptions,
-        const OCRepresentation& rep, const int eCode)
-{
-    if (eCode == OC_STACK_OK)
+    void GroupSynchronization::onJoinGroup(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode)
     {
+        if (eCode != OC_STACK_OK)
+        {
+            cout << "GroupSynchronization::onJoinGroup : error - " << eCode << endl;
+            return;
+        }
+
         cout << "GroupSynchronization::onJoinGroup : " << endl;
 
         if (remoteCollectionResource)
@@ -893,8 +902,7 @@ void GroupSynchronization::onJoinGroup(const HeaderOptions& headerOptions,
             OCStackResult result = remoteCollectionResource->get("", resourceInterface,
                     queryParamsMap,
                     std::bind(&GroupSynchronization::onGetJoinedRemoteChild, this,
-                            std::placeholders::_1, std::placeholders::_2,
-                            std::placeholders::_3));
+                            std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
             if (OC_STACK_OK == result)
             {
                 cout << "GroupSynchronization::onJoinGroup : "
@@ -908,113 +916,111 @@ void GroupSynchronization::onJoinGroup(const HeaderOptions& headerOptions,
             }
         }
     }
-    else
-    {
-        cout << "GroupSynchronization::onJoinGroup : error - " << eCode << endl;
-    }
-}
-
-void GroupSynchronization::onFindResource(std::shared_ptr< OCResource > resource)
-{
-    cout << "GroupSynchronization::onFindResource" << endl;
 
-    if (resource)
+    void GroupSynchronization::onFindResource(std::shared_ptr< OCResource > resource)
     {
-//////////////////////////////////////////////////////////////////////////////////////////////////
-////////// debugging
-        std::string resourceURI;
-        std::string hostAddress;
+        cout << "GroupSynchronization::onFindResource" << endl;
 
-        // Get the resource URI
-        resourceURI = resource->uri();
-        cout << "\tURI of the resource: " << resourceURI << endl;
+        if (resource)
+        {
+            // start of debugging
+            std::string resourceURI;
+            std::string hostAddress;
+
+            // Get the resource URI
+            resourceURI = resource->uri();
+            cout << "\tURI of the resource: " << resourceURI << endl;
 
-        // Get the resource host address
-        hostAddress = resource->host();
-        cout << "\tHost address of the resource: " << hostAddress << endl;
+            // Get the resource host address
+            hostAddress = resource->host();
+            cout << "\tHost address of the resource: " << hostAddress << endl;
 
-        hostAddress.append(resourceURI);
+            hostAddress.append(resourceURI);
 
-        // Get the resource types
-        cout << "\tList of resource types: " << endl;
+            // Get the resource types
+            cout << "\tList of resource types: " << endl;
 
-        for (auto &resourceTypes : resource->getResourceTypes())
-        {
-            cout << "\t\t" << resourceTypes << endl;
-        }
+            for (auto &resourceTypes : resource->getResourceTypes())
+            {
+                cout << "\t\t" << resourceTypes << endl;
+            }
 
-        // Get the resource interfaces
-        cout << "\tList of resource interfaces: " << endl;
-        for (auto &resourceInterfaces : resource->getResourceInterfaces())
-        {
-            cout << "\t\t" << resourceInterfaces << endl;
-        }
-//////////////////////////////////////////////////////////////////////////////////////////////////
+            // Get the resource interfaces
+            cout << "\tList of resource interfaces: " << endl;
+            for (auto &resourceInterfaces : resource->getResourceInterfaces())
+            {
+                cout << "\t\t" << resourceInterfaces << endl;
+            }
+            // end of debugging
 
-        OCResourceHandle resourceHandle;
-        OCStackResult result = OCPlatform::registerResource(resourceHandle, resource);
-        if (result != OC_STACK_OK)
-        {
-            cout << "GroupSynchronization::"
-                    << "onFindResource - Resource to join creation was unsuccessful. result - "
-                    << result << endl;
-            return;
-        }
+            OCResourceHandle resourceHandle;
+            OCStackResult result = OCPlatform::registerResource(resourceHandle, resource);
+            if (result != OC_STACK_OK)
+            {
+                cout << "GroupSynchronization::"
+                        << "onFindResource - Resource to join creation was unsuccessful. result - "
+                        << result << endl;
+                return;
+            }
 //        cout << "GroupSynchronization::onFindResource : creating resourceHandle. resource type - "
 //                << OCGetResourceTypeName(resourceHandle, 0) << endl;
 
-        result = OCPlatform::bindResource(collectionResourceHandle, resourceHandle);
-        if (result != OC_STACK_OK)
-        {
+            result = OCPlatform::bindResource(collectionResourceHandle, resourceHandle);
+            if (result != OC_STACK_OK)
+            {
+                cout << "GroupSynchronization::onFindResource : "
+                        << "To bind resource was unsuccessful. result - " << result << endl;
+                return;
+            }
+
             cout << "GroupSynchronization::onFindResource : "
-                    << "To bind resource was unsuccessful. result - " << result << endl;
-            return;
-        }
-        cout << "GroupSynchronization::onFindResource : "
-                << "To bind joinGroupHandle and resourceHandle was successful." << endl;
+                    << "To bind joinGroupHandle and resourceHandle was successful." << endl;
 
-        auto it = childResourceHandleList.find(collectionResourceHandle);
-        std::vector< OCResourceHandle > childHandleList;
-        if (it != childResourceHandleList.end())
-        {
-            childHandleList = it->second;
-        }
+            auto it = childResourceHandleList.find(collectionResourceHandle);
+            std::vector< OCResourceHandle > childHandleList;
+            if (it != childResourceHandleList.end())
+            {
+                childHandleList = it->second;
+            }
 
-        childHandleList.push_back(resourceHandle);
-        childResourceHandleList[collectionResourceHandle] = childHandleList;
+            childHandleList.push_back(resourceHandle);
+            childResourceHandleList[collectionResourceHandle] = childHandleList;
 
-        auto pResponse = std::make_shared< OC::OCResourceResponse >();
-        pResponse->setRequestHandle(resourceRequest->getRequestHandle());
-        pResponse->setResourceHandle(resourceRequest->getResourceHandle());
-        pResponse->setErrorCode(200);
-        pResponse->setResponseResult(OC_EH_OK);
+            auto pResponse = std::make_shared< OC::OCResourceResponse >();
+            pResponse->setRequestHandle(resourceRequest->getRequestHandle());
+            pResponse->setResourceHandle(resourceRequest->getResourceHandle());
+            pResponse->setErrorCode(200);
+            pResponse->setResponseResult(OC_EH_OK);
 
-        OCRepresentation rep = resourceRequest->getResourceRepresentation();
-        pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
-        if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+            OCRepresentation rep = resourceRequest->getResourceRepresentation();
+            pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
+            if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
+            {
+                cout << "GroupSynchronization::onFindResource : sendResponse is successful."
+                        << endl;
+            }
+        }
+        else
         {
-            cout << "GroupSynchronization::onFindResource : sendResponse is successful."
-                    << endl;
+            cout << "GroupSynchronization::onFindResource : "
+                    << "Resource is invalid. So a new Group Resource has to be created." << endl;
         }
-    }
-    else
-    {
-        cout << "GroupSynchronization::onFindResource : "
-                << "Resource is invalid. So a new Group Resource has to be created." << endl;
-    }
 
-    debugGroupSync();
-}
+        debugGroupSync();
+    }
 
-void GroupSynchronization::onGetJoinedRemoteChild(const HeaderOptions& headerOptions,
-        const OCRepresentation& rep, const int eCode)
-{
-    if (eCode == OC_STACK_OK)
+    void GroupSynchronization::onGetJoinedRemoteChild(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode)
     {
+        if (eCode != OC_STACK_OK)
+        {
+            cout << "GroupSynchronization::onGetJoinedRemoteChild : error - " << eCode << endl;
+            return;
+        }
+
         cout << "GroupSynchronization::onGetJoinedRemoteChild" << endl;
 
-//////////////////////////////////////////////////////////////////////////////////////////////////
-////////// debugging
+        // debugging
         std::string resourceURI;
 
         // Get the resource URI
@@ -1058,14 +1064,12 @@ void GroupSynchronization::onGetJoinedRemoteChild(const HeaderOptions& headerOpt
                 cout << "\t\t\t" << interfaces << endl;
             }
         }
-//////////////////////////////////////////////////////////////////////////////////////////////////
 
         // creating remote collection resource handle
         OCResourceHandle remoteCollectionResourceHandle;
         resourceURI = remoteCollectionResource->uri();
         std::vector< std::string > types = remoteCollectionResource->getResourceTypes();
-        std::vector< std::string > interfaces =
-                remoteCollectionResource->getResourceInterfaces();
+        std::vector< std::string > interfaces = remoteCollectionResource->getResourceInterfaces();
 
         OCStackResult result = OCPlatform::registerResource(remoteCollectionResourceHandle,
                 resourceURI, types[0], interfaces[0], NULL, OC_OBSERVABLE);
@@ -1086,8 +1090,7 @@ void GroupSynchronization::onGetJoinedRemoteChild(const HeaderOptions& headerOpt
         if (OC_STACK_OK == result)
         {
             cout << "GroupSynchronization::onGetJoinedRemoteChild : "
-                    << "binding remoteCollectionResourceHandle and deviceResourceHandle"
-                    << endl;
+                    << "binding remoteCollectionResourceHandle and deviceResourceHandle" << endl;
         }
         else
         {
@@ -1122,8 +1125,7 @@ void GroupSynchronization::onGetJoinedRemoteChild(const HeaderOptions& headerOpt
                     interfaces[0], NULL, OC_OBSERVABLE);
             if (OC_STACK_OK == result)
             {
-                result = OCPlatform::bindResource(remoteCollectionResourceHandle,
-                        resourceHandle);
+                result = OCPlatform::bindResource(remoteCollectionResourceHandle, resourceHandle);
                 if (result != OC_STACK_OK)
                 {
                     cout << "GroupSynchronization::onGetJoinedRemoteChild - "
@@ -1146,132 +1148,126 @@ void GroupSynchronization::onGetJoinedRemoteChild(const HeaderOptions& headerOpt
 
         childResourceHandleList[remoteCollectionResourceHandle] = childHandleList;
         // this handle list is used to leave group
-    }
-    else
-    {
-        cout << "GroupSynchronization::onGetJoinedRemoteChild : error - " << eCode << endl;
-    }
 
-    debugGroupSync();
-}
+        debugGroupSync();
+    }
 
-void GroupSynchronization::onLeaveGroup(const HeaderOptions& headerOptions,
-        const OCRepresentation& rep, const int eCode)
-{
-    if (eCode == OC_STACK_OK)
+    void GroupSynchronization::onLeaveGroup(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode)
     {
+        if (eCode != OC_STACK_OK)
+        {
+            cout << "GroupSynchronization::onLeaveGroup : error - " << eCode << endl;
+            return;
+        }
+
         cout << "GroupSynchronization::onLeaveGroup" << endl;
+        debugGroupSync();
     }
-    else
-    {
-        cout << "GroupSynchronization::onLeaveGroup : error - " << eCode << endl;
-    }
-    debugGroupSync();
-}
 
-void GroupSynchronization::debugGroupSync(void)
-{
-    cout << "GroupSynchronization::debugGroupSync" << endl;
-
-    unsigned int i;
-    std::map< std::string, OCResourceHandle >::iterator handleIt;
-    std::map< OCResourceHandle, std::vector< OCResourceHandle > >::iterator childIt;
-    std::string type;
-    OCResourceHandle resourceHandle;
-    std::vector< OCResourceHandle > handleList;
-    std::shared_ptr< OCResource > resource;
-
-    cout << "Resource Handle Created by App" << endl;
-    for (i = 0; i < deviceResourceHandleList.size(); i++)
+    void GroupSynchronization::debugGroupSync(void)
     {
-        resourceHandle = deviceResourceHandleList.at(i);
+        cout << "GroupSynchronization::debugGroupSync" << endl;
 
-        cout << i + 1 << ". details" << endl;
-        cout << "  uri - " << OCGetResourceUri(resourceHandle) << endl;
-        cout << "  resource type - " << OCGetResourceTypeName(resourceHandle, 0) << endl;
-        cout << "  resource interface - " << OCGetResourceInterfaceName(resourceHandle, 0)
-                << endl << endl;
-    }
+        unsigned int i;
+        std::map< std::string, OCResourceHandle >::iterator handleIt;
+        std::map< OCResourceHandle, std::vector< OCResourceHandle > >::iterator childIt;
+        std::string type;
+        OCResourceHandle resourceHandle;
+        std::vector< OCResourceHandle > handleList;
+        std::shared_ptr< OCResource > resource;
 
-    cout << "\nGroup Sync Resource Handle List. The number is "
-            << groupSyncResourceHandleList.size() << endl;
-    i = 1;
-    for (handleIt = groupSyncResourceHandleList.begin();
-            handleIt != groupSyncResourceHandleList.end(); ++handleIt)
-    {
-        type = handleIt->first;
-        cout << "\t" << i << ". group sync resource type - " << type << endl;
-        cout << "\t  details" << endl;
-
-        resourceHandle = handleIt->second;
-        cout << "\t  uri - " << OCGetResourceUri(resourceHandle) << endl;
-        cout << "\t  resource type - " << OCGetResourceTypeName(resourceHandle, 0) << endl;
-        cout << "\t  resource interface - " << OCGetResourceInterfaceName(resourceHandle, 0)
-                << endl << endl;
-        ;
-        i++;
-    }
+        cout << "Resource Handle Created by App" << endl;
+        for (i = 0; i < deviceResourceHandleList.size(); i++)
+        {
+            resourceHandle = deviceResourceHandleList.at(i);
 
-    cout << "Copied Remote Group Sync Resource List. The number is "
-            << groupSyncResourceList.size() << endl;
-    std::vector< std::string > list;
-    i = 1;
-    for (auto resourceIt = groupSyncResourceList.begin();
-            resourceIt != groupSyncResourceList.end(); ++resourceIt)
-    {
-        type = resourceIt->first;
-        cout << "\t" << i << ". group sync resource type - " << type << endl;
-        cout << "\t details" << endl;
-
-        resource = resourceIt->second;
-        cout << "\t  host - " << resource->host() << endl;
-        cout << "\t  uri - " << resource->uri() << endl;
-        list = resource->getResourceTypes();
-        cout << "\t  resource type - " << list[0] << endl;
-        list = resource->getResourceInterfaces();
-        cout << "\t  resource interface - " << list[0] << endl << endl;
-        i++;
-    }
+            cout << i + 1 << ". details" << endl;
+            cout << "  uri - " << OCGetResourceUri(resourceHandle) << endl;
+            cout << "  resource type - " << OCGetResourceTypeName(resourceHandle, 0) << endl;
+            cout << "  resource interface - " << OCGetResourceInterfaceName(resourceHandle, 0)
+                    << endl << endl;
+        }
+
+        cout << "\nGroup Sync Resource Handle List. The number is "
+                << groupSyncResourceHandleList.size() << endl;
+        i = 1;
+        for (handleIt = groupSyncResourceHandleList.begin();
+                handleIt != groupSyncResourceHandleList.end(); ++handleIt)
+        {
+            type = handleIt->first;
+            cout << "\t" << i << ". group sync resource type - " << type << endl;
+            cout << "\t  details" << endl;
+
+            resourceHandle = handleIt->second;
+            cout << "\t  uri - " << OCGetResourceUri(resourceHandle) << endl;
+            cout << "\t  resource type - " << OCGetResourceTypeName(resourceHandle, 0) << endl;
+            cout << "\t  resource interface - " << OCGetResourceInterfaceName(resourceHandle, 0)
+                    << endl << endl;
+            ;
+            i++;
+        }
+
+        cout << "Copied Remote Group Sync Resource List. The number is "
+                << groupSyncResourceList.size() << endl;
+        std::vector< std::string > list;
+        i = 1;
+        for (auto resourceIt = groupSyncResourceList.begin();
+                resourceIt != groupSyncResourceList.end(); ++resourceIt)
+        {
+            type = resourceIt->first;
+            cout << "\t" << i << ". group sync resource type - " << type << endl;
+            cout << "\t details" << endl;
+
+            resource = resourceIt->second;
+            cout << "\t  host - " << resource->host() << endl;
+            cout << "\t  uri - " << resource->uri() << endl;
+            list = resource->getResourceTypes();
+            cout << "\t  resource type - " << list[0] << endl;
+            list = resource->getResourceInterfaces();
+            cout << "\t  resource interface - " << list[0] << endl << endl;
+            i++;
+        }
 
 //    cout << "The number of collection Resource Handle is " << collectionResourceHandleList.size()
 //            << endl;
 //    cout << "The number of child resource handle list is " << childResourceHandleList.size()
 //            << endl;
 
-    cout << "Collection Resource Handle List" << endl;
-    i = 1;
-    for (handleIt = collectionResourceHandleList.begin();
-            handleIt != collectionResourceHandleList.end(); ++handleIt)
-    {
-        type = handleIt->first;
-        cout << "\t" << i << ". collection resource type - " << type << endl;
-        cout << "\t  details" << endl;
-
-        resourceHandle = handleIt->second;
-        cout << "\t  uri - " << OCGetResourceUri(resourceHandle) << endl;
-        cout << "\t  resource type - " << OCGetResourceTypeName(resourceHandle, 0) << endl;
-        cout << "\t  resource interface - " << OCGetResourceInterfaceName(resourceHandle, 0)
-                << endl << endl;
-
-        childIt = childResourceHandleList.find(resourceHandle);
-        if (childIt != childResourceHandleList.end())
+        cout << "Collection Resource Handle List" << endl;
+        i = 1;
+        for (handleIt = collectionResourceHandleList.begin();
+                handleIt != collectionResourceHandleList.end(); ++handleIt)
         {
-            handleList = childIt->second;
-            for (unsigned int j = 0; j < handleList.size(); j++)
+            type = handleIt->first;
+            cout << "\t" << i << ". collection resource type - " << type << endl;
+            cout << "\t  details" << endl;
+
+            resourceHandle = handleIt->second;
+            cout << "\t  uri - " << OCGetResourceUri(resourceHandle) << endl;
+            cout << "\t  resource type - " << OCGetResourceTypeName(resourceHandle, 0) << endl;
+            cout << "\t  resource interface - " << OCGetResourceInterfaceName(resourceHandle, 0)
+                    << endl << endl;
+
+            childIt = childResourceHandleList.find(resourceHandle);
+            if (childIt != childResourceHandleList.end())
             {
+                handleList = childIt->second;
+                for (unsigned int j = 0; j < handleList.size(); j++)
+                {
 
-                cout << "\t\t" << j + 1 << ". child resource details" << endl;
+                    cout << "\t\t" << j + 1 << ". child resource details" << endl;
 
-                resourceHandle = handleList.at(j);
-                cout << "\t\t  uri - " << OCGetResourceUri(resourceHandle) << endl;
-                cout << "\t\t  resource type - " << OCGetResourceTypeName(resourceHandle, 0)
-                        << endl;
-                cout << "\t\t  resource interface - "
-                        << OCGetResourceInterfaceName(resourceHandle, 0) << endl << endl;
+                    resourceHandle = handleList.at(j);
+                    cout << "\t\t  uri - " << OCGetResourceUri(resourceHandle) << endl;
+                    cout << "\t\t  resource type - " << OCGetResourceTypeName(resourceHandle, 0)
+                            << endl;
+                    cout << "\t\t  resource interface - "
+                            << OCGetResourceInterfaceName(resourceHandle, 0) << endl << endl;
+                }
             }
-        }
 
-        i++;
+            i++;
+        }
     }
 }
-}