-/******************************************************************
+/* ****************************************************************
*
* Copyright 2014 Samsung Electronics All Rights Reserved.
*
******************************************************************/
/**
- * @file cainterface.h
- * @brief This file contains the APIs for Resource Model to use
+ * @file
+ *
+ * This file contains the APIs for Resource Model to use.
*/
-#ifndef __CA_INTERFACE_H_
-#define __CA_INTERFACE_H_
+#ifndef CA_INTERFACE_H_
+#define CA_INTERFACE_H_
/**
- * Connectivity Abstraction Interface Description APIs.
+ * Connectivity Abstraction Interface APIs.
*/
#include "cacommon.h"
+#include "casecurityinterface.h"
#ifdef __cplusplus
extern "C"
{
#endif
+#ifdef RA_ADAPTER
+
/**
- * @brief Callback function type for request delivery.
- * requestInfo contains different parameters for resource model to understand about the request.
- * @param object [OUT] Endpoint object from which the request is received. It contains endpoint
- * address based on the connectivity type.
- * @param requestInfo [OUT] Identifier which needs to be sent with request.
+ * Callback for bound JID
+ * @param[out] jid Boud Jabber Identifier.
*/
-typedef void (*CARequestCallback)(const CARemoteEndpoint_t *object,
- const CARequestInfo_t *requestInfo);
+typedef void (*CAJidBoundCallback)(char *jid);
/**
- * @brief Callback function type for response delivery.
- * responseInfor contains different parameters for resource model to understand about the request.
- * @param object [OUT] Endpoint object from which the response is received.
- * @param responseInfo [OUT] Identifier which needs to be mapped with response.
+ * CA Remote Access information for XMPP Client
+ *
*/
-typedef void (*CAResponseCallback)(const CARemoteEndpoint_t *object,
- const CAResponseInfo_t *responseInfo);
+typedef struct
+{
+ char *hostName; /**< XMPP server hostname */
+ uint16_t port; /**< XMPP server serivce port */
+ char *xmppDomain; /**< XMPP login domain */
+ char *userName; /**< login username */
+ char *password; /**< login password */
+ char *resource; /**< specific resource for login */
+ char *userJid; /**< specific JID for login */
+ CAJidBoundCallback jidBoundCallback; /**< callback when JID bound */
+} CARAInfo_t;
+#endif //RA_ADAPTER
+
+#ifdef TCP_ADAPTER
/**
- * @brief Initialize the connectivity abstraction module.
- * It will initialize adapters, thread pool and other modules based on the platform compilation options.
- *
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Callback function to pass the connection information from CA to RI.
+ * @param[out] object remote device information.
+ * @param[out] isConnected Whether keepalive message needs to be sent.
+ * @param[out] isClient Host Mode of Operation.
*/
-CAResult_t CAInitialize();
+typedef void (*CAKeepAliveConnectionCallback)(const CAEndpoint_t *object, bool isConnected,
+ bool isClient);
/**
- * @brief Terminate the connectivity abstraction module.
- * All threads, data structures are destroyed for next initializations.
+ * Register connection status changes callback to process KeepAlive.
+ * connection informations are delivered these callbacks.
+ * @param[in] ConnHandler Connection status changes callback.
*/
-void CATerminate();
+void CARegisterKeepAliveHandler(CAKeepAliveConnectionCallback ConnHandler);
+#endif
+/**
+ * Initialize the connectivity abstraction module.
+ * It will initialize adapters, thread pool and other modules based on the platform
+ * compilation options.
+ * @param[in] transportType transport type to initialize.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
+ */
+CAResult_t CAInitialize(CATransportAdapter_t transportType);
/**
- * @brief Starts listening servers.
- * This API is used by resource hosting server for listening multicast requests.
- * based on the adapters configurations , different kinds of servers are started.
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Terminate the connectivity abstraction module.
+ * All threads, data structures are destroyed for next initializations.
*/
-CAResult_t CAStartListeningServer();
+void CATerminate();
/**
- * @brief Starts discovery servers.
- * This API is used by resource required clients for listening multicast requests.
- * based on the adapters configurations , different kinds of servers are started.
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Starts listening servers.
+ * This API is used by resource hosting server for listening multicast requests.
+ * Based on the adapters configurations, different kinds of servers are started.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED
*/
-CAResult_t CAStartDiscoveryServer();
+CAResult_t CAStartListeningServer();
/**
- * @brief Register request callbacks and response callbacks.
- * requests and responses are delivered these callbacks .
- * @see CARequestCallback CAResponseCallback
- * @param ReqHandler [IN] Request callback ( for GET,PUT ..etc)
- * @param RespHandler [IN] Response Handler Callback
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Stops the server from receiving the multicast traffic. This is used by sleeping
+ * device to not receives the multicast traffic.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED
*/
-CAResult_t CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler);
+CAResult_t CAStopListeningServer();
/**
- * @brief Create a Remote endpoint if the URI is available already.
- * for FindResource-> unicast requests , this API is used.
- * FindResource(URI)-> CACreateRemoteEndpoint , CASendRequest(GET)
- * @param uri [IN] Absolute URI of the resource to be used to generate the Remote endpoint
- * for ex : coap://10.11.12.13:4545/resource_uri ( for IP)
- * coap://10:11:12:13:45:45/resource_uri ( for BT)
- * @param object [OUT ] Endpoint object which contains the above parsed data
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Starts discovery servers.
+ * This API is used by resource required clients for listening multicast requests.
+ * Based on the adapters configurations, different kinds of servers are started.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED
*/
-CAResult_t CACreateRemoteEndpoint(const CAURI_t uri, CARemoteEndpoint_t **object);
+CAResult_t CAStartDiscoveryServer();
/**
- * @brief API Destroy the remote endpoint created
- * @param object [IN] endpoint object created with CACreateRemoteEndpoint
+ * Register request callbacks and response callbacks.
+ * Requests and responses are delivered these callbacks.
+ * @param[in] ReqHandler Request callback ( for GET,PUT ..etc).
+ * @param[in] RespHandler Response Handler Callback.
+ * @param[in] ErrorHandler Error Handler Callback.
+ * @see CARequestCallback
+ * @see CAResponseCallback
+ * @see CAErrorCallback
*/
-void CADestroyRemoteEndpoint(CARemoteEndpoint_t *object);
+void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
+ CAErrorCallback ErrorHandler);
/**
- * @brief Generating the token for the requests/response.
- * Token memory is created and destroyed by the calle.
- * @param token [OUT] token for the request
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Create an endpoint description.
+ * @param[in] flags how the adapter should be used.
+ * @param[in] adapter which adapter to use.
+ * @param[in] addr string representation of address.
+ * @param[in] port port (for IP_ADAPTER).
+ * @param[out] object Endpoint which contains the above.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_INVALID_PARAM
+ * @remark The created Remote endpoint can be freed using CADestroyEndpoint().
+ * @see CADestroyEndpoint
*/
-CAResult_t CAGenerateToken(CAToken_t *token);
+CAResult_t CACreateEndpoint(CATransportFlags_t flags,
+ CATransportAdapter_t adapter,
+ const char *addr,
+ uint16_t port,
+ CAEndpoint_t **object);
/**
- * @brief Destroy the token generated by CAGenerateToken
- * @param token [IN] token for the request
+ * Destroy the remote endpoint created.
+ * @param[in] object Remote Endpoint object created with CACreateEndpoint.
*/
-void CADestroyToken(CAToken_t token);
+void CADestroyEndpoint(CAEndpoint_t *object);
/**
- * @brief Find the resource in the network. This API internally sends multicast messages on the
- * all connectivity adapters. Responses are delivered via response callbacks.
- *
- * @param resourceUri [IN] Uri to send multicast search request
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Generating the token for matching the request and response.
+ * @param[out] token Token for the request.
+ * @param[in] tokenLength length of the token.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or
+ * ::CA_MEMORY_ALLOC_FAILED or ::CA_STATUS_INVALID_PARAM
+ * @remark Token memory is destroyed by the caller using CADestroyToken().
+ * @see CADestroyToken
*/
-CAResult_t CAFindResource(const CAURI_t resourceUri, const CAToken_t token);
+CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength);
/**
- * @brief Send control Request on a resource
- * @param object [IN] Remote Endpoint where the payload need to be sent.
- * This Remote endpoint is delivered with Request or response callback.
- * @param requestInfo [IN ] information for the request.
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Destroy the token generated by CAGenerateToken.
+ * @param[in] token token to be freed.
*/
-CAResult_t CASendRequest(const CARemoteEndpoint_t *object, CARequestInfo_t *requestInfo);
+void CADestroyToken(CAToken_t token);
/**
- * @brief Send control Request on a resource to multicast group
- * @param object [IN] Group Endpoint where the payload need to be sent.
- * This Remote endpoint is delivered with Request or response callback.
- * @param requestInfo [IN ] information for the request.
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Send control Request on a resource.
+ * @param[in] object Endpoint where the payload need to be sent.
+ * This endpoint is delivered with Request or response callback.
+ * @param[in] requestInfo Information for the request.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
+ ::CA_SEND_FAILED or ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
*/
-CAResult_t CASendRequestToAll(const CAGroupEndpoint_t* object,
- const CARequestInfo_t* requestInfo);
+CAResult_t CASendRequest(const CAEndpoint_t *object, const CARequestInfo_t *requestInfo);
/**
- * @brief Send the response
- * @param object [IN] Remote Endpoint where the payload need to be sent.
- * This Remote endpoint is delivered with Request or response callback
- * @param responseInfo [IN ] information for the response
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Send the response.
+ * @param[in] object Endpoint where the payload need to be sent.
+ * This endpoint is delivered with Request or response callback.
+ * @param[in] responseInfo Information for the response.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
+ ::CA_SEND_FAILED or ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
*/
-CAResult_t CASendResponse(const CARemoteEndpoint_t *object, CAResponseInfo_t *responseInfo);
+CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
/**
- * @brief Send notification to the remote object
- * @param object [IN] Remote Endpoint where the payload need to be sent.
- * This Remote endpoint is delivered with Request or response callback.
- * @param responseInfo [IN ] information for the response.
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Select network to use.
+ * @param[in] interestedNetwork Connectivity Type enum.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
+ * ::CA_NOT_SUPPORTED or ::CA_ADAPTER_NOT_ENABLED or ::CA_MEMORY_ALLOC_FAILED
*/
-CAResult_t CASendNotification(const CARemoteEndpoint_t *object, CAResponseInfo_t *responseInfo);
+CAResult_t CASelectNetwork(CATransportAdapter_t interestedNetwork);
/**
- * @brief for advertise the resource
- * @param resourceUri [IN] URI to be advertised
- * @param options [IN] header options information
- * @param numOptions [IN] number of options
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Select network to unuse.
+ * @param[in] nonInterestedNetwork Connectivity Type enum.
+ * @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or ::CA_STATUS_FAILED or
+ ::CA_STATUS_NOT_INITIALIZED
*/
-CAResult_t CAAdvertiseResource(const CAURI_t resourceUri, CAToken_t token,
- CAHeaderOption_t* options,uint8_t numOptions);
+CAResult_t CAUnSelectNetwork(CATransportAdapter_t nonInterestedNetwork);
/**
- * @brief Select network to use
- * @param interestedNetwork [IN] Connectivity Type enum
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Get network information.
+ * It should be destroyed by the caller as it Get Information.
+ * @param[out] info LocalConnectivity objects
+ * @param[out] size No Of Array objects
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_NOT_INITIALIZED or
+ * ::CA_STATUS_INVALID_PARAM or ::CA_MEMORY_ALLOC_FAILED
*/
-CAResult_t CASelectNetwork(const uint32_t interestedNetwork);
+CAResult_t CAGetNetworkInformation(CAEndpoint_t **info, uint32_t *size);
/**
- * @brief Select network to unuse
- * @param nonInterestedNetwork [IN] Connectivity Type enum
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * To Handle the Request or Response.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_NOT_INITIALIZED
*/
-CAResult_t CAUnSelectNetwork(const uint32_t nonInterestedNetwork);
+CAResult_t CAHandleRequestResponse();
+#ifdef RA_ADAPTER
/**
- * @brief Get network information
- * It should be destroyed by the caller as its Get Information.
- * @param info [OUT] LocalConnectivity objects
- * @param size [OUT] No Of Array objects
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * Set Remote Access information for XMPP Client.
+ * @param[in] caraInfo remote access info.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_INVALID_PARAM
*/
-CAResult_t CAGetNetworkInformation(CALocalConnectivity_t **info, uint32_t *size);
+CAResult_t CASetRAInfo(const CARAInfo_t *caraInfo);
+#endif
+#ifdef WITH_CHPROXY
/**
- * @brief for usage of singled threaded application.
- * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
+ * This function sets uri being used for proxy.
+ *
+ * @param uri NULL terminated resource uri for CoAP-HTTP Proxy.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_INVALID_PARAM
*/
-CAResult_t CAHandleRequestResponse();
+CAResult_t CASetProxyUri(const char *uri);
+#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif
+#endif /* CA_INTERFACE_H_ */
+