Stack sample client fix 15/21615/3
authorOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Tue, 25 Jul 2017 11:09:52 +0000 (14:09 +0300)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 22 Sep 2017 10:06:52 +0000 (10:06 +0000)
Stack sample client support old servers

Change-Id: Id9fffc3b9e73c68820b99e5fd197d742d0b19418
Signed-off-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp

index 18f154b..0af4051 100644 (file)
@@ -512,6 +512,28 @@ int parseClientResponse(OCClientResponse *clientResponse)
             }
         }
 
+        //old servers support
+        if (0 == coapSecureResource && res->secure)
+        {
+#ifdef __WITH_TLS__
+            if (WithTcp)
+            {
+                endpoint->flags = (OCTransportFlags)(endpoint->flags | OC_SECURE);
+                endpoint->adapter = OC_ADAPTER_TCP;
+                endpoint->port = res->tcpPort;
+                OIC_LOG_V(INFO, TAG, "TLS port: %d", endpoint->port);
+            }
+            else
+#endif
+            {
+                endpoint->port = res->port;
+                endpoint->flags = (OCTransportFlags)(endpoint->flags | OC_SECURE);
+                endpoint->adapter = OC_ADAPTER_IP;
+                OIC_LOG_V(INFO, TAG, "DTLS port: %d", endpoint->port);
+            }
+            coapSecureResource = 1;
+        }
+
         OIC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
 
         // If we discovered a secure resource, exit from here
@@ -525,4 +547,3 @@ int parseClientResponse(OCClientResponse *clientResponse)
 
     return 0;
 }
-