1 /* ****************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * This file contains the Internal APIs for KeepAlive Mechanism.
24 * In order to ensure that the connection between an OIC Devices,
25 * when using CoAP over TCP, OIC Device should send application layer
28 #ifndef KEEP_ALIVE__INTERNAL_H_
29 #define KEEP_ALIVE__INTERNAL_H_
32 #include "ocserverrequest.h"
33 #include "ocresource.h"
41 * Name of resource type.
43 #define KEEPALIVE_RESOURCE_TYPE_NAME "oic.wk.ping"
46 * Name of resource interface.
48 #define KEEPALIVE_RESOURCE_INTF_NAME "oic.if.rw"
51 * URI of the resource.
53 #define KEEPALIVE_RESOURCE_URI "/oic/ping"
56 * Initialize the KeepAlive.
57 * @param[in] mode Host mode of operation.
58 * @return ::OC_STACK_OK or Appropriate error code.
60 OCStackResult OCInitializeKeepAlive(OCMode mode);
63 * Terminates the KeepAlive.
64 * @param[in] mode Host mode of operation.
65 * @return ::OC_STACK_OK or Appropriate error code.
67 OCStackResult OCTerminateKeepAlive(OCMode mode);
70 * API to handle the Response payload.
71 * @param[in] endpoint RemoteEndpoint which sent the packet.
72 * @param[in] payload Encoded response payload.
73 * @return ::OC_STACK_OK or Appropriate error code.
75 OCStackResult OCHandleKeepAliveResponse(const CAEndpoint_t *endPoint, const OCPayload *payload);
78 * Process the KeepAlive timer to send ping message to OIC Server.
80 void OCProcessKeepAlive();
83 * This API will be called from RI layer whenever there is a request for KeepAlive.
85 * @param[in] request Received request information.
86 * @param[in] resource Resource handle used for sending the response.
87 * @return ::OC_STACK_OK or Appropriate error code.
89 OCStackResult OCHandleKeepAliveRequest(OCServerRequest *request,
90 const OCResource *resource);
93 * API to handle the connected device for KeepAlive.
94 * @param[in] endpoint Remote endpoint information.
95 * @param[in] isConnected Whether keepalive message needs to be sent.
96 * @param[in] isClient Host Mode of Operation.
98 void OCHandleKeepAliveConnCB(const CAEndpoint_t *endpoint, bool isConnected, bool isClient);
104 #endif // KEEP_ALIVE__INTERNAL_H_