"have choice" error of libmbedtls.so
[platform/upstream/iotivity.git] / resource / examples / simpleclientserver.cpp
index 25019a4..2c8f0ac 100644 (file)
 #include "OCApi.h"
 using namespace OC;
 
+static void printUsage()
+{
+    std::cout<< "    Usage simpleclientserver <0|1>" << std::endl;
+    std::cout<< "    ConnectivityType: Default IP" << std::endl;
+    std::cout << "   ConnectivityType : 0 - IP" << std::endl;
+}
 
 class ClientWorker
 {
 private:
-    void putResourceInfo(const HeaderOptions& headerOptions,
-            const OCRepresentation rep, const OCRepresentation rep2, const int eCode)
+    void putResourceInfo(const HeaderOptions& /*headerOptions*/,
+            const OCRepresentation rep, const OCRepresentation /*rep2*/, const int eCode)
     {
        std::cout << "In PutResourceInfo" << std::endl;
 
        std::cout <<"Clientside Put response to get was: "<<std::endl;
        std::cout <<"ErrorCode: "<<eCode <<std::endl;
 
-       if(eCode == 0)
+       if(eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CHANGED)
        {
             std::cout<<"Successful Put.  Attributes sent were: "<<std::endl;
 
@@ -67,7 +73,7 @@ private:
        }
     }
 
-    void getResourceInfo(const HeaderOptions& headerOptions, const OCRepresentation rep,
+    void getResourceInfo(const HeaderOptions& /*headerOptions*/, const OCRepresentation rep,
                 const int eCode)
     {
         std::cout << "In getResourceInfo" << std::endl;
@@ -147,12 +153,12 @@ public:
     void start()
     {
         std::ostringstream requestURI;
-        requestURI << OC_MULTICAST_DISCOVERY_URI << "?rt=core.foo";
+        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.foo";
 
         std::cout<<"Starting Client find:"<<std::endl;
         FindCallback f (std::bind(&ClientWorker::foundResource, this, std::placeholders::_1));
         std::cout<<"result:" <<
-        OCPlatform::findResource("", requestURI.str(), OC_ALL, f)
+        OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, f)
         << std::endl;
 
         std::cout<<"Finding Resource..."<<std::endl;
@@ -278,11 +284,7 @@ struct FooResource
             {
                 std::cout <<"\t\trequestFlag : UNSUPPORTED: ";
 
-                if(request->getRequestHandlerFlag()==RequestHandlerFlag::InitFlag)
-                {
-                    std::cout<<"InitFlag"<<std::endl;
-                }
-                else if(request->getRequestHandlerFlag()== RequestHandlerFlag::ObserverFlag)
+                if(request->getRequestHandlerFlag()== RequestHandlerFlag::ObserverFlag)
                 {
                     std::cout<<"ObserverFlag"<<std::endl;
                 }
@@ -300,7 +302,7 @@ struct FooResource
 
 int main(int argc, char* argv[])
 {
-    OCConnectivityType connectivityType = OC_WIFI;
+    OCConnectivityType connectivityType = CT_ADAPTER_IP;
 
     if(argc == 2)
     {
@@ -313,34 +315,27 @@ int main(int argc, char* argv[])
             {
                 if(optionSelected == 0)
                 {
-                    connectivityType = OC_ETHERNET;
-                }
-                else if(optionSelected == 1)
-                {
-                    connectivityType = OC_WIFI;
+                    std::cout << "Using IP."<< std::endl;
+                    connectivityType = CT_ADAPTER_IP;
                 }
                 else
                 {
-                    std::cout << "Invalid connectivity type selected. Using default WIFI"
-                    << std::endl;
+                    std::cout << "Invalid connectivity type selected. Using default IP" << std::endl;
                 }
             }
             else
             {
-                std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
+                std::cout << "Invalid connectivity type selected. Using default IP" << std::endl;
             }
         }
         catch(std::exception& )
         {
-            std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
+            std::cout << "Invalid input argument. Using IP as connectivity type" << std::endl;
         }
     }
     else
     {
-        std::cout<< "Usage simpleclientserver <ConnectivityType(0|1)>" << std::endl;
-        std::cout<<"    ConnectivityType: Default WIFI" << std::endl;
-        std::cout << "   ConnectivityType : 0 - ETHERNET" << std::endl;
-        std::cout << "   ConnectivityType : 1 - WIFI" << std::endl;
+        printUsage();
     }
 
     PlatformConfig cfg {