Enabled EDR and BLE adapter in RI
authorvimala.v <vimala.v@samsung.com>
Mon, 13 Jul 2015 11:17:43 +0000 (16:47 +0530)
committerErich Keane <erich.keane@intel.com>
Thu, 16 Jul 2015 16:17:57 +0000 (16:17 +0000)
- Added EDR and BLE connectivity types for sending Response.
- Parsing of EDR and BLE adapter address in Request URI.

Verification of IP and EDR adapter was done in Tizen with the above changes.

Change-Id: I70ebc099497ab744c4d822e65c94e0610d338e13
Signed-off-by: vimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1634
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c

index 2cd2976..3f9c2b0 100644 (file)
@@ -535,9 +535,9 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     }
 
     #ifdef WITH_PRESENCE
-    //TODO: Add other connectivity types to CAConnTypes[] when enabled
-    CATransportAdapter_t CAConnTypes[] = {CA_ADAPTER_IP};
-    const char * connTypes[] = {"IP"};
+    CATransportAdapter_t CAConnTypes[] = {CA_ADAPTER_IP, CA_ADAPTER_GATT_BTLE,
+                                          CA_ADAPTER_RFCOMM_BTEDR};
+    const char * connTypes[] = {"ip" , "ble",  "edr"};
     int size = sizeof(CAConnTypes)/ sizeof(CATransportAdapter_t);
     CATransportAdapter_t adapter = responseEndpoint.adapter;
     CAResult_t caResult = CA_STATUS_FAILED;
index 133c903..0714b53 100644 (file)
@@ -1723,48 +1723,67 @@ static OCStackResult ParseRequestUri(const char *fullUri,
 
     // processs url prefix, if any
     size_t urlLen = slash - start;
+    // port
+    uint16_t port = 0;
+    size_t len = 0;
     if (urlLen && devAddr)
     {   // construct OCDevAddr
-        if (start[0] == '[')
-        {   // ipv6 address
-            char *close = strchr(++start, ']');
-            if (!close || close > slash)
+        if (OC_ADAPTER_IP == adapter)
+        {
+            if (start[0] == '[')
+            {   // ipv6 address
+                char *close = strchr(++start, ']');
+                if (!close || close > slash)
+                {
+                    return OC_STACK_INVALID_URI;
+                }
+                end = close;
+                if (close[1] == ':')
+                {
+                    colon = close + 1;
+                }
+            }
+            else
+            {   // ipv4 address
+                end = slash;
+                colon = strchr(start, ':');
+                end = (colon && colon < slash) ? colon : slash;
+            }
+            len = end - start;
+            if (len >= sizeof(da->addr))
             {
                 return OC_STACK_INVALID_URI;
             }
-            end = close;
-            if (close[1] == ':')
+            // use standard multicast port
+            if (colon && colon < slash)
             {
-                colon = close + 1;
+                for (colon++; colon < slash; colon++)
+                {
+                    char c = colon[0];
+                    if (c < '0' || c > '9')
+                    {
+                        return OC_STACK_INVALID_URI;
+                    }
+                    port = 10 * port + c - '0';
+                }
             }
         }
         else
-        {   // ipv4 address
+        {
+            /**
+             * This is for Non-IP adapters(EDR and BLE).
+             * The address will be between "//" and "/" in the request URI.
+             * [Ex. coap://AB:BC:CD:DE:EF:FG/resource_uri]
+             */
             end = slash;
-            colon = strchr(start, ':');
-            end = (colon && colon < slash) ? colon : slash;
         }
-        size_t len = end - start;
+
+        len = end - start;
         if (len >= sizeof(da->addr))
         {
             return OC_STACK_INVALID_URI;
         }
 
-        // port
-        uint16_t port = 0;      // use standard multicast port
-        if (colon && colon < slash)
-        {
-            for (colon++; colon < slash; colon++)
-            {
-                char c = colon[0];
-                if (c < '0' || c > '9')
-                {
-                    return OC_STACK_INVALID_URI;
-                }
-                port = 10 * port + c - '0';
-            }
-        }
-
         da = (OCDevAddr *)OICCalloc(sizeof (OCDevAddr), 1);
         if (!da)
         {