Merge "[CA Integration] Updated C sample apps to accept connectivity type param"...
authorSudarshan Prasad <sudarshan.prasad@intel.com>
Thu, 25 Dec 2014 01:20:14 +0000 (01:20 +0000)
committerGerrit Code Review <gerrit@172.30.200.205>
Thu, 25 Dec 2014 01:20:14 +0000 (01:20 +0000)
38 files changed:
auto_build.sh
resource/SConscript
resource/csdk/SConscript
resource/csdk/connectivity/SConscript [new file with mode: 0644]
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript [new file with mode: 0644]
resource/csdk/connectivity/samples/linux/sample_main.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/camessagehandler_singlethread.c
resource/csdk/libcoap-4.1.1/SConscript
resource/csdk/stack/include/ocstack.h
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript [new file with mode: 0644]
resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp
resource/csdk/stack/src/ocstack.c
resource/examples/SConscript
resource/examples/devicediscoveryclient.cpp
resource/examples/fridgeclient.cpp
resource/examples/garageclient.cpp
resource/examples/groupclient.cpp
resource/examples/groupserver.cpp
resource/examples/ocicuc/SConscript
resource/examples/presenceclient.cpp
resource/examples/roomclient.cpp
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp
resource/examples/simpleclientserver.cpp
resource/examples/threadingsample.cpp
resource/include/IClientWrapper.h
resource/include/InProcClientWrapper.h
resource/include/OCPlatform.h
resource/include/OCPlatform_impl.h
resource/include/OCResource.h
resource/include/OCSerialization.h
resource/include/OutOfProcClientWrapper.h
resource/makefile
resource/src/InProcClientWrapper.cpp
resource/src/OCPlatform.cpp
resource/src/OCPlatform_impl.cpp
resource/src/OCResource.cpp

index efe7530..c2af2e1 100755 (executable)
@@ -39,11 +39,13 @@ function build()
                scons TARGET_OS=android TARGET_ARCH=armeabi-v7a-hard ANDROID_NDK=$1 RELEASE=$3
        fi
 
+: '
        echo "*********** Build for arduino avr *************"
        scons TARGET_OS=arduino TARGET_ARCH=avr ARDUINO_HOME=$2 RELEASE=$3
 
        echo "*********** Build for arduino arm *************"
        scons TARGET_OS=arduino TARGET_ARCH=arm ARDUINO_HOME=$2 RELEASE=$3
+'
 
        if [ $(uname -s) = "Darwin" ]
        then
index fc82826..6c969c2 100644 (file)
@@ -8,8 +8,12 @@ Import('env')
 target_os = env.get('TARGET_OS')
 
 # Build libcoap
+SConscript('csdk/connectivity/lib/libcoap-4.1.1/SConscript')
 SConscript('csdk/libcoap/SConscript')
 
+# Build connectivity
+SConscript('csdk/connectivity/SConscript')
+
 # Build liboctbstack
 SConscript('csdk/SConscript')
 
@@ -22,5 +26,7 @@ if target_os != 'arduino':
 
        # Build examples
        SConscript('examples/SConscript')
+
+       SConscript('csdk/stack/samples/linux/SimpleClientServer/SConscript')
 else:
-       SConscript('csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript')
\ No newline at end of file
+       SConscript('csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript')
index 6de4c2d..f393088 100644 (file)
@@ -29,7 +29,9 @@ liboctbstack_env.PrependUnique(CPPPATH = [
                'occoap/include',
                'stack/include',
                'stack/include/internal',
-               '../oc_logger/include'
+               '../oc_logger/include',
+               'connectivity/inc',
+               'connectivity/api',
                ])
 
 if target_os not in ['arduino', 'windows', 'winrt']:
@@ -56,6 +58,8 @@ if target_os in ['darwin', 'ios']:
 if not env.get('RELEASE'):
        liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
