/** The coap scheme */
#define OC_COAP_SCHEME "coap://"
-/** the first outgoing sequence number will be 5*/
-#define OC_OFFSET_SEQUENCE_NUMBER (4)
+/** the first outgoing sequence number will be 2*/
+#define OC_OFFSET_SEQUENCE_NUMBER (1)
/**
* This structure will be created in occoap and passed up the stack on the server side.
}
else
{
+ result = OC_STACK_OK;
+
// The error in observeResult for the request will be used when responding to this
// request by omitting the observation option/sequence number.
request->observeResult = OC_STACK_ERROR;
OIC_LOG(ERROR, TAG, "Observer Addition failed");
ehFlag = OC_REQUEST_FLAG;
- FindAndDeleteServerRequest(request);
- goto exit;
}
}
}
else
{
+ result = OC_STACK_OK;
request->observeResult = OC_STACK_ERROR;
OIC_LOG(ERROR, TAG, "Observer Removal failed");
- FindAndDeleteServerRequest(request);
- goto exit;
}
}
else
memcpy(responseInfo.info.token, serverRequest->requestToken, serverRequest->tokenLength);
responseInfo.info.tokenLength = serverRequest->tokenLength;
- if(serverRequest->observeResult == OC_STACK_OK)
+ // De-register observe option should not be included in the response header
+ if((serverRequest->observeResult == OC_STACK_OK) && (serverRequest->observationOption != OC_OBSERVE_DEREGISTER))
{
responseInfo.info.numOptions = ehResponse->numSendVendorSpecificHeaderOptions + 1;
}
OCClientResponse response =
{.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
- response.sequenceNumber = OC_OBSERVE_NO_OPTION;
+ response.sequenceNumber = -1;
CopyEndpointToDevAddr(endPoint, &response.devAddr);
FixUpClientResponse(&response);
response.resourceUri = responseInfo->info.resourceUri;
{
try
{
- if(eCode == OC_STACK_OK && sequenceNumber != OC_OBSERVE_NO_OPTION)
+ if(eCode == OC_STACK_OK && sequenceNumber != -1)
{
if(sequenceNumber == OC_OBSERVE_REGISTER)
{
std::cout << "Observe registration action is successful" << std::endl;
}
- else if(sequenceNumber == OC_OBSERVE_DEREGISTER)
- {
- std::cout << "Observe De-registration action is successful" << std::endl;
- }
std::cout << "OBSERVE RESULT:"<<std::endl;
std::cout << "\tSequenceNumber: "<< sequenceNumber << std::endl;
}
else
{
- if(sequenceNumber == OC_OBSERVE_NO_OPTION)
+ if(eCode == OC_STACK_OK)
{
- std::cout << "Observe registration or de-registration action is failed" << std::endl;
+ std::cout << "Observe registration failed or de-registration action failed/succeeded" << std::endl;
}
else
{
OC::ModeType::Both,
"0.0.0.0",
0,
- OC::QualityOfService::LowQos,
+ OC::QualityOfService::HighQos,
&ps
};