Commit fd60586e authored by Ziran Sun's avatar Ziran Sun Committed by Kevin Kane

Resource: Change default vaule of acceptVersion and acceptFormat.

Change-Id: Ic63cb9217c9a10b3e38ecd244d12b9cfc552d4ad
Signed-off-by: default avatarZiran Sun <ziran.sun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19061Reviewed-by: default avatarPhil Coval <philippe.coval@osg.samsung.com>
Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: default avatarTodd Malsbary <todd.malsbary@intel.com>
Reviewed-by: default avatarKevin Kane <kkane@microsoft.com>
parent 173d935f
......@@ -1456,6 +1456,10 @@ 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);
......
......@@ -29,6 +29,15 @@ with_ra = samples_env.get('WITH_RA')
######################################################################
# Build flags
######################################################################
with_upstream_libcoap = samples_env.get('WITH_UPSTREAM_LIBCOAP')
if with_upstream_libcoap == '1':
# For bring up purposes only, we manually copy the forked version to where
# the unforked version is downloaded.
samples_env.AppendUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
else:
# For bring up purposes only, the forked version will live here.
samples_env.AppendUnique(CPPPATH=['#resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
samples_env.PrependUnique(CPPPATH=[
'../../../../logger/include',
'../../../../include',
......
......@@ -34,6 +34,7 @@
#include <sstream>
#include <getopt.h>
#include "ocstack.h"
#include <coap/pdu.h>
#include "logger.h"
#include "occlient.h"
#include "ocpayload.h"
......@@ -402,14 +403,6 @@ 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,
......@@ -880,15 +873,10 @@ int InitDiscovery(OCQualityOfService qos, uint8_t withVendorSpecificHeaderOption
memset(options, 0, sizeof(OCHeaderOption) * MAX_HEADER_OPTIONS);
size_t numOptions = 0;
uint16_t format = COAP_MEDIATYPE_APPLICATION_VND_OCF_CBOR;
uint8_t format = COAP_MEDIATYPE_APPLICATION_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);
......@@ -1107,7 +1095,7 @@ int main(int argc, char* argv[])
}
else
{
InitDiscovery(OC_LOW_QOS, 1);
InitDiscovery(OC_LOW_QOS, 0);
}
// Break from loop with Ctrl+C
......
......@@ -618,8 +618,8 @@ static OCStackResult OCSendRequest(const CAEndpoint_t *object, CARequestInfo_t *
}
#endif
uint16_t acceptVersion = 0;
CAPayloadFormat_t acceptFormat = CA_FORMAT_APPLICATION_CBOR;
uint16_t acceptVersion = OC_SPEC_VERSION_VALUE;
CAPayloadFormat_t acceptFormat = CA_FORMAT_APPLICATION_VND_OCF_CBOR;
// Check settings of version option and content format.
if (requestInfo->info.numOptions > 0 && requestInfo->info.options)
{
......@@ -651,17 +651,11 @@ static OCStackResult OCSendRequest(const CAEndpoint_t *object, CARequestInfo_t *
}
requestInfo->info.acceptFormat = acceptFormat;
if (CA_FORMAT_APPLICATION_VND_OCF_CBOR == acceptFormat)
if (CA_FORMAT_APPLICATION_CBOR == acceptFormat && acceptVersion)
{
if (!acceptVersion)
{
requestInfo->info.acceptVersion = OC_SPEC_VERSION_VALUE;
}
else
{
requestInfo->info.acceptVersion = acceptVersion;
}
acceptVersion = 0;
}
requestInfo->info.acceptVersion = acceptVersion;
CAResult_t result = CASendRequest(object, requestInfo);
if (CA_STATUS_OK != result)
......@@ -2347,6 +2341,7 @@ 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;
......@@ -3291,8 +3286,8 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
if (payload)
{
uint16_t payloadVersion = 0;
CAPayloadFormat_t payloadFormat = CA_FORMAT_APPLICATION_CBOR;
uint16_t payloadVersion = OC_SPEC_VERSION_VALUE;
CAPayloadFormat_t payloadFormat = CA_FORMAT_APPLICATION_VND_OCF_CBOR;
// Check version option settings
if (numOptions > 0 && options)
{
......@@ -3322,17 +3317,12 @@ OCStackResult OCDoRequest(OCDoHandle *handle,
}
requestInfo.info.payloadFormat = payloadFormat;
if (CA_FORMAT_APPLICATION_VND_OCF_CBOR == payloadFormat)
if (CA_FORMAT_APPLICATION_CBOR == payloadFormat && payloadVersion)
{
if (!payloadVersion)
{
requestInfo.info.payloadVersion = OC_SPEC_VERSION_VALUE;
}
else
{
requestInfo.info.payloadVersion = payloadVersion;
}
payloadVersion = 0;
}
requestInfo.info.payloadVersion = payloadVersion;
if ((result =
OCConvertPayload(payload, CAToOCPayloadFormat(requestInfo.info.payloadFormat),
&requestInfo.info.payload, &requestInfo.info.payloadSize))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment