{
case OC_OBSERVER_NOT_INTERESTED:
OIC_LOG(DEBUG, TAG, "observer not interested in our notifications");
- observer = GetObserverUsingToken (token, tokenLength);
- if(observer)
+ observer = GetObserverUsingToken(token, tokenLength);
+ if (observer)
{
result = FormOCEntityHandlerRequest(&ehRequest,
0,
OC_OBSERVE_DEREGISTER,
observer->observeId,
0);
- if(result != OC_STACK_OK)
+ if (result != OC_STACK_OK)
{
return result;
}
- observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
- observer->resource->entityHandlerCallbackParam);
+
+ if (observer->resource && observer->resource->entityHandler)
+ {
+ observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
+ observer->resource->entityHandlerCallbackParam);
+ }
}
- result = DeleteObserverUsingToken (token, tokenLength);
- if(result == OC_STACK_OK)
+ result = DeleteObserverUsingToken(token, tokenLength);
+ if (result == OC_STACK_OK)
{
OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
case OC_OBSERVER_STILL_INTERESTED:
OIC_LOG(DEBUG, TAG, "observer still interested, reset the failedCount");
- observer = GetObserverUsingToken (token, tokenLength);
- if(observer)
+ observer = GetObserverUsingToken(token, tokenLength);
+ if (observer)
{
observer->forceHighQos = 0;
observer->failedCommCount = 0;
case OC_OBSERVER_FAILED_COMM:
OIC_LOG(DEBUG, TAG, "observer is unreachable");
observer = GetObserverUsingToken (token, tokenLength);
- if(observer)
+ if (observer)
{
- if(observer->failedCommCount >= MAX_OBSERVER_FAILED_COMM)
+ if (observer->failedCommCount >= MAX_OBSERVER_FAILED_COMM)
{
result = FormOCEntityHandlerRequest(&ehRequest,
0,
OC_OBSERVE_DEREGISTER,
observer->observeId,
0);
- if(result != OC_STACK_OK)
+ if (result != OC_STACK_OK)
{
return OC_STACK_ERROR;
}
- observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
- observer->resource->entityHandlerCallbackParam);
- result = DeleteObserverUsingToken (token, tokenLength);
- if(result == OC_STACK_OK)
+ if (observer->resource && observer->resource->entityHandler)
+ {
+ observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
+ observer->resource->entityHandlerCallbackParam);
+ }
+
+ result = DeleteObserverUsingToken(token, tokenLength);
+ if (result == OC_STACK_OK)
{
OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
if(result != OC_STACK_OK)
{
OIC_LOG(ERROR, TAG, "Stack initialization error");
+ TerminateScheduleResourceList();
deleteAllResources();
CATerminate();
- TerminateScheduleResourceList();
stackState = OC_STACK_UNINITIALIZED;
}
return result;
stackState = OC_STACK_UNINIT_IN_PROGRESS;
+ CAUnregisterNetworkMonitorHandler(OCDefaultAdapterStateChangedHandler,
+ OCDefaultConnectionStateChangedHandler);
+
#ifdef WITH_PRESENCE
// Ensure that the TTL associated with ANY and ALL presence notifications originating from
// here send with the code "OC_STACK_PRESENCE_STOPPED" result.
TerminateKeepAlive(myStackMode);
#endif
- // Free memory dynamically allocated for resources
- deleteAllResources();
- CATerminate();
TerminateScheduleResourceList();
// Remove all observers
DeleteObserverList();
+ // Free memory dynamically allocated for resources
+ deleteAllResources();
// Remove all the client callbacks
DeleteClientCBList();
+ // Terminate connectivity-abstraction layer.
+ CATerminate();
// De-init the SRM Policy Engine
// TODO after BeachHead delivery: consolidate into single SRMDeInit()
SRMDeInitPolicyEngine();
-
stackState = OC_STACK_UNINITIALIZED;
return OC_STACK_OK;
}