replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / caedrinterface.h
index df9e86c..45a5afb 100644 (file)
@@ -1,4 +1,4 @@
-/******************************************************************
+/* ****************************************************************
  *
  * Copyright 2014 Samsung Electronics All Rights Reserved.
  *
@@ -25,8 +25,8 @@
  * modules.
  */
 
-#ifndef __CA_EDR_INTERFACE_H_
-#define __CA_EDR_INTERFACE_H_
+#ifndef CA_EDR_INTERFACE_H_
+#define CA_EDR_INTERFACE_H_
 
 #include "caedradapter.h"
 
@@ -41,248 +41,268 @@ extern "C"
 
 typedef enum
 {
-    STATE_DISCONNECTED, /**< State is Disconnected */
-    STATE_CONNECTED /**< State is Connected */
+    STATE_DISCONNECTED, /**< State is Disconnected. */
+    STATE_CONNECTED     /**< State is Connected. */
 } CAConnectedState_t;
 
-typedef struct connected_state
+typedef struct connected_device
 {
     uint8_t address[CA_MACADDR_SIZE];
     CAConnectedState_t state;
-} state_t;
+    uint8_t *recvData;
+    size_t recvDataLen;
+    size_t totalDataLen;
+} CAConnectedDeviceInfo_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. */
+    uint8_t *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 from which data received.
- * @param data          [IN] Data received
- * @param dataLength    [IN] Length of the Data received
- * @param sentLength    [OUT] 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.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ * @pre Callback must be registered using CAEDRSetPacketReceivedCallback().
  */
-typedef void (*CAEDRDataReceivedCallback)(const char *remoteAddress, const void *data,
-                                          uint32_t dataLength, uint32_t *sentLength);
+typedef CAResult_t (*CAEDRDataReceivedCallback)(const char *remoteAddress, const uint8_t *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
- * @param  threadPool   [IN] 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()
+ * Callback to notify the error in the EDR adapter.
+ * @param[in]  remoteAddress   Remote EDR Address.
+ * @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().
+ */
+typedef void (*CAEDRErrorHandleCallback)(const char *remoteAddress,
+                                         const uint8_t *data,
+                                         uint32_t dataLength,
+                                         CAResult_t result);
+
+/**
+ * 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().
  */
 CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool);
 
 /**
- * @brief  Deinitialize with bluetooth adapter.
- * @return NONE
- * @pre    CAEDRInitializeNetworkMonitor() should be invoked before using this API.
- * @see    CAEDRInitializeNetworkMonitor()
+ * Deinitialize with bluetooth adapter.
+ * @pre    CAEDRInitializeNetworkMonitor() should be invoked before using
+ * this API.
+ * @see    CAEDRInitializeNetworkMonitor().
  */
 void CAEDRTerminateNetworkMonitor();
 
 /**
- * @brief  Start Network Monitoring Process
- * @return #CA_STATUS_OK or Appropriate error code
+ * 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();
 
 /**
- * @brief  Resetting callbacks with bluetooth framework and stop OIC device discovery.
- * @return NONE
+ * Resetting callbacks with bluetooth framework and stop OIC device discovery.
  * @pre    CAEDRClientSetCallbacks() should be invoked before using this API.
- * @see    CAEDRClientSetCallbacks()
+ * @see    CAEDRClientSetCallbacks().
  */
 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.
+ * @return ::CA_STATUS_OK or Appropriate error code.
  */
-void CAEDRInitializeClient(ca_thread_pool_t handle);
+CAResult_t CAEDRClientInitialize();
 
 /**
- * @brief  Destroys the Device list and mutex.
- * @return NONE
+ * Destroys the Device list and mutex.
  */
 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();
 
 /**
- * @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);
 
 /**
- * @brief  Get the local bluetooth adapter information.
+ * set error callback to notify error in EDR adapter.
  *
- * @param  info [OUT] Local bluetooth adapter information
+ * @param[in]  errorHandleCallback Callback function to notify the error
+ * in the EDR adapter.
+ */
+void CAEDRSetErrorHandler(CAEDRErrorHandleCallback errorHandleCallback);
+
+
+/**
+ * Get the 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
+ * @param[out]  info Local bluetooth adapter information.
  *
- * @see #CALocalConnectivity_t
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ * @retval ::CA_STATUS_OK  Successful.
+ * @retval ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval ::CA_STATUS_FAILED Operation failed.
+ *
+ * @see CALocalConnectivity_t
  *
  */
-CAResult_t CAEDRGetInterfaceInformation(CALocalConnectivity_t **info);
+CAResult_t CAEDRGetInterfaceInformation(CAEndpoint_t **info);
 
 /**
- * @brief  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  handle       [IN] Threadpool Handle
+ * Start RFCOMM server for given service UUID
  *
- * @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 arguments.
+ * @retval ::CA_STATUS_FAILED Operation failed.
  *
  */
-CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_pool_t handle);
+CAResult_t CAEDRServerStart();
 
 /**
- * @brief  Stop RFCOMM server
+ * Stop RFCOMM server
  *
- * @param  serverFD [IN] 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);
+CAResult_t CAEDRServerStop();
 
 /**
- * @brief   Terminate server for EDR
- * @return  None
+ * Used to initialize the EDR server module where mutex is initialized.
+ * @param[in]  threadPool   Threadpool Handle.
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAEDRServerInitialize(ca_thread_pool_t handle);
+
+/**
+ * Terminate server for EDR.
  */
 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();
 
 /**
- * @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(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      [OUT] 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]  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,
-                                      const void *data, uint32_t dataLength, uint32_t *sentLength);
+CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
+                                      const uint8_t *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      [OUT] 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]  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, const void *data,
-                                        uint32_t dataLength, uint32_t *sentLength);
+CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
+                                        uint32_t dataLength);
 
 /**
- * @brief This function gets bonded bluetooth device list
- * @return #CA_STATUS_OK or Appropriate error code
+ * This function gets bonded bluetooth device list
+ * @return ::CA_STATUS_OK or Appropriate error code.
  */
 CAResult_t CAEDRGetBondedDeviceList();
 
+#ifdef __TIZEN__
+/**
+ * This function starts device discovery.
+ */
+CAResult_t CAEDRStartDeviceDiscovery(void);
+#endif
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
 
-#endif //__CA_EDR_INTERFACE_H_
-
+#endif /* CA_EDR_INTERFACE_H_ */