{
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);
'../../../../include',
'../../../../stack/include',
'../../../../connectivity/api',
- '../../../../connectivity/lib/libcoap-4.1.1/include/coap',
'../../../../security/include',
'../../../../../../extlibs/boost/boost',
'../../../../../oc_logger/include',
#include <sstream>
#include <getopt.h>
#include "ocstack.h"
-#include "pdu.h"
#include "logger.h"
#include "occlient.h"
#include "ocpayload.h"
{
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,
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);
}
else
{
- InitDiscovery(OC_LOW_QOS, 0);
+ InitDiscovery(OC_LOW_QOS, 1);
}
// Break from loop with Ctrl+C
}
#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)
{
}
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)
{
serverRequest.acceptVersion = requestInfo->info.acceptVersion;
}
-
if (requestInfo->info.type == CA_MSG_CONFIRM)
{
serverRequest.qos = OC_HIGH_QOS;
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)
{
}
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))