return ++oc;
}
-void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
+void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& rep,
const int& eCode, const int& sequenceNumber)
{
try
{
- if(eCode == OC_STACK_OK)
+ if(eCode == OC_STACK_OK && sequenceNumber != OC_OBSERVE_NO_OPTION)
{
+ if(sequenceNumber == OC_OBSERVE_REGISTER)
+ {
+ std::cout << "Observe registration action is successful" << std::endl;
+ }
+ else if(sequenceNumber == OC_OBSERVE_DEREGISTER)
+ {
+ std::cout << "Observe De-registration action is successful" << std::endl;
+ }
+
std::cout << "OBSERVE RESULT:"<<std::endl;
std::cout << "\tSequenceNumber: "<< sequenceNumber << std::endl;
rep.getValue("state", mylight.m_state);
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();
}
else
{
- std::cout << "onObserve Response error: " << eCode << std::endl;
- std::exit(-1);
+ if(sequenceNumber == OC_OBSERVE_NO_OPTION)
+ {
+ std::cout << "Observe registration or de-registration action is failed" << std::endl;
+ }
+ else
+ {
+ std::cout << "onObserve Response error: " << eCode << std::endl;
+ std::exit(-1);
+ }
}
}
catch(std::exception& e)
}
-void onPost2(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPost2(const HeaderOptions& /*headerOptions*/,
+ const OCRepresentation& rep, const int eCode)
{
try
{
}
-void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
+void onPost(const HeaderOptions& /*headerOptions*/,
+ const OCRepresentation& rep, const int eCode)
{
try
{
}
// 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)
{
try
{
}
// 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)
{
try
{
}
}
-static FILE* client_open(const char *path, const char *mode)
+static FILE* client_open(const char* /*path*/, const char *mode)
{
return fopen("./oic_svr_db_client.json", mode);
}