OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OIC_LOG_V(INFO, TAG, "Callback Context for OBSERVE notification recvd successfully %d",
- gNumObserveNotifies);
- OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OIC_LOG(INFO, TAG, ("=============> Obs Response"));
- gNumObserveNotifies++;
- if (gNumObserveNotifies > 15) //large number to test observing in DELETE case.
+ if (clientResponse->result == OC_STACK_OK)
{
- if (TestCase == TEST_OBS_REQ_NON || TestCase == TEST_OBS_REQ_CON)
+ OIC_LOG_V(INFO, TAG, "Callback Context for OBSERVE notification recvd successfully %d",
+ gNumObserveNotifies);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Obs Response"));
+ gNumObserveNotifies++;
+
+ if (gNumObserveNotifies > 15) //large number to test observing in DELETE case.
{
- OIC_LOG(ERROR, TAG, "Cancelling with LOW QOS");
- if (OCCancel (handle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
+ if (TestCase == TEST_OBS_REQ_NON || TestCase == TEST_OBS_REQ_CON)
{
- OIC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Cancelling with LOW QOS");
+ if (OCCancel (handle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
+ }
+ return OC_STACK_DELETE_TRANSACTION;
}
- return OC_STACK_DELETE_TRANSACTION;
- }
- else if (TestCase == TEST_OBS_REQ_NON_CANCEL_IMM)
- {
- OIC_LOG(ERROR, TAG, "Cancelling with HIGH QOS");
- if (OCCancel (handle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK)
+ else if (TestCase == TEST_OBS_REQ_NON_CANCEL_IMM)
{
- OIC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Cancelling with HIGH QOS");
+ if (OCCancel (handle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
+ }
}
}
}
if(cbNode)
{
OIC_LOG(INFO, TAG, "There is a cbNode associated with the response token");
+ uint32_t obsHeaderOpt = OC_OBSERVE_NO_OPTION;
+ uint8_t tempNumOpt = responseInfo->info.numOptions;
+ GetObserveHeaderOption(&obsHeaderOpt, responseInfo->info.options,
+ &tempNumOpt);
+
if(responseInfo->result == CA_EMPTY)
{
OIC_LOG(INFO, TAG, "Receiving A ACK/RESET for this token");
cbNode->handle, &response);
FindAndDeleteClientCB(cbNode);
}
+ else if ((cbNode->method == OC_REST_OBSERVE || cbNode->method == OC_REST_OBSERVE_ALL)
+ && (responseInfo->result == CA_CONTENT)
+ && (obsHeaderOpt == OC_OBSERVE_NO_OPTION))
+ {
+ OCClientResponse response =
+ {.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
+ CopyEndpointToDevAddr(endPoint, &response.devAddr);
+ FixUpClientResponse(&response);
+ response.resourceUri = responseInfo->info.resourceUri;
+ memcpy(response.identity.id, responseInfo->info.identity.id,
+ sizeof (response.identity.id));
+ response.identity.id_length = responseInfo->info.identity.id_length;
+ response.result = OC_STACK_UNAUTHORIZED_REQ;
+
+ cbNode->callBack(cbNode->context,
+ cbNode->handle,
+ &response);
+ FindAndDeleteClientCB(cbNode);
+ }
else
{
OIC_LOG(INFO, TAG, "This is a regular response, A client call back is found");