#include <pthread.h>
#include <mutex>
#include <condition_variable>
-
+#include <getopt.h>
#include "OCPlatform.h"
#include "OCApi.h"
std::shared_ptr<OCResource> curResource;
std::mutex resourceLock;
-
static int TEST_CASE = 0;
-static OCConnectivityType connectivityType = OC_WIFI;
+static OCConnectivityType connectivityType = CT_ADAPTER_IP;
/**
* List of methods that can be inititated from the client
std::cout << "-t 2 : Discover Resources and Initiate Unicast Presence with Filter"
<< std::endl;
std::cout << "-t 3 : Discover Resources and Initiate Unicast Presence with Two Filters"
- << std::endl;
+ << std::endl;
std::cout << "-t 4 : Discover Resources and Initiate Multicast Presence" << std::endl;
std::cout << "-t 5 : Discover Resources and Initiate Multicast Presence with Filter"
<< std::endl;
std::cout << "-t 6 : Discover Resources and Initiate Multicast Presence with two Filters"
- << std::endl;
- std::cout<<"ConnectivityType: Default WIFI" << std::endl;
- std::cout << "-c 0 : Send message over ETHERNET interface" << std::endl;
- std::cout << "-c 1 : Send message over WIFI interface" << std::endl;
+ << std::endl;
+ std::cout<<"ConnectivityType: Default IP" << std::endl;
+ std::cout << "-c 0 : Send message with IP" << std::endl;
}
// Callback to presence
}
catch(std::exception& e)
{
+ std::cerr << "Exception in foundResource: "<< e.what() << std::endl;
//log(e.what());
}
}
{
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::cout << "Invalid connectivity type selected. Using default IP"
<< std::endl;
}
}
else
{
- std::cout << "Invalid connectivity type selected. Using default WIFI"
+ std::cout << "Invalid connectivity type selected. Using default IP"
<< std::endl;
}
break;
}
}
}
- catch(std::exception& e)
+ catch(std::exception& )
{
- std::cout << "Invalid input argument. Using WIFI as connectivity type"
+ std::cout << "Invalid input argument. Using IP as connectivity type"
<< std::endl;
}
if(TEST_CASE == TEST_MULTICAST_PRESENCE_NORMAL)
{
result = OCPlatform::subscribePresence(presenceHandle,
- OC_MULTICAST_IP, connectivityType, presenceHandler);
+ "",
+ connectivityType,
+ presenceHandler);
if(result == OC_STACK_OK)
{
}
else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTER)
{
- result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
- connectivityType, &presenceHandler);
+ result = OCPlatform::subscribePresence(presenceHandle,
+ "", "core.light",
+ connectivityType,
+ &presenceHandler);
if(result == OC_STACK_OK)
{
std::cout << "Subscribed to multicast presence with resource type";
}
else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTERS)
{
- result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
- connectivityType, &presenceHandler);
+ result = OCPlatform::subscribePresence(presenceHandle,
+ "", "core.light",
+ connectivityType,
+ &presenceHandler);
if(result == OC_STACK_OK)
{
std::cout << "Subscribed to multicast presence with resource type";
}
std::cout << "\"core.light\"." << std::endl;
- result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.fan",
- connectivityType, &presenceHandler);
+ result = OCPlatform::subscribePresence(presenceHandle,
+ "", "core.fan",
+ connectivityType,
+ &presenceHandler);
if(result == OC_STACK_OK)
{
std::cout<< "Subscribed to multicast presence with resource type";
else
{
// Find all resources
- requestURI << OC_WELL_KNOWN_QUERY;
+ requestURI << OC_RSRVD_WELL_KNOWN_URI;
result = OCPlatform::findResource("", requestURI.str(),
- connectivityType, &foundResource);
+ CT_DEFAULT, &foundResource);
if(result == OC_STACK_OK)
{
std::cout << "Finding Resource... " << std::endl;