Revert "Change default vaule of acceptVersion and acceptFormat.". This change has...
authorZiran Sun <ziran.sun@samsung.com>
Mon, 3 Apr 2017 12:55:09 +0000 (12:55 +0000)
committerZiran Sun <ziran.sun@samsung.com>
Mon, 3 Apr 2017 14:54:02 +0000 (14:54 +0000)
This reverts commit feba13f7d0d8a4226e526c092eb050855c2caee8.

Change-Id: I64ff4508bb4583f70f5e6b3d88519b6ba8460e9d
Signed-off-by: Ziran Sun <ziran.sun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18455
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp
resource/csdk/stack/src/ocstack.c

index 04aac41..daef640 100755 (executable)
@@ -1454,10 +1454,6 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
         {
             OIC_LOG(DEBUG, ANALYZER_TAG, "Payload Format = [CA_FORMAT_APPLICATION_CBOR]");
         }
-        else if (CA_FORMAT_APPLICATION_VND_OCF_CBOR == info->payloadFormat)
-        {
-            OIC_LOG(DEBUG, ANALYZER_TAG, "Payload Format = [CA_FORMAT_APPLICATION_VND_OCF_CBOR]");
-        }
         else
         {
             OIC_LOG_V(DEBUG, ANALYZER_TAG, "Payload Format = [%d]", info->payloadFormat);
index db1119c..4b9bfdf 100644 (file)
@@ -44,7 +44,6 @@ samples_env.PrependUnique(CPPPATH=[
     '../../../../include',
     '../../../../stack/include',
     '../../../../connectivity/api',
-    '../../../../connectivity/lib/libcoap-4.1.1/include/coap',
     '../../../../security/include',
     '../../../../../../extlibs/boost/boost',
     '../../../../../oc_logger/include',
index 72857f5..1b39e28 100755 (executable)
@@ -34,7 +34,6 @@
 #include <sstream>
 #include <getopt.h>
 #include "ocstack.h"
-#include "pdu.h"
 #include "logger.h"
 #include "occlient.h"
 #include "ocpayload.h"
@@ -403,6 +402,14 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
     {
         OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
 
+        if (OC_STACK_NOT_ACCEPTABLE == clientResponse->result)
+        {
+            // Re-initiate discovery with OIC format. This is applicable for the case that
+            // a OCF 1.x client speaks to a OIC 1.1 server.
+            InitDiscovery(OC_LOW_QOS, 0);
+            return OC_STACK_KEEP_TRANSACTION;
+        }
+
         std::string connectionType = getConnectivityType (clientResponse->connType);
         OIC_LOG_V(INFO, TAG, "Discovered on %s", connectionType.c_str());
         OIC_LOG_V(INFO, TAG,
@@ -873,10 +880,15 @@ int InitDiscovery(OCQualityOfService qos, uint8_t withVendorSpecificHeaderOption
         memset(options, 0, sizeof(OCHeaderOption) * MAX_HEADER_OPTIONS);
         size_t numOptions = 0;
 
-        uint8_t format = COAP_MEDIATYPE_APPLICATION_CBOR;
+        uint16_t format = COAP_MEDIATYPE_APPLICATION_VND_OCF_CBOR;
         uint16_t optionID = CA_OPTION_ACCEPT;
         OCSetHeaderOption(options, &numOptions, optionID, &format, sizeof(format));
 
+        uint16_t version = 2048;
+        optionID = CA_OPTION_ACCEPT_VERSION;
+        numOptions = 1;
+        OCSetHeaderOption(options, &numOptions, optionID, &version, sizeof(version));
+
         ret = OCDoRequest(NULL, OC_REST_DISCOVER, szQueryUri, NULL, 0, CT_DEFAULT,
                               (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS,
                               &cbData, options, 2);
@@ -1095,7 +1107,7 @@ int main(int argc, char* argv[])
     }
     else
     {
-        InitDiscovery(OC_LOW_QOS, 0);
+        InitDiscovery(OC_LOW_QOS, 1);
     }
 
     // Break from loop with Ctrl+C
index c597ce5..2b4e55d 100755 (executable)
@@ -612,8 +612,8 @@ static OCStackResult OCSendRequest(const CAEndpoint_t *object, CARequestInfo_t *
     }
 #endif
 
-    uint16_t acceptVersion = OC_SPEC_VERSION_VALUE;
-    CAPayloadFormat_t acceptFormat = CA_FORMAT_APPLICATION_VND_OCF_CBOR;
+    uint16_t acceptVersion = 0;
+    CAPayloadFormat_t acceptFormat = CA_FORMAT_APPLICATION_CBOR;
     // Check settings of version option and content format.
     if (requestInfo->info.numOptions > 0 && requestInfo->info.options)
     {
@@ -645,11 +645,17 @@ static OCStackResult OCSendRequest(const CAEndpoint_t *object, CARequestInfo_t *
     }
 
     requestInfo->info.acceptFormat = acceptFormat;
-    if (CA_FORMAT_APPLICATION_CBOR == acceptFormat && acceptVersion)
+    if (CA_FORMAT_APPLICATION_VND_OCF_CBOR == acceptFormat)
     {
-        acceptVersion = 0;
+        if (!acceptVersion)
+        {
+            requestInfo->info.acceptVersion = OC_SPEC_VERSION_VALUE;
+        }
+        else
+        {
+            requestInfo->info.acceptVersion = acceptVersion;
+        }
     }
-    requestInfo->info.acceptVersion = acceptVersion;
 
     CAResult_t result = CASendRequest(object, requestInfo);
     if (CA_STATUS_OK != result)
@@ -2325,7 +2331,6 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
     {
         serverRequest.acceptVersion = requestInfo->info.acceptVersion;
     }
-
     if (requestInfo->info.type == CA_MSG_CONFIRM)
     {
         serverRequest.qos = OC_HIGH_QOS;
@@ -3251,8 +3256,8 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
 
     if (payload)
     {
-        uint16_t payloadVersion = OC_SPEC_VERSION_VALUE;
-        CAPayloadFormat_t payloadFormat = CA_FORMAT_APPLICATION_VND_OCF_CBOR;
+        uint16_t payloadVersion = 0;
+        CAPayloadFormat_t payloadFormat = CA_FORMAT_APPLICATION_CBOR;
         // Check version option settings
         if (numOptions > 0 && options)
         {
@@ -3282,12 +3287,17 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
         }
 
         requestInfo.info.payloadFormat = payloadFormat;
-        if (CA_FORMAT_APPLICATION_CBOR == payloadFormat && payloadVersion)
+        if (CA_FORMAT_APPLICATION_VND_OCF_CBOR == payloadFormat)
         {
-            payloadVersion = 0;
+            if (!payloadVersion)
+            {
+                requestInfo.info.payloadVersion = OC_SPEC_VERSION_VALUE;
+            }
+            else
+            {
+                requestInfo.info.payloadVersion = payloadVersion;
+            }
         }
-        requestInfo.info.payloadVersion = payloadVersion;
-
         if ((result =
             OCConvertPayload(payload, CAToOCPayloadFormat(requestInfo.info.payloadFormat),
                             &requestInfo.info.payload, &requestInfo.info.payloadSize))