replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / examples / presenceclient.cpp
index ff39bfb..72b672a 100644 (file)
@@ -25,7 +25,7 @@
 #include <pthread.h>
 #include <mutex>
 #include <condition_variable>
-
+#include <getopt.h>
 #include "OCPlatform.h"
 #include "OCApi.h"
 
@@ -63,9 +63,8 @@ void printUsage()
               << std::endl;
     std::cout << "-t 6 : Discover Resources and Initiate Multicast Presence with two Filters"
             << std::endl;
-    std::cout<<"ConnectivityType: Default IPv4" << std::endl;
-    std::cout << "-c 0 : Send message with IPv4" << std::endl;
-    std::cout << "-c 1 : Send message with IPv6 (Currently Not Supported)" << std::endl;
+    std::cout<<"ConnectivityType: Default IP" << std::endl;
+    std::cout << "-c 0 : Send message with IP" << std::endl;
 }
 
 // Callback to presence
@@ -221,16 +220,8 @@ int main(int argc, char* argv[]) {
                     {
                         if(optionSelected == 0)
                         {
-                            std::cout << "Using IPv4."<< std::endl;
-                            connectivityType = CT_IP_USE_V4;
-                        }
-                        else if(optionSelected == 1)
-                        {
-                            std::cout << "IPv6 is currently not supported."<< std::endl;
-                            printUsage();
-                            return -1;
-                            //TODO: printUsage to be removed when IPv6 is available.
-                            //connectivityType = CT_IP_USE_V6;
+                            std::cout << "Using IP."<< std::endl;
+                            connectivityType = CT_ADAPTER_IP;
                         }
                         else
                         {
@@ -280,13 +271,12 @@ int main(int argc, char* argv[]) {
         OCPlatform::OCPresenceHandle presenceHandle = nullptr;
         OCStackResult result = OC_STACK_OK;
 
-        std::ostringstream multicastPresenceURI;
-        multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX;
-
         if(TEST_CASE == TEST_MULTICAST_PRESENCE_NORMAL)
         {
             result = OCPlatform::subscribePresence(presenceHandle,
-                    multicastPresenceURI.str(), connectivityType, presenceHandler);
+                                                   "",
+                                                   connectivityType,
+                                                   presenceHandler);
 
             if(result == OC_STACK_OK)
             {
@@ -299,8 +289,10 @@ int main(int argc, char* argv[]) {
         }
         else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTER)
         {
-            result = OCPlatform::subscribePresence(presenceHandle, multicastPresenceURI.str(), "core.light",
-                    connectivityType, &presenceHandler);
+            result = OCPlatform::subscribePresence(presenceHandle,
+                                                   "", "core.light",
+                                                   connectivityType,
+                                                   &presenceHandler);
             if(result == OC_STACK_OK)
             {
                 std::cout << "Subscribed to multicast presence with resource type";
@@ -313,8 +305,10 @@ int main(int argc, char* argv[]) {
         }
         else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTERS)
         {
-            result = OCPlatform::subscribePresence(presenceHandle, multicastPresenceURI.str(), "core.light",
-                    connectivityType, &presenceHandler);
+            result = OCPlatform::subscribePresence(presenceHandle,
+                                                   "", "core.light",
+                                                   connectivityType,
+                                                   &presenceHandler);
             if(result == OC_STACK_OK)
             {
                 std::cout << "Subscribed to multicast presence with resource type";
@@ -325,8 +319,10 @@ int main(int argc, char* argv[]) {
             }
             std::cout << "\"core.light\"." << std::endl;
 
-            result = OCPlatform::subscribePresence(presenceHandle, multicastPresenceURI.str(), "core.fan",
-                    connectivityType, &presenceHandler);
+            result = OCPlatform::subscribePresence(presenceHandle,
+                                                   "", "core.fan",
+                                                   connectivityType,
+                                                   &presenceHandler);
             if(result == OC_STACK_OK)
             {
                 std::cout<< "Subscribed to multicast presence with resource type";