Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / resource / examples / simpleclientHQ.cpp
index e4d2f0b..a1377c7 100644 (file)
@@ -67,7 +67,7 @@ int observe_count()
     return ++oc;
 }
 
-void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
+void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& rep,
                     const int& eCode, const int& sequenceNumber)
 {
     if(eCode == SUCCESS_RESPONSE)
@@ -97,7 +97,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
         std::cout << "\tpower: " << mylight.m_power << std::endl;
         std::cout << "\tname: " << mylight.m_name << std::endl;
 
-        if(observe_count() > 10)
+        if(observe_count() == 11)
         {
             std::cout<<"Cancelling Observe..."<<std::endl;
             OCStackResult result = curResource->cancelObserve(OC::QualityOfService::HighQos);
@@ -112,9 +112,9 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
     }
 }
 
-void onPost2(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPost2(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
 {
-    if(eCode == SUCCESS_RESPONSE)
+    if(eCode == SUCCESS_RESPONSE || eCode == OC_STACK_RESOURCE_CHANGED)
     {
         std::cout << "POST request was successful" << std::endl;
 
@@ -150,9 +150,10 @@ void onPost2(const HeaderOptions& headerOptions, const OCRepresentation& rep, co
     }
 }
 
-void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPost(const HeaderOptions& /*headerOptions*/,
+        const OCRepresentation& rep, const int eCode)
 {
-    if(eCode == SUCCESS_RESPONSE)
+    if(eCode == SUCCESS_RESPONSE || eCode == OC_STACK_RESOURCE_CHANGED)
     {
         std::cout << "POST request was successful" << std::endl;
 
@@ -212,7 +213,7 @@ void postLightRepresentation(std::shared_ptr<OCResource> resource)
 }
 
 // callback handler on PUT request
-void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
 {
     if(eCode == SUCCESS_RESPONSE)
     {
@@ -256,7 +257,7 @@ void putLightRepresentation(std::shared_ptr<OCResource> resource)
 }
 
 // Callback handler on GET request
-void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
 {
     if(eCode == SUCCESS_RESPONSE)
     {
@@ -429,7 +430,7 @@ int main(int argc, char* argv[]) {
             return -1;
         }
     }
-    catch(std::exception& e)
+    catch(std::exception&)
     {
         std::cout << "Invalid input argument." << std::endl;
         PrintUsage();