OC_STACK_KEEP_TRANSACTION
} OCStackApplicationResult;
+#ifdef CA_INT
+typedef enum {
+ OC_ETHERNET = (1 << 0),
+ OC_WIFI = (1 << 1),
+ OC_EDR = (1 << 2),
+ OC_LE = (1 << 3)
+} OCConnectivityType;
+#endif
+
//-----------------------------------------------------------------------------
// Callback function definitions
//-----------------------------------------------------------------------------
* OC_STACK_INVALID_QUERY - number of resource types specified for filtering presence
* notifications exceeds @ref MAX_PRESENCE_FILTERS.
*/
-OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri, const char *referenceUri,
- const char *request, OCQualityOfService qos, OCCallbackData *cbData, OCHeaderOption * options,
+#ifdef CA_INT
+OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri,
+ const char *referenceUri, const char *request, uint8_t conType,
+ OCQualityOfService qos, OCCallbackData *cbData, OCHeaderOption * options,
uint8_t numOptions);
+#else
+OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri,
+ const char *referenceUri, const char *request, OCQualityOfService qos,
+ OCCallbackData *cbData, OCHeaderOption * options, uint8_t numOptions);
+#endif
/**
* Cancel a request associated with a specific @ref OCDoResource invocation.
* OC_STACK_INVALID_METHOD - invalid resource method
* OC_STACK_INVALID_URI - invalid required or reference URI
*/
-
+#ifdef CA_INT
+OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri,
+ const char *referenceUri, const char *request, uint8_t conType,
+ OCQualityOfService qos, OCCallbackData *cbData,
+ OCHeaderOption * options, uint8_t numOptions)
+#else
OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requiredUri,
const char *referenceUri, const char *request,
OCQualityOfService qos, OCCallbackData *cbData,
OCHeaderOption * options, uint8_t numOptions)
+#endif
{
OCStackResult result = OC_STACK_ERROR;
OCCoAPToken token;
OCPlatform::Configure(cfg);
try
{
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::getDeviceInfo("", "coap://224.0.1.187/oc/core/d", connectivityType,
+ &receivedDeviceInfo);
+#else
OCPlatform::getDeviceInfo("", "coap://224.0.1.187/oc/core/d", &receivedDeviceInfo);
+#endif
std::cout<< "Querying for device information... " <<std::endl;
// A condition variable will free the mutex it is given, then do a non-
{
std::cout << "Fridge Client has started " <<std::endl;
FindCallback f (std::bind(&ClientFridge::foundDevice, this, PH::_1));
-
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCStackResult result = OCPlatform::findResource(
+ "", "coap://224.0.1.187/oc/core?rt=intel.fridge", connectivityType, f);
+#else
OCStackResult result = OCPlatform::findResource(
"", "coap://224.0.1.187/oc/core?rt=intel.fridge", f);
+#endif
if(OC_STACK_OK != result)
{
// server, and query them.
std::vector<std::string> lightTypes = {"intel.fridge.light"};
std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCResource::Ptr light = constructResourceObject(resource->host(),
+ "/light", connectivityType, false, lightTypes, ifaces);
+#else
OCResource::Ptr light = constructResourceObject(resource->host(),
"/light", false, lightTypes, ifaces);
+#endif
if(!light)
{
}
std::vector<std::string> doorTypes = {"intel.fridge.door"};
-
+#ifdef CA_INT
+ OCResource::Ptr leftdoor = constructResourceObject(resource->host(),
+ "/door/left", connectivityType, false, doorTypes, ifaces);
+#else
OCResource::Ptr leftdoor = constructResourceObject(resource->host(),
"/door/left", false, doorTypes, ifaces);
+#endif
+
if(!leftdoor)
{
std::cout << "Error: Left Door Resource Object construction returned null\n";
return;
}
+#ifdef CA_INT
+ OCResource::Ptr rightdoor = constructResourceObject(resource->host(),
+ "/door/right", connectivityType, false, doorTypes, ifaces);
+#else
OCResource::Ptr rightdoor = constructResourceObject(resource->host(),
"/door/right", false, doorTypes, ifaces);
+#endif
+
if(!rightdoor)
{
std::cout << "Error: Right Door Resource Object construction returned null\n";
return;
}
+#ifdef CA_INT
+ OCResource::Ptr randomdoor = constructResourceObject(resource->host(),
+ "/door/random", connectivityType, false, doorTypes, ifaces);
+#else
OCResource::Ptr randomdoor = constructResourceObject(resource->host(),
"/door/random", false, doorTypes, ifaces);
+#endif
if(!randomdoor)
{
std::cout << "Error: Random Door Resource Object construction returned null\n";
try
{
// Find all resources
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.garage",
+ connectivityType, &foundResource);
+#else
OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.garage",
&foundResource);
+#endif
std::cout<< "Finding Resource... " <<std::endl;
// A condition variable will free the mutex it is given, then do a non-
OCPlatform::Configure(config);
string resourceTypeName = "a.collection";
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=a.collection",
+ connectivityType, &foundResource);
+#else
OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=a.collection", &foundResource);
+#endif
isReady = false;
cout << "registerResource is called." << endl;
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light",
+ connectivityType, &foundResource);
+#else
OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light", &foundResource);
+#endif
+
OCPlatform::bindInterfaceToResource(resourceHandle, GROUP_INTERFACE);
OCPlatform::bindInterfaceToResource(resourceHandle, DEFAULT_INTERFACE);
#CXX := clang
OUT_DIR := $(BUILD)
-CXX_FLAGS.debug := -O0 -g3 -std=c++0x -Wall -pthread
+#TODO-CA Remove the CA Flag later
+CXX_FLAGS.debug := -O0 -g3 -std=c++0x -Wall -pthread -DCA_INT
-CXX_FLAGS.release := -O3 -std=c++0x -Wall -pthread
+CXX_FLAGS.release := -O3 -std=c++0x -Wall -pthread -DCA_INT
CXX_INC := -I../include/
CXX_INC += -I../oc_logger/include
devicediscoveryclient: devicediscoveryclient.cpp
$(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ devicediscoveryclient.cpp $(CXX_INC) $(CXX_LIBS)
-
-
+
+
ocicuc_target:
cd ocicuc && $(MAKE) apps
OCStackResult result = OC_STACK_OK;
curResource = resource;
OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+#endif
if(TEST_CASE == TEST_UNICAST_PRESENCE_NORMAL)
{
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
+ connectivityType, &presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
&presenceHandler);
+#endif
if(result == OC_STACK_OK)
{
std::cout<< "Subscribed to unicast address: " << hostAddress << std::endl;
if(TEST_CASE == TEST_UNICAST_PRESENCE_WITH_FILTER ||
TEST_CASE == TEST_UNICAST_PRESENCE_WITH_FILTERS)
{
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
+ "core.light", connectivityType, &presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
"core.light", &presenceHandler);
+#endif
if(result == OC_STACK_OK)
{
std::cout<< "Subscribed to unicast address: " << hostAddress;
}
if(TEST_CASE == TEST_UNICAST_PRESENCE_WITH_FILTERS)
{
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle, hostAddress, "core.fan",
+ connectivityType, &presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle, hostAddress, "core.fan",
&presenceHandler);
+#endif
if(result == OC_STACK_OK)
{
std::cout<< "Subscribed to unicast address: " << hostAddress;
OCPlatform::OCPresenceHandle presenceHandle = nullptr;
OCStackResult result = OC_STACK_OK;
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+#endif
if(TEST_CASE == TEST_MULTICAST_PRESENCE_NORMAL)
{
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle,
+ OC_MULTICAST_IP, connectivityType, presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle,
OC_MULTICAST_IP, presenceHandler);
+#endif
+
if(result == OC_STACK_OK)
{
std::cout << "Subscribed to multicast presence." << std::endl;
}
else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTER)
{
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
+ connectivityType, &presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
&presenceHandler);
+#endif
if(result == OC_STACK_OK)
{
std::cout << "Subscribed to multicast presence with resource type";
}
else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTERS)
{
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
+ connectivityType, &presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
&presenceHandler);
+#endif
if(result == OC_STACK_OK)
{
std::cout << "Subscribed to multicast presence with resource type";
}
std::cout << "\"core.light\"." << std::endl;
+#ifdef CA_INT
+ result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.fan",
+ connectivityType, &presenceHandler);
+#else
result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.fan",
&presenceHandler);
+#endif
if(result == OC_STACK_OK)
{
std::cout<< "Subscribed to multicast presence with resource type";
else
{
// Find all resources
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ result = OCPlatform::findResource("", "coap://224.0.1.187/oc/core",
+ connectivityType, &foundResource);
+#else
result = OCPlatform::findResource("", "coap://224.0.1.187/oc/core", &foundResource);
+#endif
if(result == OC_STACK_OK)
{
std::cout << "Finding Resource... " << std::endl;
try
{
// Find all resources
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core", connectivityType,
+ &foundResource);
+#else
OCPlatform::findResource("", "coap://224.0.1.187/oc/core", &foundResource);
+#endif
+
std::cout<< "Finding Resource... " <<std::endl;
// A condition variable will free the mutex it is given, then do a non-
// makes it so that all boolean values are printed as 'true/false' in this stream
std::cout.setf(std::ios::boolalpha);
// Find all resources
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light",
+ connectivityType, &foundResource);
+#else
OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light", &foundResource);
+#endif
std::cout<< "Finding Resource... " <<std::endl;
// A condition variable will free the mutex it is given, then do a non-
try
{
// Find all resources
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light",
+ connectivityType, &foundResource, OC::QualityOfService::LowQos);
+#else
OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.light", &foundResource,
OC::QualityOfService::LowQos);
+#endif
std::cout<< "Finding Resource... " <<std::endl;
// A condition variable will free the mutex it is given, then do a non-
{
std::cout<<"Starting Client find:"<<std::endl;
FindCallback f (std::bind(&ClientWorker::foundResource, this, std::placeholders::_1));
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
std::cout<<"result:" <<
- OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.foo", f)
- << std::endl;
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.foo", connectivityType, f)
+ << std::endl;
+#else
+ std::cout<<"result:" <<
+ OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.foo", f)
+ << std::endl;
+#endif
+
std::cout<<"Finding Resource..."<<std::endl;
{
void client1()
{
std::cout << "in client1\n";
-
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ std::cout<<"result1:" << OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.foo",
+ connectivityType, foundResource1)<< std::endl;
+#else
std::cout<<"result1:" << OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.foo",
foundResource1)<< std::endl;
+#endif
// A condition variable will free the mutex it is given, then do a non-
// intensive block until 'notify' is called on it. In this case, since we
void client2()
{
std::cout << "in client2\n";
-
+#ifdef CA_INT
+ OCConnectivityType connectivityType = OC_WIFI;
+ std::cout<<"result2:" << OCPlatform::findResource("",
+ "coap://224.0.1.187/oc/core?rt=core.foo",
+ connectivityType, foundResource2)<< std::endl;
+#else
std::cout<<"result2:" << OCPlatform::findResource("",
"coap://224.0.1.187/oc/core?rt=core.foo",
foundResource2)<< std::endl;
+#endif
// A condition variable will free the mutex it is given, then do a non-
// intensive block until 'notify' is called on it. In this case, since we
IClientWrapper()
{}
+#ifdef CA_INT
+ virtual OCStackResult ListenForResource(const std::string& serviceUrl,
+ const std::string& resourceType, uint8_t connectivityType,
+ FindCallback& callback,
+ QualityOfService QoS) = 0;
+
+ virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
+ const std::string& deviceURI, uint8_t connectivityType,
+ FindDeviceCallback& callback,
+ QualityOfService QoS) = 0;
+
+ virtual OCStackResult GetResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType,
+ const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions,
+ GetCallback& callback, QualityOfService QoS)=0;
+
+ virtual OCStackResult PutResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType,
+ const OCRepresentation& rep, const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions,
+ PutCallback& callback, QualityOfService QoS) = 0;
+
+ virtual OCStackResult PostResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType,
+ const OCRepresentation& rep, const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions,
+ PostCallback& callback, QualityOfService QoS) = 0;
+
+ virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
+ uint8_t connectivityType, const HeaderOptions& headerOptions,
+ DeleteCallback& callback, QualityOfService QoS) = 0;
+
+ virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
+ const std::string& host, const std::string& uri, uint8_t connectivityType,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ ObserveCallback& callback, QualityOfService QoS)=0;
+#else
virtual OCStackResult ListenForResource(const std::string& serviceUrl,
const std::string& resourceType, FindCallback& callback,
QualityOfService QoS) = 0;
const std::string& host, const std::string& uri,
const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
ObserveCallback& callback, QualityOfService QoS)=0;
-
+#endif
virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
const std::string& uri, const HeaderOptions& headerOptions, QualityOfService QoS)=0;
+#ifdef CA_INT
+ virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
+ const std::string& resourceType, uint8_t connectivityType,
+ SubscribeCallback& presenceHandler)=0;
+#else
virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
const std::string& resourceType, SubscribeCallback& presenceHandler)=0;
-
+#endif
virtual OCStackResult UnsubscribePresence(OCDoHandle handle) =0;
virtual OCStackResult GetDefaultQos(QualityOfService& qos) = 0;
PlatformConfig cfg);
virtual ~InProcClientWrapper();
+#ifdef CA_INT
+ virtual OCStackResult ListenForResource(const std::string& serviceUrl,
+ const std::string& resourceType, uint8_t connectivityType, FindCallback& callback,
+ QualityOfService QoS);
+
+ virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
+ const std::string& deviceURI, uint8_t connectivityType, FindDeviceCallback& callback,
+ QualityOfService QoS);
+
+ virtual OCStackResult GetResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions,
+ GetCallback& callback, QualityOfService QoS);
+
+ virtual OCStackResult PutResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const OCRepresentation& attributes,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ PutCallback& callback, QualityOfService QoS);
+
+ virtual OCStackResult PostResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const OCRepresentation& attributes,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ PostCallback& callback, QualityOfService QoS);
+
+ virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
+ uint8_t connectivityType, const HeaderOptions& headerOptions,
+ DeleteCallback& callback, QualityOfService QoS);
+
+ virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
+ const std::string& host, const std::string& uri, uint8_t connectivityType,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ ObserveCallback& callback, QualityOfService QoS);
+#else
virtual OCStackResult ListenForResource(const std::string& serviceUrl,
const std::string& resourceType, FindCallback& callback,
QualityOfService QoS);
virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
const HeaderOptions& headerOptions, ObserveCallback& callback, QualityOfService QoS);
-
+#endif
virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
const std::string& uri, const HeaderOptions& headerOptions, QualityOfService QoS);
+#ifdef CA_INT
+ virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
+ const std::string& resourceType, uint8_t connectivityType,
+ SubscribeCallback& presenceHandler);
+#else
virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
const std::string& resourceType, SubscribeCallback& presenceHandler);
+#endif
virtual OCStackResult UnsubscribePresence(OCDoHandle handle);
OCStackResult GetDefaultQos(QualityOfService& QoS);
* as BTH etc.
* NOTE: OCStackResult is defined in ocstack.h.
*/
+#ifdef CA_INT
+ OCStackResult findResource(const std::string& host, const std::string& resourceURI,
+ uint8_t connectivityType, FindCallback resourceHandler);
+ OCStackResult findResource(const std::string& host, const std::string& resourceURI,
+ uint8_t connectivityType, FindCallback resourceHandler, QualityOfService QoS);
+#else
OCStackResult findResource(const std::string& host, const std::string& resourceURI,
FindCallback resourceHandler);
OCStackResult findResource(const std::string& host, const std::string& resourceURI,
FindCallback resourceHandler, QualityOfService QoS);
-
+#endif
/**
* API for Device Discovery
*
* @param QualityOfService the quality of communication
*
*/
+#ifdef CA_INT
+ OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
+ uint8_t connectivityType, FindDeviceCallback deviceInfoHandler);
+ OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
+ uint8_t connectivityType, FindDeviceCallback deviceInfoHandler,
+ QualityOfService QoS);
+#else
OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
FindDeviceCallback deviceInfoHandler);
OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
FindDeviceCallback deviceInfoHandler, QualityOfService QoS);
-
+#endif
/**
* This API registers a resource with the server
* NOTE: This API applies to server side only.
*
* @return OCStackResult - return value of the API. Returns OCSTACK_OK if success <br>
*/
+#ifdef CA_INT
+ OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
+ uint8_t connectivityType, SubscribeCallback presenceHandler);
+ OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
+ const std::string& resourceType, uint8_t connectivityType,
+ SubscribeCallback presenceHandler);
+#else
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
SubscribeCallback presenceHandler);
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
const std::string& resourceType, SubscribeCallback presenceHandler);
-
+#endif
/**
* unsubscribes from a previously subscribed server's presence events. Note that
* you may for a short time still receive events from the server since it may take time
* @param interfaces - a collection of interfaces that the resource supports/implements
* @return OCResource::Ptr - a shared pointer to the new resource object
*/
+#ifdef CA_INT
+ OCResource::Ptr constructResourceObject(const std::string& host, const std::string& uri,
+ uint8_t connectivityType, bool isObservable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces);
+#else
OCResource::Ptr constructResourceObject(const std::string& host, const std::string& uri,
bool isObservable, const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces);
-
+#endif
/**
* Allows application entity handler to send response to an incoming request.
*
* as BTH etc.
* NOTE: OCStackResult is defined in ocstack.h.
*/
+#ifdef CA_INT
+ OCStackResult findResource(const std::string& host, const std::string& resourceURI,
+ uint8_t connectivityType, FindCallback resourceHandler);
+ OCStackResult findResource(const std::string& host, const std::string& resourceURI,
+ uint8_t connectivityType, FindCallback resourceHandler, QualityOfService QoS);
+#else
OCStackResult findResource(const std::string& host, const std::string& resourceURI,
FindCallback resourceHandler);
OCStackResult findResource(const std::string& host, const std::string& resourceURI,
FindCallback resourceHandler, QualityOfService QoS);
-
+#endif
/**
* API for Device Discovery
*
* @param QualityOfService the quality of communication
*
*/
+#ifdef CA_INT
+ OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
+ uint8_t connectivityType, FindDeviceCallback deviceInfoHandler);
+ OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
+ uint8_t connectivityType, FindDeviceCallback deviceInfoHandler,
+ QualityOfService QoS);
+#else
OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
FindDeviceCallback deviceInfoHandler);
OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
FindDeviceCallback deviceInfoHandler, QualityOfService QoS);
-
+#endif
/**
* This API registers a resource with the server
* NOTE: This API applies to server side only.
*
* @return OCStackResult - return value of the API. Returns OCSTACK_OK if success <br>
*/
+#ifdef CA_INT
+ OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
+ uint8_t connectivityType, SubscribeCallback presenceHandler);
+ OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
+ const std::string& resourceType, uint8_t connectivityType,
+ SubscribeCallback presenceHandler);
+#else
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
SubscribeCallback presenceHandler);
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
const std::string& resourceType, SubscribeCallback presenceHandler);
-
+#endif
/**
* unsubscribes from a previously subscribed server's presence events. Note that
* you may for a short time still receive events from the server since it may take time
* @param interfaces - a collection of interfaces that the resource supports/implements
* @return OCResource::Ptr - a shared pointer to the new resource object
*/
+#ifdef CA_INT
+ OCResource::Ptr constructResourceObject(const std::string& host, const std::string& uri,
+ uint8_t connectivityType, bool isObservable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces);
+#else
OCResource::Ptr constructResourceObject(const std::string& host, const std::string& uri,
bool isObservable, const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces);
-
+#endif
/**
* Allows application entity handler to send response to an incoming request.
*
*/
std::string uri() const;
+#ifdef CA_INT
+ /**
+ * Function to get the connectivity type of this resource
+ * @return uint8_t connectivity type
+ */
+ uint8_t connectivityType() const;
+#endif
+
/**
* Function to provide ability to check if this resource is observable or not
* @return bool true indicates resource is observable; false indicates resource is
std::weak_ptr<IClientWrapper> m_clientWrapper;
std::string m_uri;
std::string m_host;
+#ifdef CA_INT
+ uint8_t m_connectivityType;
+#endif
bool m_isObservable;
bool m_isCollection;
std::vector<std::string> m_resourceTypes;
HeaderOptions m_headerOptions;
private:
+#ifdef CA_INT
+ OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::string& host,
+ const std::string& uri, uint8_t m_connectivityType, bool observable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces);
+#else
OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::string& host,
- const std::string& uri, bool observable, const std::vector<std::string>& resourceTypes,
+ const std::string& uri, bool observable,
+ const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces);
+#endif
};
} // namespace OC
{
if(res.loaded())
{
+#ifdef CA_INT
+ //CA_TODO: To get the connectivity type correctly.
+ uint8_t connectivityType;
+ m_resources.push_back(std::shared_ptr<OCResource>(
+ new OCResource(m_clientWrapper,
+ ConvertOCAddrToString(res.secureType(),res.port()),
+ res.m_uri, connectivityType, res.observable(), res.resourceTypes(),
+ res.interfaces())));
+#else
m_resources.push_back(std::shared_ptr<OCResource>(
new OCResource(m_clientWrapper,
ConvertOCAddrToString(res.secureType(),res.port()),
res.m_uri, res.observable(), res.resourceTypes(),
res.interfaces())));
+#endif
}
}
PlatformConfig cfg)
{}
+#ifdef CA_INT
+ virtual OCStackResult ListenForResource(const std::string& serviceUrl,
+ const std::string& resourceType, uint8_t connectivityType,
+ FindCallback& callback, QualityOfService QoS)
+ {return OC_STACK_NOTIMPL;}
+
+ virtual OCStackResult ListenForDevice(const std::string& serviceUrl,
+ const std::string& deviceURI, uint8_t connectivityType, FindDeviceCallback& callback,
+ QualityOfService QoS)
+ {return OC_STACK_NOTIMPL;}
+
+ virtual OCStackResult GetResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions, GetCallback& callback,
+ QualityOfService QoS)
+ {return OC_STACK_NOTIMPL;}
+
+ virtual OCStackResult PutResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const OCRepresentation& attributes,
+ const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions, PutCallback& callback,
+ QualityOfService QoS)
+ {return OC_STACK_NOTIMPL;}
+
+ virtual OCStackResult PostResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const OCRepresentation& attributes,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ PostCallback& callback, QualityOfService QoS)
+ {return OC_STACK_NOTIMPL;}
+
+ virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
+ uint8_t connectivityType, const HeaderOptions& headerOptions, DeleteCallback& callback,
+ QualityOfService QoS) {return OC_STACK_NOTIMPL;}
+
+ virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
+ const std::string& host, const std::string& uri, uint8_t connectivityType,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ ObserveCallback& callback, QualityOfService QoS){return OC_STACK_NOTIMPL;}
+#else
virtual OCStackResult ListenForResource(const std::string& serviceUrl,
const std::string& resourceType, FindCallback& callback, QualityOfService QoS)
{return OC_STACK_NOTIMPL;}
const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
const HeaderOptions& headerOptions,
ObserveCallback& callback, QualityOfService QoS){return OC_STACK_NOTIMPL;}
-
+#endif
virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
const std::string& uri,
const HeaderOptions& headerOptions, QualityOfService QoS){return OC_STACK_NOTIMPL;}
-
+#ifdef CA_INT
+ virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
+ const std::string& resourceType, uint8_t connectivityType,
+ SubscribeCallback& presenceHandler)
+ {return OC_STACK_NOTIMPL;}
+#else
virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
const std::string& resourceType, SubscribeCallback& presenceHandler)
{return OC_STACK_NOTIMPL;}
-
+#endif
virtual OCStackResult UnsubscribePresence(OCDoHandle handle){return OC_STACK_NOTIMPL;}
virtual OCStackResult GetDefaultQos(QualityOfService& QoS){return OC_STACK_NOTIMPL;}
OUT_DIR := $(ROOT_DIR)/$(BUILD)
OBJ_DIR := $(OUT_DIR)/obj
-CXX_FLAGS.debug := -g3 -std=c++0x -Wall -pthread -O0
-CXX_FLAGS.release := -std=c++0x -Wall -pthread -O3
+#TODO-CA Need to remove flag later
+CXX_FLAGS.debug := -g3 -std=c++0x -Wall -pthread -O0 -DCA_INT
+CXX_FLAGS.release := -std=c++0x -Wall -pthread -O3 -DCA_INT
CXX_INC := -I./include/
CXX_INC += -I./oc_logger/include
return OC_STACK_KEEP_TRANSACTION;
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::ListenForResource(const std::string& serviceUrl,
+ const std::string& resourceType, uint8_t connectivityType,
+ FindCallback& callback, QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::ListenForResource(const std::string& serviceUrl,
const std::string& resourceType, FindCallback& callback, QualityOfService QoS)
+#endif
{
OCStackResult result;
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
OCDoHandle handle;
+#ifdef CA_INT
+ result = OCDoResource(&handle, OC_REST_GET,
+ resourceType.c_str(),
+ nullptr, nullptr, connectivityType,
+ static_cast<OCQualityOfService>(QoS),
+ &cbdata,
+ NULL, 0);
+#else
result = OCDoResource(&handle, OC_REST_GET,
resourceType.c_str(),
nullptr, nullptr,
static_cast<OCQualityOfService>(QoS),
&cbdata,
NULL, 0);
+#endif
}
else
{
return OC_STACK_KEEP_TRANSACTION;
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::ListenForDevice(const std::string& serviceUrl,
+ const std::string& deviceURI, uint8_t connectivityType,
+ FindDeviceCallback& callback, QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::ListenForDevice(const std::string& serviceUrl,
const std::string& deviceURI, FindDeviceCallback& callback, QualityOfService QoS)
+#endif
{
OCStackResult result;
{
std::lock_guard<std::recursive_mutex> lock(*cLock);
OCDoHandle handle;
+#ifdef CA_INT
+ result = OCDoResource(&handle, OC_REST_GET,
+ deviceURI.c_str(),
+ nullptr, nullptr, connectivityType,
+ static_cast<OCQualityOfService>(QoS),
+ &cbdata,
+ NULL, 0);
+#else
result = OCDoResource(&handle, OC_REST_GET,
deviceURI.c_str(),
nullptr, nullptr,
static_cast<OCQualityOfService>(QoS),
&cbdata,
NULL, 0);
+#endif
}
else
{
return OC_STACK_DELETE_TRANSACTION;
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::GetResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const QueryParamsMap& queryParams,
+ const HeaderOptions& headerOptions, GetCallback& callback,
+ QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::GetResourceRepresentation(const std::string& host,
const std::string& uri, const QueryParamsMap& queryParams,
const HeaderOptions& headerOptions, GetCallback& callback,
QualityOfService QoS)
+#endif
{
OCStackResult result;
OCCallbackData cbdata = {0};
OCHeaderOption options[MAX_HEADER_OPTIONS];
assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+ result = OCDoResource(&handle, OC_REST_GET, os.str().c_str(),
+ nullptr, nullptr, connectivityType,
+ static_cast<OCQualityOfService>(QoS),
+ &cbdata,
+ options, headerOptions.size());
+#else
result = OCDoResource(&handle, OC_REST_GET, os.str().c_str(),
nullptr, nullptr,
static_cast<OCQualityOfService>(QoS),
&cbdata,
options, headerOptions.size());
+#endif
}
else
{
return ocInfo.getJSONRepresentation(OCInfoFormat::IncludeOC);
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::PostResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const OCRepresentation& rep,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ PostCallback& callback, QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::PostResourceRepresentation(const std::string& host,
const std::string& uri, const OCRepresentation& rep,
const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
PostCallback& callback, QualityOfService QoS)
+#endif
{
OCStackResult result;
OCCallbackData cbdata = {0};
OCDoHandle handle;
assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+ result = OCDoResource(&handle, OC_REST_POST,
+ os.str().c_str(), nullptr,
+ assembleSetResourcePayload(rep).c_str(), connectivityType,
+ static_cast<OCQualityOfService>(QoS),
+ &cbdata, options, headerOptions.size());
+#else
result = OCDoResource(&handle, OC_REST_POST,
os.str().c_str(), nullptr,
assembleSetResourcePayload(rep).c_str(),
static_cast<OCQualityOfService>(QoS),
&cbdata, options, headerOptions.size());
+#endif
}
else
{
return result;
}
-
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::PutResourceRepresentation(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const OCRepresentation& rep,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ PutCallback& callback, QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::PutResourceRepresentation(const std::string& host,
const std::string& uri, const OCRepresentation& rep,
const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
PutCallback& callback, QualityOfService QoS)
+#endif
{
OCStackResult result;
OCCallbackData cbdata = {0};
OCHeaderOption options[MAX_HEADER_OPTIONS];
assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+ result = OCDoResource(&handle, OC_REST_PUT,
+ os.str().c_str(), nullptr,
+ assembleSetResourcePayload(rep).c_str(), connectivityType,
+ static_cast<OCQualityOfService>(QoS),
+ &cbdata,
+ options, headerOptions.size());
+#else
result = OCDoResource(&handle, OC_REST_PUT,
os.str().c_str(), nullptr,
assembleSetResourcePayload(rep).c_str(),
static_cast<OCQualityOfService>(QoS),
&cbdata,
options, headerOptions.size());
+#endif
}
else
{
return OC_STACK_DELETE_TRANSACTION;
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::DeleteResource(const std::string& host,
+ const std::string& uri, uint8_t connectivityType, const HeaderOptions& headerOptions,
+ DeleteCallback& callback, QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::DeleteResource(const std::string& host,
const std::string& uri, const HeaderOptions& headerOptions,
DeleteCallback& callback, QualityOfService QoS)
+#endif
{
OCStackResult result;
OCCallbackData cbdata = {0};
assembleHeaderOptions(options, headerOptions);
std::lock_guard<std::recursive_mutex> lock(*cLock);
-
+#ifdef CA_INT
+ result = OCDoResource(&handle, OC_REST_DELETE,
+ os.str().c_str(), nullptr,
+ nullptr, connectivityType,
+ static_cast<OCQualityOfService>(m_cfg.QoS),
+ &cbdata, options, headerOptions.size());
+#else
result = OCDoResource(&handle, OC_REST_DELETE,
os.str().c_str(), nullptr,
nullptr, static_cast<OCQualityOfService>(m_cfg.QoS),
&cbdata, options, headerOptions.size());
+#endif
}
else
{
return OC_STACK_KEEP_TRANSACTION;
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle,
+ const std::string& host, const std::string& uri, uint8_t connectivityType,
+ const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
+ ObserveCallback& callback, QualityOfService QoS)
+#else
OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle,
const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
const HeaderOptions& headerOptions, ObserveCallback& callback, QualityOfService QoS)
+#endif
{
OCStackResult result;
OCCallbackData cbdata = {0};
OCHeaderOption options[MAX_HEADER_OPTIONS];
assembleHeaderOptions(options, headerOptions);
+#ifdef CA_INT
+ result = OCDoResource(handle, method,
+ os.str().c_str(), nullptr,
+ nullptr, connectivityType,
+ static_cast<OCQualityOfService>(QoS),
+ &cbdata,
+ options, headerOptions.size());
+#else
result = OCDoResource(handle, method,
os.str().c_str(), nullptr,
nullptr,
static_cast<OCQualityOfService>(QoS),
&cbdata,
options, headerOptions.size());
+#endif
}
else
{
return OC_STACK_KEEP_TRANSACTION;
}
+#ifdef CA_INT
+ OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle,
+ const std::string& host, const std::string& resourceType, uint8_t connectivityType,
+ SubscribeCallback& presenceHandler)
+#else
OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle,
const std::string& host, const std::string& resourceType,
SubscribeCallback& presenceHandler)
+#endif
{
OCCallbackData cbdata = {0};
return OC_STACK_ERROR;
}
+#ifdef CA_INT
+ return OCDoResource(handle, OC_REST_PRESENCE, os.str().c_str(), nullptr, nullptr,
+ connectivityType, OC_LOW_QOS, &cbdata, NULL, 0);
+#else
return OCDoResource(handle, OC_REST_PRESENCE, os.str().c_str(), nullptr, nullptr,
OC_LOW_QOS, &cbdata, NULL, 0);
+#endif
}
OCStackResult InProcClientWrapper::UnsubscribePresence(OCDoHandle handle)
observationIds, pResponse, QoS);
}
+#ifdef CA_INT
+ OCResource::Ptr constructResourceObject(const std::string& host,
+ const std::string& uri, uint8_t connectivityType,
+ bool isObservable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces)
+ {
+ return OCPlatform_impl::Instance().constructResourceObject(host, uri, connectivityType,
+ isObservable,
+ resourceTypes, interfaces);
+ }
+
+ OCStackResult findResource(const std::string& host,
+ const std::string& resourceName,
+ uint8_t connectivityType,
+ FindCallback resourceHandler)
+ {
+ return OCPlatform_impl::Instance().findResource(host, resourceName,
+ connectivityType, resourceHandler);
+ }
+
+ OCStackResult findResource(const std::string& host,
+ const std::string& resourceName,
+ uint8_t connectivityType,
+ FindCallback resourceHandler, QualityOfService QoS)
+ {
+ return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
+ resourceHandler, QoS);
+ }
+
+ OCStackResult getDeviceInfo(const std::string& host,
+ const std::string& deviceURI,
+ uint8_t connectivityType,
+ FindDeviceCallback deviceInfoHandler)
+ {
+ return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
+ connectivityType, deviceInfoHandler);
+ }
+
+ OCStackResult getDeviceInfo(const std::string& host,
+ const std::string& deviceURI,
+ uint8_t connectivityType,
+ FindDeviceCallback deviceInfoHandler,
+ QualityOfService QoS)
+ {
+ return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
+ deviceInfoHandler, QoS);
+ }
+#else
OCResource::Ptr constructResourceObject(const std::string& host,
const std::string& uri,
bool isObservable,
return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
deviceInfoHandler, QoS);
}
-
+#endif
OCStackResult registerResource(OCResourceHandle& resourceHandle,
std::string& resourceURI,
return OCPlatform_impl::Instance().stopPresence();
}
+#ifdef CA_INT
+ OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
+ const std::string& host,
+ uint8_t connectivityType,
+ SubscribeCallback presenceHandler)
+ {
+ return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
+ connectivityType, presenceHandler);
+ }
+
+ OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
+ const std::string& host,
+ const std::string& resourceType,
+ uint8_t connectivityType,
+ SubscribeCallback presenceHandler)
+ {
+ return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
+ resourceType, connectivityType, presenceHandler);
+ }
+#else
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
const std::string& host,
SubscribeCallback presenceHandler)
return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
resourceType, presenceHandler);
}
-
+#endif
OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
{
return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
static_cast<OCQualityOfService>(QoS)));
}
+#ifdef CA_INT
+ OCResource::Ptr OCPlatform_impl::constructResourceObject(const std::string& host,
+ const std::string& uri, uint8_t connectivityType,
+ bool isObservable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces)
+ {
+ if(!m_client)
+ {
+ return std::shared_ptr<OCResource>();
+ }
+
+ return std::shared_ptr<OCResource>(new OCResource(m_client,
+ host,
+ uri, connectivityType,
+ isObservable,
+ resourceTypes,
+ interfaces));
+ }
+
+ OCStackResult OCPlatform_impl::findResource(const std::string& host,
+ const std::string& resourceName,
+ uint8_t connectivityType,
+ FindCallback resourceHandler)
+ {
+ return findResource(host, resourceName, connectivityType, resourceHandler, m_cfg.QoS);
+ }
+
+ OCStackResult OCPlatform_impl::findResource(const std::string& host,
+ const std::string& resourceName,
+ uint8_t connectivityType,
+ FindCallback resourceHandler, QualityOfService QoS)
+ {
+
+ return checked_guard(m_client, &IClientWrapper::ListenForResource,
+ host, resourceName, connectivityType, resourceHandler, QoS);
+ }
+
+ OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host,
+ const std::string& deviceURI,
+ uint8_t connectivityType,
+ FindDeviceCallback deviceInfoHandler)
+ {
+ return result_guard(getDeviceInfo(host, deviceURI, connectivityType,
+ deviceInfoHandler, m_cfg.QoS));
+ }
+
+ OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host,
+ const std::string& deviceURI,
+ uint8_t connectivityType,
+ FindDeviceCallback deviceInfoHandler,
+ QualityOfService QoS)
+ {
+ return checked_guard(m_client, &IClientWrapper::ListenForDevice,
+ host, deviceURI, connectivityType, deviceInfoHandler, QoS);
+ }
+
+#else
OCResource::Ptr OCPlatform_impl::constructResourceObject(const std::string& host,
const std::string& uri,
bool isObservable,
const std::string& resourceName,
FindCallback resourceHandler, QualityOfService QoS)
{
+
return checked_guard(m_client, &IClientWrapper::ListenForResource,
host, resourceName, resourceHandler, QoS);
}
host, deviceURI, deviceInfoHandler, QoS);
}
+#endif
+
OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
std::string& resourceURI,
const std::string& resourceTypeName,
return checked_guard(m_server, &IServerWrapper::stopPresence);
}
+#ifdef CA_INT
+ OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
+ const std::string& host, uint8_t connectivityType,
+ SubscribeCallback presenceHandler)
+ {
+ return subscribePresence(presenceHandle, host, "", connectivityType, presenceHandler);
+ }
+
+
+ OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
+ const std::string& host,
+ const std::string& resourceType,
+ uint8_t connectivityType,
+ SubscribeCallback presenceHandler)
+ {
+ return checked_guard(m_client, &IClientWrapper::SubscribePresence,
+ &presenceHandle, host, resourceType, connectivityType,
+ presenceHandler);
+ }
+#else
OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
const std::string& host,
SubscribeCallback presenceHandler)
SubscribeCallback presenceHandler)
{
return checked_guard(m_client, &IClientWrapper::SubscribePresence,
- &presenceHandle, host, resourceType, presenceHandler);
+ &presenceHandle, host, resourceType,
+ presenceHandler);
}
+#endif
OCStackResult OCPlatform_impl::unsubscribePresence(OCPresenceHandle presenceHandle)
{
using OC::result_guard;
using OC::checked_guard;
+#ifdef CA_INT
+OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::string& host,
+ const std::string& uri, uint8_t connectivityType, bool observable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces)
+ : m_clientWrapper(clientWrapper), m_uri(uri), m_connectivityType(connectivityType),
+ m_host(host), m_isObservable(observable),
+ m_isCollection(false), m_resourceTypes(resourceTypes), m_interfaces(interfaces),
+ m_observeHandle(nullptr)
+{
+ m_isCollection = std::find(m_interfaces.begin(), m_interfaces.end(), LINK_INTERFACE)
+ != m_interfaces.end();
+
+ if (m_uri.empty() ||
+ resourceTypes.empty() ||
+ interfaces.empty()||
+ m_clientWrapper.expired())
+ {
+ throw ResourceInitException(m_uri.empty(), resourceTypes.empty(),
+ interfaces.empty(), m_clientWrapper.expired(), false, false);
+ }
+}
+#else
OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::string& host,
const std::string& uri, bool observable, const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces)
interfaces.empty(), m_clientWrapper.expired(), false, false);
}
}
+#endif
OCResource::~OCResource()
{
OCStackResult OCResource::get(const QueryParamsMap& queryParametersMap,
GetCallback attributeHandler, QualityOfService QoS)
{
+#ifdef CA_INT
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetResourceRepresentation,
+ m_host, m_uri, m_connectivityType, queryParametersMap, m_headerOptions,
+ attributeHandler, QoS);
+#else
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetResourceRepresentation,
m_host, m_uri, queryParametersMap, m_headerOptions, attributeHandler, QoS);
+#endif
}
OCStackResult OCResource::get(const QueryParamsMap& queryParametersMap,
const QueryParamsMap& queryParametersMap, PutCallback attributeHandler,
QualityOfService QoS)
{
+#ifdef CA_INT
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PutResourceRepresentation,
+ m_host, m_uri, m_connectivityType, rep, queryParametersMap,
+ m_headerOptions, attributeHandler, QoS);
+#else
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PutResourceRepresentation,
m_host, m_uri, rep, queryParametersMap, m_headerOptions, attributeHandler, QoS);
+#endif
}
OCStackResult OCResource::put(const OCRepresentation& rep,
const QueryParamsMap& queryParametersMap, PostCallback attributeHandler,
QualityOfService QoS)
{
+#ifdef CA_INT
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
+ m_host, m_uri, m_connectivityType, rep, queryParametersMap,
+ m_headerOptions, attributeHandler, QoS);
+#else
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation,
m_host, m_uri, rep, queryParametersMap, m_headerOptions, attributeHandler, QoS);
+#endif
}
OCStackResult OCResource::post(const OCRepresentation& rep,
OCStackResult OCResource::deleteResource(DeleteCallback deleteHandler, QualityOfService QoS)
{
+#ifdef CA_INT
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
+ m_host, m_uri, m_connectivityType, m_headerOptions, deleteHandler, QoS);
+#else
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource,
m_host, m_uri, m_headerOptions, deleteHandler, QoS);
+#endif
}
OCStackResult OCResource::deleteResource(DeleteCallback deleteHandler)
return result_guard(OC_STACK_INVALID_PARAM);
}
+#ifdef CA_INT
+ return checked_guard(m_clientWrapper.lock(), &IClientWrapper::ObserveResource,
+ observeType, &m_observeHandle, m_host,
+ m_uri, m_connectivityType, queryParametersMap, m_headerOptions,
+ observeHandler, QoS);
+#else
return checked_guard(m_clientWrapper.lock(), &IClientWrapper::ObserveResource,
observeType, &m_observeHandle, m_host,
m_uri, queryParametersMap, m_headerOptions, observeHandler, QoS);
+#endif
}
OCStackResult OCResource::observe(ObserveType observeType,
return m_uri;
}
+#ifdef CA_INT
+uint8_t OCResource::connectivityType() const
+{
+ return m_connectivityType;
+}
+#endif
+
bool OCResource::isObservable() const
{
return m_isObservable;