-/******************************************************************
+/* ****************************************************************
*
* Copyright 2014 Samsung Electronics All Rights Reserved.
*
******************************************************************/
/**
- * @file caedrinterface.h
- * @brief This file provides APIs for EDR adapter - client, server, network monitor modules
+ * @file
+ *
+ * This file provides APIs for EDR adapter - client, server, network monitor
+ * modules.
*/
-#ifndef __CA_EDR_INTERFACE_H_
-#define __CA_EDR_INTERFACE_H_
+#ifndef CA_EDR_INTERFACE_H_
+#define CA_EDR_INTERFACE_H_
-#include <string.h>
#include "caedradapter.h"
#ifdef __cplusplus
#define OIC_EDR_SERVICE_ID "12341234-1C25-481F-9DFB-59193D238280"
#endif //OIC_EDR_SERVICE_ID
+typedef enum
+{
+ STATE_DISCONNECTED, /**< State is Disconnected. */
+ STATE_CONNECTED /**< State is Connected. */
+} CAConnectedState_t;
-typedef struct connected_state {
- char address[CA_MACADDR_SIZE];
- uint32_t state;
+typedef struct connected_state
+{
+ uint8_t address[CA_MACADDR_SIZE];
+ CAConnectedState_t state;
} state_t;
/**
- * @enum CAAdapterServerType_t
- * @brief Enum for defining different server types.
+ * Enum for defining different server types.
*/
typedef enum
{
- CA_UNICAST_SERVER = 0, /**< Unicast Server */
- CA_MULTICAST_SERVER, /**< Multicast Server */
- CA_SECURED_UNICAST_SERVER /**< Secured Unicast Server */
+ CA_UNICAST_SERVER = 0, /**< Unicast Server. */
+ CA_MULTICAST_SERVER, /**< Multicast Server. */
+ CA_SECURED_UNICAST_SERVER /**< Secured Unicast Server. */
} CAAdapterServerType_t;
/**
- * @struct CAEDRData
- * @brief Structure to maintain the information of data in message queue.
+ * Structure to maintain the information of data in message queue.
*/
typedef struct
{
- CARemoteEndpoint_t *remoteEndpoint; /**< Remote Endpoint */
- void *data; /**< Data to be sent */
- uint32_t dataLen; /**< Length of the data to be sent */
+ CAEndpoint_t *remoteEndpoint; /**< Remote Endpoint. */
+ void *data; /**< Data to be sent. */
+ uint32_t dataLen; /**< Length of the data to be sent. */
} CAEDRData;
/**
- * @struct CAEDRNetworkEvent
- * @brief Structure to maintain the adapter information and its status.
+ * Structure to maintain the adapter information and its status.
*/
typedef struct
{
- CALocalConnectivity_t *info; /**< Local Connectivity Information */
- CANetworkStatus_t status; /**< Network Status */
+ CAEndpoint_t *info; /**< Local Connectivity Information. */
+ CANetworkStatus_t status; /**< Network Status. */
} CAEDRNetworkEvent;
/**
- * @brief This will be used during the recive of network requests and response.
- * @param remoteAddress [IN] EDR address of remote OIC device
- * @param data [IN] Data received
- * @param dataLength [IN] Length of the Data received
- * @param sentLength [IN] Length of the sent data
- * @return NONE
- * @pre Callback must be registered using CAEDRSetPacketReceivedCallback()
+ * This will be used during the Receiver of network requests and response.
+ * @param[in] remoteAddress EDR address of remote OIC device from which data received.
+ * @param[in] data Data received.
+ * @param[in] dataLength Length of the Data received.
+ * @param[out] sentLength Length of the sent data.
+ * @pre Callback must be registered using CAEDRSetPacketReceivedCallback().
*/
-typedef void (*CAEDRDataReceivedCallback)(const char *remoteAddress, void *data, uint32_t dataLength,
- uint32_t *sentLength);
+typedef void (*CAEDRDataReceivedCallback)(const char *remoteAddress, const void *data,
+ uint32_t dataLength, uint32_t *sentLength);
/**
- * @brief This will be used during change in network status.
- * @param status [IN] Network Status of the adapter
- * @return NONE
+ * This will be used during change in network status.
+ * @param[in] status Network Status of the adapter.
*/
typedef void (*CAEDRNetworkStatusCallback)(CANetworkStatus_t status);
/**
- * @brief Initialize the network monitor module
- *
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is
- * not enabled.
- * @retval #CA_STATUS_FAILED Operation failed
- * @see CAEDRTerminateNetworkMonitor()
+ * Callback to notify the error in the EDR adapter.
+ * @param[in] remoteAddress Remote EDR Address.
+ * @param[in] serviceUUID Service UUID of the device.
+ * @param[in] data data containing token, uri and coap data.
+ * @param[in] dataLength length of data.
+ * @param[in] result error code as defined in ::CAResult_t.
+ * @pre Callback must be registered using CAEDRSetPacketReceivedCallback().
*/
-CAResult_t CAEDRInitializeNetworkMonitor();
+typedef void (*CAEDRErrorHandleCallback)(const char *remoteAddress, const char *serviceUUID,
+ const void *data, uint32_t dataLength, CAResult_t result);
/**
- * @brief Deinitialize with bluetooth adapter.
- * @return NONE
- * @pre CAEDRInitializeNetworkMonitor() should be invoked before using this API.
- * @see CAEDRInitializeNetworkMonitor()
+ * Initialize the network monitor module
+ * @param[in] threadPool Threadpool Handle.
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_ADAPTER_NOT_ENABLED Initialization is successful, but
+ * bluetooth adapter is not enabled.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ * @see CAEDRTerminateNetworkMonitor().
*/
-void CAEDRTerminateNetworkMonitor(void);
+CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool);
/**
- * @brief Start Network Monitoring Process
- * @return #CA_STATUS_OK or Appropriate error code
+ * Deinitialize with bluetooth adapter.
+ * @pre CAEDRInitializeNetworkMonitor() should be invoked before using
+ * this API.
+ * @see CAEDRInitializeNetworkMonitor().
+ */
+void CAEDRTerminateNetworkMonitor();
+
+/**
+ * Start Network Monitoring Process.
+ * @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRStartNetworkMonitor();
/**
- * @brief Stop Network Monitoring Process
- * @return #CA_STATUS_OK or Appropriate error code
+ * Stop Network Monitoring Process.
+ * @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRStopNetworkMonitor();
/**
- * @brief Sets the callback and Starts discovery for nearby OIC bluetooth devices.
+ * Sets the callback and Starts discovery for nearby OIC bluetooth devices.
*
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_STATUS_FAILED Operation failed.
*/
-CAResult_t CAEDRClientSetCallbacks(void);
+CAResult_t CAEDRClientSetCallbacks();
/**
- * @brief Resetting callbacks with bluetooth framework and stop OIC device discovery.
- * @return NONE
- * @pre CAEDRClientSetCallbacks() should be invoked before using this API.
- * @see CAEDRClientSetCallbacks()
+ * Resetting callbacks with bluetooth framework and stop OIC device discovery.
+ * @pre CAEDRClientSetCallbacks() should be invoked before using this API.
+ * @see CAEDRClientSetCallbacks().
*/
-void CAEDRClientUnsetCallbacks(void);
+void CAEDRClientUnsetCallbacks();
/**
- * @brief Used to initialize the EDR client module where mutex is initialized
- * @return NONE
+ * Used to initialize the EDR client module where mutex is initialized.
*/
-void CAEDRInitializeClient(u_thread_pool_t handle);
+void CAEDRInitializeClient(ca_thread_pool_t handle);
/**
- * @brief Destroys the Device list and mutex.
- * @return NONE
+ * Destroys the Device list and mutex.
*/
-void CAEDRTerminateClient();
+void CAEDRClientTerminate();
/**
- * @brief Closes all the client connection to peer bluetooth devices.
- * @return NONE
+ * Closes all the client connection to peer bluetooth devices.
*/
-void CAEDRClientDisconnectAll(void);
+void CAEDRClientDisconnectAll();
/**
- * @brief Register callback to send the received packets from remote bluetooth device to BTAdapter.
+ * Register callback to send the received packets from remote bluetooth
+ * device to BTAdapter.
*
- * @param packetReceivedCallback [IN] Callback function to register for sending network
- * packets to EDR Adapter.
- * @return NONE
+ * @param[in] packetReceivedCallback Callback function to register for
+ * sending network packets to EDR Adapter.
*/
void CAEDRSetPacketReceivedCallback(CAEDRDataReceivedCallback packetReceivedCallback);
/**
- * @brief Register callback for receiving local bluetooth adapter state.
+ * Register callback for receiving local bluetooth adapter state.
*
- * @param networkStateChangeCallback [IN] Callback function to register for receiving local
- * bluetooth adapter status.
- * @return NONE
+ * @param[in] networkStateChangeCallback Callback function to register
+ * for receiving local bluetooth adapter status.
*/
void CAEDRSetNetworkChangeCallback(CAEDRNetworkStatusCallback networkStateChangeCallback);
+/**
+ * set error callback to notify error in EDR adapter.
+ *
+ * @param[in] errorHandleCallback Callback function to notify the error
+ * in the EDR adapter.
+ */
+void CAEDRSetErrorHandler(CAEDRErrorHandleCallback errorHandleCallback);
+
/**
- * @brief Get the local bluetooth adapter information.
+ * Get the local bluetooth adapter information.
*
- * @param info [IN] Local bluetooth adapter information
+ * @param[out] info Local bluetooth adapter information.
*
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM Invalid input argumets.
+ * @retval ::CA_STATUS_FAILED Operation failed.
*
- * @see #CALocalConnectivity_t
+ * @see CALocalConnectivity_t
*
*/
-CAResult_t CAEDRGetInterfaceInformation(CALocalConnectivity_t **info);
+CAResult_t CAEDRGetInterfaceInformation(CAEndpoint_t **info);
/**
- * @brief Start RFCOMM server for given service UUID
+ * Start RFCOMM server for given service UUID
*
- * @param serviceUUID [IN] The UUID of service with which RFCOMM server needs to be started.
- * @param serverFD [IN] The RFCOMM server socket file descriptor.
+ * @param[in] serviceUUID The UUID of service with which RFCOMM server
+ * needs to be started.
+ * @param[in] serverFD The RFCOMM server socket file descriptor.
+ * @param[in] handle Threadpool Handle.
*
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM Invalid input argumets.
+ * @retval ::CA_STATUS_FAILED Operation failed.
*
*/
-CAResult_t CAEDRServerStart(const char *serviceUUID, int32_t *serverFD, u_thread_pool_t handle);
+CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_pool_t handle);
/**
- * @brief Stop RFCOMM server
+ * Stop RFCOMM server
*
- * @param serverFD [IN] The RFCOMM server socket file descriptor which needs to be stopped.
+ * @param[in] serverFD The RFCOMM server socket file descriptor which
+ * needs to be stopped.
*
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ */
+CAResult_t CAEDRServerStop(int serverFD);
+
+/**
+ * Terminate server for EDR.
*/
-CAResult_t CAEDRServerStop(const int32_t serverFD);
+void CAEDRServerTerminate();
/**
- * @brief All received data will be notified to upper layer.
+ * All received data will be notified to upper layer.
*
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK Successful
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK Successful.
+ * @retval ::CA_STATUS_FAILED Operation failed.
*
*/
-CAResult_t CAEDRManagerReadData(void);
+CAResult_t CAEDRManagerReadData();
/**
- * @brief This function gets bluetooth adapter enable state.
- * @param state [OUT] State of the Adapter.
- * @return #CA_STATUS_OK or Appropriate error code
+ * This function gets bluetooth adapter enable state.
+ * @param[out] state State of the Adapter.
+ * @return ::CA_STATUS_OK or Appropriate error code.
*/
-CAResult_t CAEDRGetAdapterEnableState(CABool_t *state);
+CAResult_t CAEDRGetAdapterEnableState(bool *state);
/**
- * @brief This function sends data to specified remote bluetooth device.
- * @param remoteAddress [IN] Remote EDR Address
- * @param serviceUUID [IN] Service UUID of the device
- * @param data [IN] Data to be sent
- * @param dataLength [IN] Length of the data to be sent
- * @param sentLength [IN] Length of the actual sent data
- * @return #CA_STATUS_OK or Appropriate error code
+ * This function sends data to specified remote bluetooth device.
+ * @param[in] remoteAddress Remote EDR Address.
+ * @param[in] serviceUUID Service UUID of the device.
+ * @param[in] data Data to be sent.
+ * @param[in] dataLength Length of the data to be sent.
+ * @return ::CA_STATUS_OK or Appropriate error code.
*/
CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *serviceUUID,
- void *data, uint32_t dataLength, uint32_t *sentLength);
+ const void *data, uint32_t dataLength);
/**
- * @brief This function sends data to all bluetooth devices running OIC service.
- * @param serviceUUID [IN] Service UUID of the device
- * @param data [IN] Data to be sent
- * @param dataLength [IN] Length of the data to be sent
- * @param sentLength [IN] Length of the actual sent data
- * @return #CA_STATUS_OK or Appropriate error code
+ * This function sends data to all bluetooth devices running OIC service.
+ * @param[in] serviceUUID Service UUID of the device.
+ * @param[in] data Data to be sent.
+ * @param[in] dataLength Length of the data to be sent.
+ * @return ::CA_STATUS_OK or Appropriate error code.
*/
-CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, void *data,
- uint32_t dataLength, uint32_t *sentLength);
+CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
+ uint32_t dataLength);
+
+/**
+ * This function gets bonded bluetooth device list
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAEDRGetBondedDeviceList();
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif //__CA_EDR_INTERFACE_H_
-
+#endif /* CA_EDR_INTERFACE_H_ */