static OCOtmEventHandler_t g_otmEventHandler = {NULL, NULL};
#endif
+#ifdef WITH_PROCESS_EVENT
+static oc_event g_ocProcessEvent = NULL;
+#endif // WITH_PROCESS_EVENT
+
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
{
*handle = resHandle;
}
+#ifdef WITH_PROCESS_EVENT
+ OCSendProcessEventSignal();
+#endif // WITH_PROCESS_EVENT
goto exit;
}
#ifdef WITH_PRESENCE
-OCStackResult OCProcessPresence()
+#ifdef WITH_PROCESS_EVENT
+OCStackResult OCProcessPresence(uint32_t *nextEventTime)
+#else // WITH_PROCESS_EVENT
+OCStackResult OCProcessPresence(void)
+#endif // !WITH_PROCESS_EVENT
{
OCStackResult result = OC_STACK_OK;
continue;
}
- if (now < cbNode->presence->timeOut[cbNode->presence->TTLlevel])
+ uint32_t timeout = cbNode->presence->timeOut[cbNode->presence->TTLlevel];
+ if (now < timeout)
{
+#ifdef WITH_PROCESS_EVENT
+ if (nextEventTime && (timeout - now) < *nextEventTime)
+ {
+ *nextEventTime = timeout - now;
+ }
+#endif // WITH_PROCESS_EVENT
continue;
}
}
#endif // WITH_PRESENCE
+#ifdef WITH_PROCESS_EVENT
+OCStackResult OCProcess(void)
+{
+ uint32_t nextEventTime;
+ return OCProcessEvent(&nextEventTime);
+}
+
+OCStackResult OCProcessEvent(uint32_t *nextEventTime)
+{
+ if (stackState == OC_STACK_UNINITIALIZED)
+ {
+ OIC_LOG(ERROR, TAG, "OCProcess has failed. ocstack is not initialized");
+ return OC_STACK_ERROR;
+ }
+
+ *nextEventTime = UINT32_MAX;
+
+#ifdef WITH_PRESENCE
+ OCProcessPresence(nextEventTime);
+ OIC_LOG_V(INFO, TAG, "OCProcessPresence next event time : %u", *nextEventTime);
+#endif
+ CAHandleRequestResponse();
+
+// TODO
+#ifdef ROUTING_GATEWAY
+ RMProcess(nextEventTime);
+#endif
+
+#ifdef TCP_ADAPTER
+ OCProcessKeepAlive(nextEventTime);
+ OIC_LOG_V(INFO, TAG, "OCProcessKeepAlive next event time : %u", *nextEventTime);
+#endif
+ return OC_STACK_OK;
+}
+
+void OCRegisterProcessEvent(oc_event event)
+{
+ g_ocProcessEvent = event;
+ CARegisterProcessEvent(event);
+}
+
+void OCSendProcessEventSignal(void)
+{
+ if (g_ocProcessEvent)
+ {
+ oc_event_signal(g_ocProcessEvent);
+ }
+}
+#else // WITH_PROCESS_EVENT
+
OCStackResult OCProcess()
{
if (stackState == OC_STACK_UNINITIALIZED)
#endif
return OC_STACK_OK;
}
+#endif // !WITH_PROCESS_EVENT
#ifdef WITH_PRESENCE
OCStackResult OCStartPresence(const uint32_t ttl)
void OCDefaultAdapterStateChangedHandler(CATransportAdapter_t adapter, bool enabled)
{
OIC_LOG(DEBUG, TAG, "OCDefaultAdapterStateChangedHandler");
-
+
OC_UNUSED(adapter);
OC_UNUSED(enabled);
}