Update snapshot(2017-12-14)
[platform/upstream/iotivity.git] / resource / examples / groupclient.cpp
index cd8d6f6..cde8eb2 100644 (file)
@@ -88,7 +88,7 @@ void foundResource(std::shared_ptr< OCResource > resource)
     }
 }
 
-void onGet(const HeaderOptions& opt, const OCRepresentation &rep, const int eCode)
+void onGet(const HeaderOptions& /*opt*/, const OCRepresentation &rep, const int /*eCode*/)
 {
     // printf("onGet\n");
 
@@ -105,12 +105,14 @@ void onGet(const HeaderOptions& opt, const OCRepresentation &rep, const int eCod
     cv.notify_one();
 }
 
-void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPut(const HeaderOptions& /*headerOptions*/,
+        const OCRepresentation& /*rep*/, const int /*eCode*/)
 {
     printf("\nonPut\n");
 }
 
-void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPost(const HeaderOptions& /*headerOptions*/,
+        const OCRepresentation& rep, const int /*eCode*/)
 {
     printf("\nonPost\n");
 
@@ -168,53 +170,10 @@ bool isResourceReady()
     return isReady;
 }
 
-int main(int argc, char* argv[])
+int main(int /*argc*/, char** /*argv[]*/)
 {
     ostringstream requestURI;
-    requestURI << OC_MULTICAST_DISCOVERY_URI << "?rt=a.collection";
-
-    OCConnectivityType connectivityType = OC_WIFI;
-
-    if(argc == 2)
-    {
-        try
-        {
-            std::size_t inputValLen;
-            int optionSelected = stoi(argv[1], &inputValLen);
-
-            if(inputValLen == strlen(argv[1]))
-            {
-                if(optionSelected == 0)
-                {
-                    connectivityType = OC_ETHERNET;
-                }
-                else if(optionSelected == 1)
-                {
-                    connectivityType = OC_WIFI;
-                }
-                else
-                {
-                    std::cout << "Invalid connectivity type selected. Using default WIFI"
-                        << std::endl;
-                }
-            }
-            else
-            {
-                std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
-            }
-        }
-        catch(exception&)
-        {
-            std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
-        }
-    }
-    else
-    {
-        std::cout<<"Usage: groupclient <ConnectivityType(0|1)>\n";
-        std::cout<<"ConnectivityType: Default WIFI\n";
-        std::cout<<"ConnectivityType 0: ETHERNET\n";
-        std::cout<<"ConnectivityType 1: WIFI\n";
-    }
+    requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=a.collection";
 
     PlatformConfig config
     { OC::ServiceType::InProc, ModeType::Client, "0.0.0.0", 0, OC::QualityOfService::LowQos };
@@ -228,7 +187,7 @@ int main(int argc, char* argv[])
         string resourceTypeName = "a.collection";
 
         OCPlatform::findResource("", requestURI.str(),
-                                 OC_ALL, &foundResource);
+                                 CT_DEFAULT, &foundResource);
 
         //Non-intensive block until foundResource callback is called by OCPlatform
         //and onGet gets resource.
@@ -295,7 +254,6 @@ int main(int argc, char* argv[])
                     cout << "Invalid option" << endl;
                     break;
             }
-            fflush(stdin);
         }
     }
     catch (OCException& e)