// OCClient.cpp : Defines the entry point for the console application.
//
+#include "iotivity_config.h"
+
#include <set>
#include <string>
#include <cstdlib>
-#include <pthread.h>
#include <mutex>
#include <condition_variable>
#include "OCPlatform.h"
#include "OCApi.h"
+#if defined(HAVE_PTHREAD_H)
+#include <pthread.h>
+#endif
+#if defined(HAVE_WINDOWS_H)
+#include <windows.h>
+#endif
+
using namespace OC;
struct dereference_compare
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)
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);
}
}
-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;
}
}
-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;
}
// 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)
+ if(eCode == SUCCESS_RESPONSE || eCode == OC_STACK_RESOURCE_CHANGED)
{
std::cout << "PUT request was successful" << std::endl;
}
// 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)
{
std::cout << " ObserveType : 1 - Observe" << std::endl;
std::cout << " ObserveType : 2 - ObserveAll" << std::endl;
std::cout << " ConnectivityType: Default IP" << std::endl;
- std::cout << " ConnectivityType : 0 - IPv4"<< std::endl;
- std::cout << " ConnectivityType : 0 - IPv6 (Current Not Supported )"<< std::endl;
+ std::cout << " ConnectivityType : 0 - IP"<< std::endl;
}
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
{
return -1;
}
}
- catch(std::exception& e)
+ catch(std::exception&)
{
std::cout << "Invalid input argument." << std::endl;
PrintUsage();