[CA Integration] Pass connectivity type on which response is received
authorVijay <vijay.s.kesavan@intel.com>
Thu, 25 Dec 2014 04:26:28 +0000 (20:26 -0800)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Thu, 25 Dec 2014 07:24:33 +0000 (07:24 +0000)
Change-Id: I2f8377ca88a79f9502465a40c5003505e5001ec6
Signed-off-by: Vijay <vijay.s.kesavan@intel.com>
resource/csdk/makefile
resource/csdk/stack/include/ocstack.h
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.h
resource/csdk/stack/src/ocstack.c

index 540ea2e..3504657 100644 (file)
@@ -125,9 +125,10 @@ INC_DIRS   += -I$(CONNECTIVITY_INC)
 INC_DIRS       += -I$(CONNECTIVITY_DIR)/api
 
 # TODO-CA Remove -fstack-protector-all before merging to master
-CC_FLAGS.debug         := -O0 -g3 -Wall -fstack-protector-all -c -fmessage-length=0 -pedantic -fpic -DTB_LOG
+# TODO-CA Remove CA_INT flag after CA merging is finalized
+CC_FLAGS.debug         := -O0 -g3 -Wall -fstack-protector-all -c -fmessage-length=0 -pedantic -fpic -DTB_LOG -DCA_INT
 # TODO-CA Remove -fstack-protector-all before merging to master
-CC_FLAGS.release       := -Os -Wall -fstack-protector-all -c -fmessage-length=0 -fpic
+CC_FLAGS.release       := -Os -Wall -fstack-protector-all -c -fmessage-length=0 -fpic -DCA_INT
 
 CFLAGS         += $(CC_FLAGS.$(BUILD)) $(INC_DIRS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM)
 LDLIBS         += -lcoap
index eba9044..437d596 100644 (file)
@@ -133,6 +133,18 @@ typedef enum {
     OC_COAP_ID      = (1 << 1)
 } OCTransportProtocolID;
 
+#ifdef CA_INT
+/**
+ * Adaptor types
+ */
+typedef enum {
+    OC_ETHERNET = (1 << 0),
+    OC_WIFI = (1 << 1),
+    OC_EDR = (1 << 2),
+    OC_LE = (1 << 3)
+} OCConnectivityType;
+#endif
+
 /**
  * Declares Stack Results & Errors
  */
@@ -266,6 +278,10 @@ typedef struct {
 typedef struct {
     // Address of remote server
     OCDevAddr * addr;
+    #ifdef CA_INT
+    // Indicates adaptor type on which the response was received
+    OCConnectivityType connType;
+    #endif
     // the is the result of our stack, OCStackResult should contain coap/other error codes;
     OCStackResult result;
     // If associated with observe, this will represent the sequence of notifications from server.
@@ -333,15 +349,6 @@ 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
 //-----------------------------------------------------------------------------
index 22ebc4a..f27b2f7 100644 (file)
@@ -296,16 +296,13 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
         OCDevAddrToPort((OCDevAddr *) clientResponse->addr, &remotePortNu);
 
 #ifdef CA_INT
+        std::string connectionType = getConnectivityType (clientResponse->connType);
+        OC_LOG_V(INFO, TAG, "Discovered on %s", connectionType.c_str());
+#endif
         OC_LOG_V(INFO, TAG,
                 "Device =============> Discovered %s @ %d.%d.%d.%d:%d",
                 clientResponse->resJSONPayload, remoteIpAddr[0], remoteIpAddr[1],
                 remoteIpAddr[2], remoteIpAddr[3], remotePortNu);
-#else
-        OC_LOG_V(INFO, TAG,
-                "Device =============> Discovered %s @ %d.%d.%d.%d:%d",
-                clientResponse->resJSONPayload, remoteIpAddr[0], remoteIpAddr[1],
-                remoteIpAddr[2], remoteIpAddr[3], remotePortNu);
-#endif
 
         parseClientResponse(clientResponse);
 
@@ -722,6 +719,27 @@ std::string getPortTBServer(OCClientResponse * clientResponse){
     return ss.str();
 }
 
+std::string getConnectivityType (OCConnectivityType connType)
+{
+    switch (connType)
+    {
+        case OC_ETHERNET:
+            return "Ethernet";
+
+        case OC_WIFI:
+            return "WiFi";
+
+        case OC_LE:
+            return "BLE";
+
+        case OC_EDR:
+            return "BT";
+
+        default:
+            return "Incorrect connectivity";
+    }
+}
+
 std::string getQueryStrForGetPut(OCClientResponse * clientResponse){
 
     return "/a/light";
index 96444ca..58f04fd 100644 (file)
@@ -70,6 +70,9 @@ int InitPresence();
 //----------------------------------------------------------------------------
 // Function prototype
 //----------------------------------------------------------------------------
+#ifdef CA_INT
+std::string getConnectivityType (OCConnectivityType connType);
+#endif
 
 /* call getResult in common.cpp to get the result in string format. */
 const char *getResult(OCStackResult result);
index d38b439..a4c5a57 100644 (file)
@@ -328,6 +328,9 @@ void HandleCAResponses(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_
         static OCDevAddr address;
         memcpy((void*)&address.addr, &(sa), sizeof(sa));
         response.addr = &address;
+        #ifdef CA_INT
+        response.connType = endPoint->connectivityType;
+        #endif
         response.result = CAToOCStackResult(responseInfo->result);
         response.resJSONPayload = (unsigned char*)responseInfo->info.payload;
         response.numRcvdVendorSpecificHeaderOptions = 0;