+liboctbstack_env.AppendUnique(CPPDEFINES = ['CA_INT'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
diff --git a/resource/csdk/connectivity/SConscript b/resource/csdk/connectivity/SConscript
new file mode 100644 (file)
index 0000000..7cb81e2
--- /dev/null
@@ -0,0 +1,77 @@
+##
+# CA library (share library) build script
+##
+Import('env')
+
+# Add third party libraries
+lib_env = env.Clone()
+SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
+
+calib_env = lib_env.Clone()
+######################################################################
+# Build flags
+######################################################################
+calib_env.AppendUnique(CPPPATH = [
+               './common/inc',
+               './api',
+               './inc',
+               './src/ethernet_adapter/linux',
+               './src/wifi_adapter/linux',
+               './src/bt_edr_adapter/linux',
+               './src/bt_le_adapter/linux',
+               './lib/libcoap-4.1.1'
+               ])
+
+target_os = env.get('TARGET_OS')
+
+if target_os not in ['windows', 'winrt']:
+       calib_env.AppendUnique(CFLAGS = ['-Wall', '-fPIC', '-fstack-protector-all']);
+       calib_env.AppendUnique(CPPDEFINES = [
+                       '__LINUX__', 'WITH_POSIX',
+                       'NO_EDR_ADAPTER', 'NO_LE_ADAPTER',
+                       'WIFI_ADAPTER', 'ETHERNET_ADAPTER',
+                       #'TB_LOG'
+                       ])
+
+calib_env.ParseConfig('pkg-config --cflags glib-2.0')
+
+#TODO add SConscript for libcoap
+#`/home/tester/iotivity/resource/csdk/connectivity/lib/libcoap-4.1.1'
+
+######################################################################
+# Source files and Targets
+######################################################################
+calib_src = [
+               './common/src/logger.c',
+               './common/src/oic_logger.c',
+               './common/src/oic_console_logger.c',
+               './common/src/oic_malloc.c',
+               './common/src/oic_string.c',
+               './common/src/uqueue.c',
+               './common/src/uarraylist.c',
+               './common/src/umutex.c',
+               './common/src/uthreadpool.c',
+               './src/caretransmission.c',
+               './src/caconnectivitymanager.c',
+               './src/caremotehandler.c',
+               './src/cainterfacecontroller.c',
+               './src/camessagehandler.c',
+               './src/caqueueingthread.c',
+               './src/canetworkconfigurator.c',
+               './src/caprotocolmessage.c',
+               './src/adapter_util/caadapterutils.c',
+               './src/ethernet_adapter/caethernetadapter.c',
+               './src/wifi_adapter/cawifiadapter.c',
+               './src/bt_edr_adapter/linux/caedradapter.c',
+               './src/bt_le_adapter/linux/caleadapter.c',
+               './src/wifi_adapter/linux/cawifiserver.c',
+               './src/wifi_adapter/linux/cawificlient.c',
+               './src/wifi_adapter/linux/cawifinwmonitor.c',
+               './src/ethernet_adapter/linux/caethernetserver.c',
+               './src/ethernet_adapter/linux/caethernetclient.c',
+               './src/ethernet_adapter/linux/caethernetnwmonitor.c'
+       ]
+
+calib = calib_env.SharedLibrary('connectivity_abstraction', calib_src)
+calib_env.InstallTarget(calib, 'libconnectivity_abstraction')
+
diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript b/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
new file mode 100644 (file)
index 0000000..91ef9a5
--- /dev/null
@@ -0,0 +1,77 @@
+##
+# libcoap (share library) build script
+##
+
+Import('env')
+
+libcoap_env = env.Clone()
+
+target_os = env.get('TARGET_OS')
+# As in the source code(C) includes arduino Time library head file(C++)
+# It requires compile the .c with g++
+if target_os == 'arduino':
+       libcoap_env.Replace(CC = env.get('CXX'))
+       libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+
+######################################################################
+# Build flags
+######################################################################
+libcoap_env.PrependUnique(CPPPATH = [
+               '../ocsocket/include',
+               '../ocmalloc/include',
+               '../logger/include',
+               '../ocrandom/include',
+               '../stack',
+               '../../oc_logger/include'
+               ])
+
+if target_os not in ['arduino', 'windows', 'winrt']:
+       libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
+       libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99', '-fPIC'])
+
+if target_os not in ['windows', 'winrt']:
+       libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
+                       '-fdata-sections', '-fno-exceptions'])
+
+if target_os == 'android':
+       libcoap_env.AppendUnique(LIBS = ['log'])
+
+if target_os == 'arduino':
+       libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
+
+if target_os in ['darwin', 'ios']:
+       libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+
+if not env.get('RELEASE'):
+       libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+######################################################################
+# Source files and Target(s)
+######################################################################
+libcoap_src = [
+       'pdu.c',
+       'net.c',
+       'debug.c',
+       'encode.c',
+       'uri.c',
+       'coap_list.c',
+       'resource.c',
+       'hashkey.c',
+    'str.c',
+       'option.c',
+       'async.c',
+       'subscribe.c',
+       'block.c',
+#      '../logger/src/logger.c',
+#      '../ocrandom/src/ocrandom.c',
+#      '../ocmalloc/src/ocmalloc.c',
+#      '../../oc_logger/c/oc_logger.c',
+#      '../../oc_logger/c/oc_console_logger.c'
+       ]
+
+if target_os == 'arduino':
+       libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
+else:
+       libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
+
+libcoap_env.InstallTarget(libcoap, 'libcoap')
index a6620cb..3c4fdaf 100644 (file)
@@ -626,6 +626,7 @@ void send_request_all()
     memset(&requestData, 0, sizeof(CAInfo_t));
     requestData.token = token;
     requestData.payload = "Temp Json Payload";
