/**
* Initialize the KeepAlive.
+ * @param[in] mode Host mode of operation.
* @return ::OC_STACK_OK or Appropriate error code.
*/
-OCStackResult InitializeKeepAlive();
+OCStackResult InitializeKeepAlive(OCMode mode);
/**
* Terminates the KeepAlive.
+ * @param[in] mode Host mode of operation.
* @return ::OC_STACK_OK or Appropriate error code.
*/
-OCStackResult TerminateKeepAlive();
+OCStackResult TerminateKeepAlive(OCMode mode);
/**
* Process the KeepAlive timer to send ping message to OIC Server.
*/
static OCStackResult RemoveKeepAliveEntry(const CAEndpoint_t *endpoint);
-OCStackResult InitializeKeepAlive()
+OCStackResult InitializeKeepAlive(OCMode mode)
{
OIC_LOG(DEBUG, TAG, "InitializeKeepAlive IN");
if (g_isKeepAliveInitialized)
return OC_STACK_OK;
}
- // Create the KeepAlive Resource[/oic/ping].
- OCStackResult result = CreateKeepAliveResource();
- if (OC_STACK_OK != result)
+ if (OC_CLIENT != mode)
{
- OIC_LOG_V(ERROR, TAG, "CreateKeepAliveResource failed[%d]", result);
- return result;
+ // Create the KeepAlive Resource[/oic/ping].
+ OCStackResult result = CreateKeepAliveResource();
+ if (OC_STACK_OK != result)
+ {
+ OIC_LOG_V(ERROR, TAG, "CreateKeepAliveResource failed[%d]", result);
+ return result;
+ }
}
if (!g_keepAliveConnectionTable)
if (NULL == g_keepAliveConnectionTable)
{
OIC_LOG(ERROR, TAG, "Creating KeepAlive Table failed");
- TerminateKeepAlive();
+ TerminateKeepAlive(mode);
return OC_STACK_ERROR;
}
}
return OC_STACK_OK;
}
-OCStackResult TerminateKeepAlive()
+OCStackResult TerminateKeepAlive(OCMode mode)
{
OIC_LOG(DEBUG, TAG, "TerminateKeepAlive IN");
if (!g_isKeepAliveInitialized)
return OC_STACK_ERROR;
}
- // Delete the KeepAlive Resource[/oic/ping].
- OCStackResult result = DeleteKeepAliveResource();
- if (OC_STACK_OK != result)
+ if (OC_CLIENT != mode)
{
- OIC_LOG_V(ERROR, TAG, "DeleteKeepAliveResource failed[%d]", result);
- return result;
+ // Delete the KeepAlive Resource[/oic/ping].
+ OCStackResult result = DeleteKeepAliveResource();
+ if (OC_STACK_OK != result)
+ {
+ OIC_LOG_V(ERROR, TAG, "DeleteKeepAliveResource failed[%d]", result);
+ return result;
+ }
}
if (NULL != g_keepAliveConnectionTable)