1. Added support for sequence number starting from 1.
2. When sequence number is 1, client treats it as a normal response
rather than de-registration response.
3. Correct default sequence number value to be valid.
JIRA Issue: https://jira.iotivity.org/browse/IOT-1195
Change-Id: I2ce68d70ff5f8f0cce98234a7dbda566b8085a61
Signed-off-by: Ziran Sun <ziran.sun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9519
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Mushfiqul Islam <i.mushfiq@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
/** The coap scheme */
#define OC_COAP_SCHEME "coap://"
-/** the first outgoing sequence number will be 2*/
-#define OC_OFFSET_SEQUENCE_NUMBER (1)
+/** the first outgoing sequence number will be 1*/
+#define OC_OFFSET_SEQUENCE_NUMBER (0)
/**
* This structure will be created in occoap and passed up the stack on the server side.
{
OIC_LOG(INFO, TAG, "Removed observer successfully");
request->observeResult = OC_STACK_OK;
+ // There should be no observe option header for de-registration response.
+ // Set as an invalid value here so we can detect it later and remove the field in response.
+ request->observationOption = MAX_SEQUENCE_NUMBER + 1;
}
else
{
#include "ocstack.h"
#include "ocserverrequest.h"
#include "ocresourcehandler.h"
+#include "ocobserve.h"
#include "oic_malloc.h"
#include "oic_string.h"
#include "ocpayload.h"
memcpy(responseInfo.info.token, serverRequest->requestToken, serverRequest->tokenLength);
responseInfo.info.tokenLength = serverRequest->tokenLength;
- // De-register observe option should not be included in the response header
- if((serverRequest->observeResult == OC_STACK_OK) && (serverRequest->observationOption != OC_OBSERVE_DEREGISTER))
+ if((serverRequest->observeResult == OC_STACK_OK)&&
+ (serverRequest->observationOption != MAX_SEQUENCE_NUMBER + 1))
{
responseInfo.info.numOptions = ehResponse->numSendVendorSpecificHeaderOptions + 1;
}
OCClientResponse response =
{.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
- response.sequenceNumber = -1;
+ response.sequenceNumber = MAX_SEQUENCE_NUMBER + 1;
CopyEndpointToDevAddr(endPoint, &response.devAddr);
FixUpClientResponse(&response);
response.resourceUri = responseInfo->info.resourceUri;
if (cbNode->method == OC_REST_OBSERVE &&
response.sequenceNumber > OC_OFFSET_SEQUENCE_NUMBER &&
+ cbNode->sequenceNumber <= MAX_SEQUENCE_NUMBER &&
response.sequenceNumber <= cbNode->sequenceNumber)
{
OIC_LOG_V(INFO, TAG, "Received stale notification. Number :%d",
#include "OCPlatform.h"
#include "OCApi.h"
+#define maxSequenceNumber 0xFFFFFF
+
using namespace OC;
static const char* SVR_DB_FILE_NAME = "./oic_svr_db_client.dat";
{
try
{
- if(eCode == OC_STACK_OK && sequenceNumber != -1)
+ if(eCode == OC_STACK_OK && sequenceNumber != maxSequenceNumber + 1)
{
if(sequenceNumber == OC_OBSERVE_REGISTER)
{
std::thread exec(context->callback, serverHeaderOptions, attrs,
result, sequenceNumber);
exec.detach();
- if (sequenceNumber == OC_OBSERVE_DEREGISTER)
- {
- return OC_STACK_DELETE_TRANSACTION;
- }
+
return OC_STACK_KEEP_TRANSACTION;
}