+       requestData.type = CA_MSG_NONCONFIRM;
 
     CARequestInfo_t requestInfo;
     memset(&requestInfo, 0, sizeof(CARequestInfo_t));
index f13f926..d7ca0d4 100644 (file)
@@ -160,7 +160,7 @@ static void CASendThreadProcess(void *threadData)
             OIC_LOG_V(DEBUG, TAG, "responseInfo is available..");
 
             pdu = (coap_pdu_t *) CAGeneratePdu(data->remoteEndpoint->resourceUri,
-                                               data->responseInfo->result, 
+                                               data->responseInfo->result,
                                                data->responseInfo->info);
         }
         else
@@ -205,6 +205,7 @@ static void CASendThreadProcess(void *threadData)
         info.options = data->options;
         info.numOptions = data->numOptions;
         info.token = data->requestInfo->info.token;
+        info.type = data->requestInfo->info.type;
 
         pdu = (coap_pdu_t *) CAGeneratePdu(data->remoteEndpoint->resourceUri, CA_GET, info);
 
@@ -664,6 +665,7 @@ CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t
     memset(ReqInfo, 0, sizeof(CARequestInfo_t));
     ReqInfo->method = CA_GET;
     ReqInfo->info.token = token;
+    ReqInfo->info.type = CA_MSG_NONCONFIRM;
     data->requestInfo = ReqInfo;
 
     data->responseInfo = NULL;
index b6d46e8..a1da2c6 100644 (file)
@@ -128,6 +128,7 @@ static void CAProcessData(CAData_t *data)
         info.options = data->options;
         info.numOptions = data->numOptions;
         info.token = data->requestInfo->info.token;
+        info.type = data->requestInfo->info.type;
 
         pdu = (coap_pdu_t *) CAGeneratePdu(data->remoteEndpoint->resourceUri, CA_GET, info);
 
@@ -441,6 +442,7 @@ CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t
     memset(ReqInfo, 0, sizeof(CARequestInfo_t));
     ReqInfo->method = CA_GET;
     ReqInfo->info.token = token;
+    ReqInfo->info.type = CA_MSG_NONCONFIRM;
     data->requestInfo = ReqInfo;
 
     data->responseInfo = NULL;
index 7e1bdf1..778e191 100644 (file)
@@ -78,8 +78,8 @@ else:
        libcoap_src.append(['../ocsocket/src/ocsocket.c'])
 
 if target_os == 'arduino':
-       libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
+       libcoap = libcoap_env.StaticLibrary('libcoap_csdk', libcoap_src, OBJPREFIX='libcoap_')
 else:
-       libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
+       libcoap = libcoap_env.SharedLibrary('libcoap_csdk', libcoap_src, OBJPREFIX='libcoap_')
 
-libcoap_env.InstallTarget(libcoap, 'libcoap')
+libcoap_env.InstallTarget(libcoap, 'libcoap_csdk')
index 8be0d12..eba9044 100644 (file)
@@ -333,6 +333,15 @@ typedef enum {
     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
 //-----------------------------------------------------------------------------
@@ -447,9 +456,16 @@ OCStackResult OCProcess();
  *     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.
diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/SConscript b/resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
new file mode 100644 (file)
index 0000000..2429690
--- /dev/null
@@ -0,0 +1,65 @@
+
+Import('env')
+
+samples_env = env.Clone()
+######################################################################
+# Build flags
+######################################################################
+samples_env.PrependUnique(CPPPATH = [
+               '../../../../ocsocket/include',
+               '../../../../logger/include',
+               '../../../../stack/include',
+               '../../../../../../extlibs/cjson',
+               '../../../../../oc_logger/include'
+               ])
+
+target_os = env.get('TARGET_OS')
+if target_os not in ['windows', 'winrt']:
+       samples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+
+       # Note: 'pthread' is in libc for android. On other platform, if use
+       # new gcc(>4.9?) it isn't required, otherwise, it's required
+       if target_os != 'android':
+               samples_env.AppendUnique(LIBS = ['-lpthread'])
+
+samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+samples_env.PrependUnique(LIBS = ['oc', 'm', 'octbstack', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction'])
+
+samples_env.ParseConfig('pkg-config --libs glib-2.0');
+
+if target_os == 'android':
+       samples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+       samples_env.AppendUnique(LIBS = ['gnustl_static'])
+       samples_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
+
+       if not env.get('RELEASE'):
+               samples_env.AppendUnique(LIBS = ['log'])
+
+if target_os in ['darwin', 'ios']:
+       samples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+
+samples_env.AppendUnique(CPPDEFINES = ['CA_INT'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+ocserver         = samples_env.Program('ocserver', 'ocserver.cpp')
+occlient         = samples_env.Program('occlient', 'occlient.cpp')
+#ocserverslow     = samples_env.Program('ocserverslow', 'ocserverslow.cpp')
+#occlientslow     = samples_env.Program('occlientslow', 'occlientslow.cpp')
+#ocservercoll     = samples_env.Program('ocservercoll', 'ocservercoll.cpp')
+#occlientcoll     = samples_env.Program('occlientcoll', 'occlientcoll.cpp')
+#ocserverbasicops = samples_env.Program('ocserverbasicops', 'ocserverbasicops.cpp')
+#occlientbasicops = samples_env.Program('occlientbasicops', 'occlientbasicops.cpp')
+
+Alias("samples", [ocserver, occlient,
+                               #ocservercoll, occlientcoll,
+                               #ocserverbasicops, occlientbasicops,
+                               #ocserverslow, occlientslow
+                ])
+
+env.AppendTarget('samples')
+
+#ios doesn't allow run application from terminal, so won't build these samples
+#if target_os != 'ios':
+#      SConscript('ocicuc/SConscript')
index a75b559..e0abee0 100644 (file)
@@ -7,7 +7,6 @@
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
-//
 //      http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
 #include <string.h>
 #include <signal.h>
 #include <unistd.h>
-#include <iostream>
+
+#include <set>
+#include <string>
 #include <sstream>
+#include <iostream>
+#include <algorithm>
+
 #include "ocstack.h"
 #include "logger.h"
 #include "occlientbasicops.h"
 
 static int UNICAST_DISCOVERY = 0;
 static int TEST_CASE = 0;
+
 static const char * TEST_APP_UNICAST_DISCOVERY_QUERY = "coap://0.0.0.0:5683/oc/core";
+
 static std::string putPayload = "{\"state\":\"off\",\"power\":10}";
+
 static std::string coapServerIP = "255.255.255.255";
 static std::string coapServerPort = "5683";
 static std::string coapServerResource = "/a/led";
 
 int gQuitFlag = 0;
 
+namespace {
+    typedef std::pair<bool, std::string>    extract_result_t;
+    typedef std::string                     sid_t;
+    typedef std::set<std::string>           SID_set_t;
+} // namespace
+
+void collateSIDs(const OCClientResponse * clientResponse, const std::string& server_ip);
+
 /* SIGINT handler: set gQuitFlag to 1 for graceful termination */
 void handleSigInt(int signum)
 {
@@ -122,21 +137,18 @@ OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientRespons
 
 OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse)
 {
-    if(clientResponse == NULL)
-    {
-        OC_LOG(INFO, TAG, "The clientResponse is NULL");
-        return   OC_STACK_DELETE_TRANSACTION;
-    }
     if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
     }
 
-    OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
-    OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
-    OC_LOG_V(INFO, TAG, "JSON = %s =============> Get Response",
-            clientResponse->resJSONPayload);
-
+    if(clientResponse)
+    {
+        OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
+        OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
+        OC_LOG_V(INFO, TAG, "JSON = %s =============> Get Response",
+                clientResponse->resJSONPayload);
+    }
     if(clientResponse->rcvdVendorSpecificHeaderOptions &&
             clientResponse->numRcvdVendorSpecificHeaderOptions)
     {
@@ -164,7 +176,7 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
     uint8_t remoteIpAddr[4];
     uint16_t remotePortNu;
 
-    if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
+    if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
     {
         OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
     }
@@ -184,6 +196,8 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
 
         parseClientResponse(clientResponse);
 
+        collateSIDs(clientResponse, getIPAddrTBServer(clientResponse));
+
         switch(TEST_CASE)
         {
             case TEST_NON_CON_OP:
@@ -203,7 +217,6 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
     }
 
     return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
-
 }
 
 int InitPutRequest()
@@ -339,8 +352,8 @@ int main(int argc, char* argv[])
     InitDiscovery();
 
     // Break from loop with Ctrl+C
-    OC_LOG(INFO, TAG, "Entering occlient main loop...");
     signal(SIGINT, handleSigInt);
+
     while (!gQuitFlag)
     {
         if (OCProcess() != OC_STACK_OK)
@@ -391,9 +404,69 @@ std::string getQueryStrForGetPut(OCClientResponse * clientResponse)
     return "/a/led";
 }
 
+
+/* You could do this with the JSON parser of your choice, a regular expression, PEG
+grammar, etc.. This "sample" version does not handle cases like escaping strings,
+but shows a simple way you might approach the task with just the C++98 library: */
+extract_result_t extract_value(const std::string& search_key, const std::string& input)
+{
+    const std::string key('\"' + search_key + "\":\"");
+
+    const size_t key_mark = input.find(key);
+    const size_t key_edge = key_mark + key.length();
+    const size_t val_mark = input.find_first_of("\"", key_edge);
+
+    if(std::string::npos == key_mark || std::string::npos == val_mark) {
+       std::ostringstream os;
+
+       os << "extract_value(): \"" << search_key << "\" not found in input";
+       OC_LOG(ERROR, TAG, os.str().c_str());
+
+       return std::make_pair(false, "");
+     }
+
+    return std::make_pair(true, input.substr(key_edge, val_mark - key_edge));
+}
+
+extract_result_t parseSID(const OCClientResponse * const clientResponse)
+{
+    const char* const& pl_in = reinterpret_cast<const char *>(clientResponse->resJSONPayload);
+
+    const std::string pl(pl_in, strlen(pl_in));
+
+    const extract_result_t sid = extract_value("sid", pl);
+    const extract_result_t uri = extract_value("href", pl);
+    //TODO-CA: It should be just enough to send the SID alone and not the combination
+    // of it.
+    return std::make_pair(sid.first and uri.first, sid.second + ':' + uri.second);
+}
+
 void parseClientResponse(OCClientResponse * clientResponse)
 {
     coapServerIP = getIPAddrTBServer(clientResponse);
     coapServerPort = getPortTBServer(clientResponse);
     coapServerResource = getQueryStrForGetPut(clientResponse);
 }
+
+void collateSIDs(const OCClientResponse * clientResponse, const std::string& server_ip)
+{
+    static SID_set_t sids;
+
+    const extract_result_t sid_result = parseSID(clientResponse);
+
+    if(false == sid_result.first)
+     return;
+
+    const sid_t& sid = sid_result.second;
+
+    /* ...there's no need for an application to take any special action, but we can tell
+    if we've seen a resource before, regardless of the transport it arrive on: */
+    std::ostringstream msg;
+
+    if(not sids.insert(sid).second)
+     msg << "SID " << sid << " has been seen before.\n";
+    else
+     msg << "SID " << sid << " is new.\n";
+
+    OC_LOG(INFO, TAG, msg.str().c_str());
+}
index 87ed18d..9ded668 100644 (file)
@@ -69,6 +69,7 @@ uint32_t PresenceTimeOut[] = {50, 75, 85, 95, 100};
 
 OCMode myStackMode;
 OCDeviceEntityHandler defaultDeviceHandler;
+OCStackResult getQueryFromUri(const char * uri, unsigned char** resourceType, char ** newURI);
 
 //-----------------------------------------------------------------------------
 // Macros
@@ -308,10 +309,21 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t*
     OCServerProtocolRequest serverRequest;
 
     memset (&serverRequest, 0, sizeof(OCServerProtocolRequest));
-    // copy URI of resource
-    memcpy (&(serverRequest.resourceUrl), endPoint->resourceUri, strlen(endPoint->resourceUri));
+    OC_LOG_V(INFO, TAG, PCF("***** Endpoint URI ***** : %s\n"), (char*)endPoint->resourceUri);
+
+    char * newUri = (char *)endPoint->resourceUri;
+    unsigned char * query = NULL;
+    unsigned char * resourceType = NULL;
+    getQueryFromUri(endPoint->resourceUri, &query, &newUri);
+    OC_LOG_V(INFO, TAG, PCF("**********URI without query ****: %s\n"), newUri);
+    OC_LOG_V(INFO, TAG, PCF("**********Query ****: %s\n"), query);
+    //copy URI
+    memcpy (&(serverRequest.resourceUrl), newUri, strlen(newUri));
     //copy query
-    // TODO-CA: Is the query part of header option?
+    if(query)
+    {
+        memcpy (&(serverRequest.query), query, strlen(query));
+    }
     //copy request payload
     if (requestInfo->info.payload)
     {
@@ -845,7 +857,7 @@ static void incrementSequenceNumber(OCResource * resPtr);
 static OCStackResult verifyUriQueryLength(const char * inputUri,
         uint16_t uriLen);
 static uint8_t OCIsPacketTransferRequired(const char *request, const char *response, uint16_t size);
-OCStackResult getResourceType(const char * uri, unsigned char** resourceType, char ** newURI);
+OCStackResult getResourceType(const char * query, unsigned char** resourceType);
 
 //-----------------------------------------------------------------------------
 // Public APIs
@@ -1080,17 +1092,24 @@ OCStackResult verifyUriQueryLength(const char *inputUri, uint16_t uriLen)
  *     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;
     ClientCB *clientCB = NULL;
     unsigned char * requestUri = NULL;
     unsigned char * resourceType = NULL;
+    unsigned char * query = NULL;
     char * newUri = (char *)requiredUri;
     (void) referenceUri;
 #ifdef CA_INT
@@ -1148,13 +1167,24 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ
 #ifdef WITH_PRESENCE
     if(method == OC_REST_PRESENCE)
     {
-        result = getResourceType(requiredUri, &resourceType, &newUri);
-        if(resourceType) {
-            OC_LOG_V(DEBUG, TAG, "Got Resource Type: %s", resourceType);
+        // Replacing method type with GET because "presence" is a stack layer only implementation.
+        method = OC_REST_GET;
+        result = getQueryFromUri(requiredUri, &query, &newUri);
+        if(query)
+        {
+            result = getResourceType((char *) query, &resourceType);
+            if(resourceType)
+            {
+                OC_LOG_V(DEBUG, TAG, "Got Resource Type: %s", resourceType);
+            }
+            else
+            {
+                OC_LOG(DEBUG, TAG, PCF("Resource type is NULL."));
+            }
         }
         else
         {
-            OC_LOG(DEBUG, TAG, PCF("Got Resource Type is NULL."));
+            OC_LOG(DEBUG, TAG, PCF("Query string is NULL."));
         }
         if(result != OC_STACK_OK)
         {
@@ -1291,14 +1321,6 @@ OCStackResult OCDoResource(OCDoHandle *handle, OCMethod method, const char *requ
         goto exit;
     }
 
-#ifdef WITH_PRESENCE
-    if(method == OC_REST_PRESENCE)
-    {
-        // Replacing method type with GET because "presence" is a stack layer only implementation.
-        method = OC_REST_GET;
-    }
-#endif
-
     // Make call to OCCoAP layer
     result = OCDoCoAPResource(method, qos, &token, newUri, request, options, numOptions);
 #endif // CA_INT
@@ -3072,29 +3094,50 @@ uint8_t OCIsPacketTransferRequired(const char *request, const char *response, ui
 }
 
 /**
- * Retrieves a resource type based upon a uri string if the uri string contains only just one
+ * Retrieves a resource type based upon a query ontains only just one
  * resource attribute (and that has to be of type "rt").
  *
- * @remark This API malloc's memory for the resource type and newURI. Do not malloc resourceType
- * or newURI before passing in.
+ * @remark This API malloc's memory for the resource type. Do not malloc resourceType
+ * before passing in.
  *
- * @param uri - Valid URI for "requiredUri" parameter to OCDoResource API.
+ * @param query - The quert part of the URI
  * @param resourceType - The resource type to be populated; pass by reference.
- * @param newURI - Return URI without resourceType appended to the end of it. This is used to
- *                 ensure that the uri parameter is not modified; pass by reference.
  *
  * @return
- *  OC_STACK_INVALID_URI   - Returns this if the URI is invalid/NULL.
  *  OC_STACK_INVALID_PARAM - Returns this if the resourceType parameter is invalid/NULL.
  *  OC_STACK_OK            - Success
  */
-OCStackResult getResourceType(const char * uri, unsigned char** resourceType, char ** newURI)
+OCStackResult getResourceType(const char * query, unsigned char** resourceType)
+{
+    if(!query)
+    {
+        return OC_STACK_INVALID_PARAM;
+    }
+
+    OCStackResult result = OC_STACK_ERROR;
+
+    if(strncmp(query, "rt=", 3) == 0)
+    {
+        *resourceType = (unsigned char *) OCMalloc(strlen(query)-3);
+        if(!*resourceType)
+        {
+            result = OC_STACK_NO_MEMORY;
+        }
+
+        strcpy((char *)*resourceType, ((const char *)&query[3]));
+        result = OC_STACK_OK;
+    }
+
+    return result;
+}
+
+OCStackResult getQueryFromUri(const char * uri, unsigned char** query, char ** newURI)
 {
     if(!uri)
     {
         return OC_STACK_INVALID_URI;
     }
-    if(!resourceType || !newURI)
+    if(!query || !newURI)
     {
         return OC_STACK_INVALID_PARAM;
     }
@@ -3108,16 +3151,17 @@ OCStackResult getResourceType(const char * uri, unsigned char** resourceType, ch
     char* strTokPtr;
     leftToken = strtok_r((char *)tempURI, "?", &strTokPtr);
 
+    //TODO-CA: This could be simplified. Clean up required.
     while(leftToken != NULL)
     {
-        if(strncmp(leftToken, "rt=", 3) == 0)
+        if(strncmp(leftToken, "rt=", 3) == 0 || strncmp(leftToken, "if=", 3) == 0)
         {
-            *resourceType = (unsigned char *) OCMalloc(strlen(leftToken)-3);
-            if(!*resourceType)
+            *query = (unsigned char *) OCMalloc(strlen(leftToken));
+            if(!*query)
             {
                 goto exit;
             }
-            strcpy((char *)*resourceType, ((const char *)&leftToken[3]));
+            strcpy((char *)*query, ((const char *)&leftToken[0]));
             break;
         }
         leftToken = strtok_r(NULL, "?", &strTokPtr);
index 4a12d01..c65b4f1 100644 (file)
@@ -31,7 +31,9 @@ if target_os not in ['windows', 'winrt']:
                examples_env.AppendUnique(LIBS = ['-lpthread'])
 
 examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'oc_logger'])
+examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction'])
+
+examples_env.ParseConfig('pkg-config --libs glib-2.0');
 
 if target_os == 'android':
        examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
@@ -70,5 +72,5 @@ Alias("examples", [simpleserver, simpleserverHQ, simpleclient, simpleclientHQ,
 env.AppendTarget('examples')
 
 #ios doesn't allow run application from terminal, so won't build these examples
-if target_os != 'ios':
-       SConscript('ocicuc/SConscript')
+#if target_os != 'ios':
+#      SConscript('ocicuc/SConscript')
index f08a8c7..4bc412c 100644 (file)
@@ -125,7 +125,13 @@ int main() {
     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-
index a37c581..30420b3 100644 (file)
@@ -44,9 +44,14 @@ class ClientFridge
     {
         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)
         {
@@ -79,8 +84,14 @@ class ClientFridge
         // 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)
         {
@@ -89,25 +100,41 @@ class ClientFridge
         }
 
         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";
index ba8a09a..392a501 100644 (file)
@@ -282,8 +282,14 @@ int main(int argc, char* argv[]) {
     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-
index 11afb80..4e5e654 100755 (executable)
@@ -133,7 +133,13 @@ int main()
         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;
 
index 4cebd44..4ebb2d6 100755 (executable)
@@ -101,7 +101,14 @@ int main()
 
         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);
 
index 0b52b29..a4d8050 100644 (file)
@@ -20,7 +20,9 @@ ocicuc_env.AppendUnique(CPPPATH = [
                ])
 
 ocicuc_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-ocicuc_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'oc_logger'])
+ocicuc_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap_csdk', 'coap', 'oc_logger', 'connectivity_abstraction'])
+
+ocicuc_env.ParseConfig('pkg-config --libs glib-2.0');
 
 target_os = env.get('TARGET_OS')
 if target_os not in ['windows', 'winrt']:
@@ -46,4 +48,4 @@ monoprocess = ocicuc_env.Program('monoprocess', ['monoprocess.cpp', 'driver.cpp'
 small_example = ocicuc_env.Program('small_example', ['small_example.cpp', 'driver.cpp', 'utility.cpp'])
 
 Alias("examples_ocicuc", [client, server, monoprocess, small_example])
-env.AppendTarget('examples_ocicuc')
\ No newline at end of file
+env.AppendTarget('examples_ocicuc')
index 857d0f4..2d0a9d0 100644 (file)
@@ -132,11 +132,19 @@ void foundResource(std::shared_ptr<OCResource> resource)
                 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;
@@ -150,8 +158,13 @@ void foundResource(std::shared_ptr<OCResource> resource)
                 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;
@@ -164,8 +177,13 @@ void foundResource(std::shared_ptr<OCResource> resource)
                 }
                 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;
@@ -229,11 +247,20 @@ int main(int argc, char* argv[]) {
 
         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;
@@ -245,8 +272,13 @@ int main(int argc, char* argv[]) {
         }
         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";
@@ -259,8 +291,13 @@ int main(int argc, char* argv[]) {
         }
         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";
@@ -271,8 +308,13 @@ int main(int argc, char* argv[]) {
             }
             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";
@@ -286,7 +328,13 @@ int main(int argc, char* argv[]) {
         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;
index 7e73597..3cf5540 100644 (file)
@@ -233,7 +233,14 @@ int main(int argc, char* argv[]) {
     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-
index 85c0dc1..0451ddb 100644 (file)
@@ -371,7 +371,13 @@ int main(int argc, char* argv[]) {
         // 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-
index e3a6f2c..a215ef0 100644 (file)
@@ -384,8 +384,14 @@ int main(int argc, char* argv[]) {
     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-
index d3ee18b..763af03 100644 (file)
@@ -146,9 +146,17 @@ public:
     {
         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;
 
         {
index ff556e2..b092c1a 100644 (file)
@@ -280,9 +280,14 @@ void foundResource1(std::shared_ptr<OCResource> resource)
 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
@@ -297,10 +302,16 @@ void client1()
 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
index 1e40e23..31a9591 100644 (file)
@@ -40,6 +40,44 @@ namespace OC
         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;
@@ -71,13 +109,18 @@ namespace OC
                         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;
index ced111d..0d29b9d 100644 (file)
@@ -83,6 +83,39 @@ namespace OC
                             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);
@@ -112,12 +145,18 @@ namespace OC
         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);
index 1cad339..8639dbe 100644 (file)
@@ -114,11 +114,17 @@ namespace OC
         * 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
          *
@@ -129,11 +135,18 @@ namespace OC
          * @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.
@@ -381,11 +394,18 @@ namespace OC
         *
         * @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
@@ -423,10 +443,16 @@ namespace OC
         * @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.
         *
index f25ce2e..b4d4810 100644 (file)
@@ -140,11 +140,17 @@ namespace OC
         * 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
          *
@@ -155,11 +161,18 @@ namespace OC
          * @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.
@@ -403,11 +416,18 @@ namespace OC
         *
         * @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
@@ -445,10 +465,16 @@ namespace OC
         * @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.
         *
index 63c4253..cf9bded 100644 (file)
@@ -274,6 +274,14 @@ namespace OC
         */
         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
@@ -303,6 +311,9 @@ namespace OC
         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;
@@ -312,9 +323,17 @@ namespace OC
         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
index f611407..ff47918 100644 (file)
@@ -258,11 +258,21 @@ 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
                         }
 
                     }
index 049c445..0654a36 100644 (file)
@@ -32,6 +32,45 @@ namespace OC
                                 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;}
@@ -68,15 +107,20 @@ namespace OC
             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;}
index a710781..b6b1833 100644 (file)
@@ -37,8 +37,9 @@ CEREAL_DIR:= $(DEPEND_DIR)/cereal
 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
index 83e4ef8..4244b5a 100644 (file)
@@ -172,8 +172,14 @@ namespace OC
         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;
 
@@ -192,12 +198,21 @@ namespace OC
         {
             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
         {
@@ -220,8 +235,14 @@ namespace OC
         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;
 
@@ -241,12 +262,21 @@ namespace OC
         {
             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
         {
@@ -300,10 +330,17 @@ namespace OC
         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};
@@ -326,11 +363,19 @@ namespace OC
             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
         {
@@ -398,10 +443,17 @@ namespace OC
         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};
@@ -426,11 +478,19 @@ namespace OC
             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
         {
@@ -441,11 +501,17 @@ namespace OC
         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};
@@ -470,12 +536,21 @@ namespace OC
             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
         {
@@ -502,9 +577,15 @@ namespace OC
         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};
@@ -528,11 +609,18 @@ namespace OC
             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
         {
@@ -563,9 +651,16 @@ namespace OC
         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};
@@ -601,12 +696,21 @@ namespace OC
             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
         {
@@ -669,9 +773,15 @@ namespace OC
         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};
 
@@ -698,8 +808,13 @@ namespace OC
             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)
index 9a17833..c5f1773 100644 (file)
@@ -70,6 +70,55 @@ namespace OC
                                                     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,
@@ -110,7 +159,7 @@ namespace OC
             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
                     deviceInfoHandler, QoS);
         }
-
+#endif
 
         OCStackResult registerResource(OCResourceHandle& resourceHandle,
                                                 std::string& resourceURI,
@@ -189,6 +238,26 @@ namespace OC
             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)
@@ -205,7 +274,7 @@ namespace OC
             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
                                                 resourceType, presenceHandler);
         }
-
+#endif
         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
         {
             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
index 9d9ae52..e4eda8e 100644 (file)
@@ -138,6 +138,64 @@ namespace OC
                             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,
@@ -168,6 +226,7 @@ namespace OC
                                             const std::string& resourceName,
                                             FindCallback resourceHandler, QualityOfService QoS)
     {
+
         return checked_guard(m_client, &IClientWrapper::ListenForResource,
                              host, resourceName, resourceHandler, QoS);
     }
@@ -188,6 +247,8 @@ namespace OC
                              host, deviceURI, deviceInfoHandler, QoS);
     }
 
+#endif
+
     OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
                                             std::string& resourceURI,
                                             const std::string& resourceTypeName,
@@ -291,6 +352,26 @@ namespace OC
         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)
@@ -304,8 +385,10 @@ namespace OC
                                             SubscribeCallback presenceHandler)
     {
         return checked_guard(m_client, &IClientWrapper::SubscribePresence,
-                             &presenceHandle, host, resourceType, presenceHandler);
+                             &presenceHandle, host, resourceType,
+                             presenceHandler);
     }
+#endif
 
     OCStackResult OCPlatform_impl::unsubscribePresence(OCPresenceHandle presenceHandle)
     {
index df5ff60..3581eee 100644 (file)
@@ -27,6 +27,29 @@ using OC::nil_guard;
 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)
@@ -46,6 +69,7 @@ OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::s
                 interfaces.empty(), m_clientWrapper.expired(), false, false);
     }
 }
+#endif
 
 OCResource::~OCResource()
 {
@@ -54,8 +78,14 @@ 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,
@@ -98,8 +128,14 @@ OCStackResult OCResource::put(const OCRepresentation& rep,
                               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,
@@ -147,8 +183,14 @@ OCStackResult OCResource::post(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,
@@ -194,8 +236,13 @@ OCStackResult OCResource::post(const std::string& resourceType,
 
 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)
@@ -215,9 +262,16 @@ OCStackResult OCResource::observe(ObserveType observeType,
         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,
@@ -265,6 +319,13 @@ std::string OCResource::uri() const
     return m_uri;
 }
 
+#ifdef CA_INT
+uint8_t OCResource::connectivityType() const
+{
+    return m_connectivityType;
+}
+#endif
+
 bool OCResource::isObservable() const
 {
     return m_isObservable;