Implementation for Tizen EDR transport.
authork.karthick <k.karthick@samsung.com>
Tue, 28 Apr 2015 09:49:05 +0000 (15:19 +0530)
committerErich Keane <erich.keane@intel.com>
Fri, 1 May 2015 20:32:49 +0000 (20:32 +0000)
Typo errors, logging issues and some refactoring

Change-Id: I4103abf950c67cb6181a7137a72fa8fd78f18b3e
Signed-off-by: k.karthick <k.karthick@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/756
Reviewed-by: Caiwen Zhang <caiwen.zhang@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/inc/caedradapter.h
resource/csdk/connectivity/inc/caedrinterface.h
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrnwmonitor.c
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrserver.c

index b6bbc90..6f67eb2 100644 (file)
@@ -1,4 +1,4 @@
-/* ****************************************************************
+/******************************************************************
  *
  * Copyright 2014 Samsung Electronics All Rights Reserved.
  *
@@ -40,34 +40,24 @@ extern "C"
 #endif
 
 /**
- * @brief  Initialize EDR Interface.
- * @param  registerCallback  [IN] Callback to register EDR interface to Connectivity
- *                                Abstraction Layer
- * @param  reqRespCallback   [IN] Callback to notify request and response messages from server(s)
- *                                started at Connectivity Abstraction Layer.
- * @param  netCallback       [IN] Callback to notify the network additions to Connectivity
- *                                Abstraction Layer.
- * @param  handle            [IN] Threadpool Handle
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval  #CA_STATUS_OK  Successful
- * @retval  #CA_STATUS_INVALID_PARAM  Invalid input parameters
- * @retval  #CA_ADAPTER_NOT_ENABLED Initialization is successful, but bluetooth adapter is
- *                                  not enabled
- * @retval  #CA_STATUS_FAILED Operation failed
+ * @brief   Initialize EDR Interface.
+ * @param   registerCallback  [IN] Callback to register EDR interface to Connectivity
+ *                                 Abstraction Layer
+ * @param   reqRespCallback   [IN] Callback to notify request and response messages from server(s)
+ *                                 started at Connectivity Abstraction Layer.
+ * @param   netCallback       [IN] Callback to notify the network additions to Connectivity
+ *                                 Abstraction Layer.
+ * @param   handle            [IN] Threadpool Handle
+ * @return  CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
                            CANetworkPacketReceivedCallback reqRespCallback,
-                           CANetworkChangeCallback netCallback,
-                           ca_thread_pool_t handle);
+                           CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
 
 /**
- * @brief  Starts EDR connectivity adapters. As its peer to peer it doesnot require to start
- *         any servers.
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval  #CA_STATUS_OK  Successful
- * @retval  #CA_ADAPTER_NOT_ENABLED Bluetooth adapter is not enabled
- * @retval  #CA_STATUS_FAILED Operation failed
- *
+ * @brief   Starts EDR connectivity adapters. As its peer to peer it doesnot require to start
+ *          any servers.
+ * @return  CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAStartEDR();
 
@@ -75,12 +65,7 @@ CAResult_t CAStartEDR();
  * @brief  Starts listening server for receiving multicast search requests.
  * Starts  RFCOMM Server with prefixed UUID as per OIC specification.
  *
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK  Successful
- * @retval #CA_SERVER_STARTED_ALREADY  Server is already started and running for the predefined
- *                                     service UUID
- * @retval #CA_STATUS_FAILED Operation failed
- *
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAStartEDRListeningServer();
 
@@ -88,11 +73,7 @@ CAResult_t CAStartEDRListeningServer();
  * @brief  Starting discovery server for receiving multicast advertisements.
  * Starts  RFCOMM Server with prefixed UUID as per OIC specification.
  *
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK  Successful
- * @retval #CA_SERVER_STARTED_ALREADY  Server is already started and running for the predefined
- *                                     service UUID
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAStartEDRDiscoveryServer();
 
@@ -106,7 +87,7 @@ CAResult_t CAStartEDRDiscoveryServer();
  *
  */
 int32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, const void *data,
-                              uint32_t dataLength);
+                             uint32_t dataLength);
 
 /**
  * @brief  Sends multicast data to all discovered bluetooth OIC devices using the adapter
@@ -123,26 +104,19 @@ int32_t CASendEDRMulticastData(const void *data, uint32_t dataLength);
  * @param  info [OUT] Array of local connectivity information structures.
  * @param  size [OUT] Size of the array @info.
  *
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK  Successful
- * @retval #CA_STATUS_INVALID_PARAM  Invalid input parameters
- * @retval #CA_MEMORY_ALLOC_FAILED  Failed to allocate memory
- * @retval #CA_STATUS_FAILED Operation failed
- * @remarks info is allocated in this API and should be freed by the caller.
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *size);
 
 /**
  * @brief  Read Synchronous API callback.
- * @return #CA_STATUS_OK on success otherwise proper error code.
- * @retval #CA_STATUS_OK  Successful
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAReadEDRData();
 
 /**
  * @brief  EDR Stops all RFCOMM servers and close sockets.
- * @return #CA_STATUS_OK or Appropriate error code
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAStopEDR();
 
@@ -156,11 +130,7 @@ void CATerminateEDR();
 /**
  * @brief  Initializes the adapter queues.
  * This will initiates both server and receiver adapter queues.
- * @return #CA_STATUS_OK or Appropriate error code
- * @retval #CA_STATUS_OK  Successful
- * @retval #CA_STATUS_INVALID_PARAM  Invalid input parameters
- * @retval #CA_MEMORY_ALLOC_FAILED  Failed to allocate memory
- * @retval #CA_STATUS_FAILED Operation failed
+ * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
  */
 CAResult_t CAAdapterStartQueue();
 
index 64e74ee..df9e86c 100644 (file)
@@ -1,4 +1,4 @@
-/* ****************************************************************
+/******************************************************************
  *
  * Copyright 2014 Samsung Electronics All Rights Reserved.
  *
@@ -41,29 +41,30 @@ 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_state
+{
     uint8_t address[CA_MACADDR_SIZE];
     CAConnectedState_t state;
 } state_t;
 
 /**
- * @enum CAAdapterServerType_t
+ * @enum  CAAdapterServerType_t
  * @brief 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.
+ * @brief  Structure to maintain the information of data in message queue.
  */
 typedef struct
 {
@@ -74,12 +75,12 @@ typedef struct
 
 /**
  * @struct CAEDRNetworkEvent
- * @brief Structure to maintain the adapter information and its status.
+ * @brief  Structure to maintain the adapter information and its status.
  */
 typedef struct
 {
-    CALocalConnectivity_t *info;    /**< Local Connectivity Information */
-    CANetworkStatus_t status;       /**< Network Status */
+    CALocalConnectivity_t *info; /**< Local Connectivity Information */
+    CANetworkStatus_t status;    /**< Network Status */
 } CAEDRNetworkEvent;
 
 /**
@@ -91,19 +92,19 @@ typedef struct
  * @return NONE
  * @pre Callback must be registered using CAEDRSetPacketReceivedCallback()
  */
-typedef void (*CAEDRDataReceivedCallback)(const char *remoteAddress,
-                                    const 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
+ * @param status        [IN] Network Status of the adapter
  * @return NONE
  */
 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
@@ -111,24 +112,24 @@ typedef void (*CAEDRNetworkStatusCallback)(CANetworkStatus_t status);
  * @retval #CA_STATUS_FAILED Operation failed
  * @see  CAEDRTerminateNetworkMonitor()
  */
-CAResult_t CAEDRInitializeNetworkMonitor();
+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()
+ * @pre    CAEDRInitializeNetworkMonitor() should be invoked before using this API.
+ * @see    CAEDRInitializeNetworkMonitor()
  */
-void CAEDRTerminateNetworkMonitor(void);
+void CAEDRTerminateNetworkMonitor();
 
 /**
- * @brief Start Network Monitoring Process
+ * @brief  Start Network Monitoring Process
  * @return #CA_STATUS_OK or Appropriate error code
  */
 CAResult_t CAEDRStartNetworkMonitor();
 
 /**
- * @brief Stop Network Monitoring Process
+ * @brief  Stop Network Monitoring Process
  * @return #CA_STATUS_OK or Appropriate error code
  */
 CAResult_t CAEDRStopNetworkMonitor();
@@ -140,33 +141,33 @@ CAResult_t CAEDRStopNetworkMonitor();
  * @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()
+ * @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
+ * @brief  Used to initialize the EDR client module where mutex is initialized
  * @return NONE
  */
 void CAEDRInitializeClient(ca_thread_pool_t handle);
 
 /**
- * @brief Destroys the Device list and mutex.
+ * @brief  Destroys the Device list and mutex.
  * @return NONE
  */
 void CAEDRClientTerminate();
 
 /**
- * @brief Closes all the client connection to peer bluetooth devices.
+ * @brief  Closes all the client connection to peer bluetooth devices.
  * @return NONE
  */
-void CAEDRClientDisconnectAll(void);
+void CAEDRClientDisconnectAll();
 
 /**
  * @brief  Register callback to send the received packets from remote bluetooth device to BTAdapter.
@@ -186,11 +187,10 @@ void CAEDRSetPacketReceivedCallback(CAEDRDataReceivedCallback packetReceivedCall
  */
 void CAEDRSetNetworkChangeCallback(CAEDRNetworkStatusCallback networkStateChangeCallback);
 
-
 /**
  * @brief  Get the local bluetooth adapter information.
  *
- * @param  info [IN] Local bluetooth adapter information
+ * @param  info [OUT] Local bluetooth adapter information
  *
  * @return #CA_STATUS_OK or Appropriate error code
  * @retval #CA_STATUS_OK  Successful
@@ -207,6 +207,7 @@ CAResult_t CAEDRGetInterfaceInformation(CALocalConnectivity_t **info);
  *
  * @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
  *
  * @return #CA_STATUS_OK or Appropriate error code
  * @retval #CA_STATUS_OK  Successful
@@ -241,42 +242,47 @@ void CAEDRServerTerminate();
  * @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.
+ * @brief  This function gets bluetooth adapter enable state.
+ * @param  state    [OUT] 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
+ * @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
  */
 CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress, const char *serviceUUID,
                                       const void *data, uint32_t dataLength, uint32_t *sentLength);
 
 /**
- * @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
+ * @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
  */
 CAResult_t CAEDRClientSendMulticastData(const char *serviceUUID, const void *data,
                                         uint32_t dataLength, uint32_t *sentLength);
 
+/**
+ * @brief 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_
 
-
index e2ea8e5..9425988 100644 (file)
@@ -1,4 +1,4 @@
-/* ****************************************************************
+/******************************************************************
  *
  * Copyright 2014 Samsung Electronics All Rights Reserved.
  *
@@ -100,30 +100,30 @@ static int g_serverId = -1;
  */
 static bool g_serverState = false;
 
-static CAResult_t CAStartServer(void);
-static CAResult_t CAEDRInitializeQueueHandlers(void);
-CAResult_t CAEDRInitializeSendHandler(void);
-CAResult_t CAEDRInitializeReceiveHandler(void);
-void CAAdapterTerminateQueues(void);
+static CAResult_t CAStartServer();
+static CAResult_t CAEDRInitializeQueueHandlers();
+CAResult_t CAEDRInitializeSendHandler();
+CAResult_t CAEDRInitializeReceiveHandler();
+void CAAdapterTerminateQueues();
 void CAAdapterDataSendHandler(void *context);
 void CAAdapterDataReceiverHandler(void *context);
 CAResult_t CAAdapterStopQueue();
-void CAAdapterRecvData(const char *remoteAddress, const void *data,
-                                    uint32_t dataLength, uint32_t *sentLength);
+void CAAdapterRecvData(const char *remoteAddress, const void *data, uint32_t dataLength,
+                       uint32_t *sentLength);
 void CAEDRNotifyNetworkStatus(CANetworkStatus_t status);
 void CAEDROnNetworkStatusChanged(void *context);
-CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID,
-                               const void *data, uint32_t dataLength, uint32_t *sentLength);
+CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const void *data,
+                             uint32_t dataLength, uint32_t *sentLength);
 CAEDRNetworkEvent *CAEDRCreateNetworkEvent(CALocalConnectivity_t *connectivity,
                                            CANetworkStatus_t status);
 CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUID,
-                                      const void *data, uint32_t dataLength, uint32_t *sentLength);
+                               const void *data, uint32_t dataLength, uint32_t *sentLength);
 /**
  * @fn CACreateEDRData
  * @brief Helper function to create CAEDRData
  */
 static CAEDRData *CACreateEDRData(const CARemoteEndpoint_t *remoteEndpoint, const void *data,
-                                uint32_t dataLength);
+                                  uint32_t dataLength);
 
 /**
  * @fn CAFreeEDRData
@@ -160,7 +160,7 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
     g_networkChangeCallback = networkStateChangeCallback;
 
     // Initialize EDR Network Monitor
-    CAResult_t err = CAEDRInitializeNetworkMonitor();
+    CAResult_t err = CAEDRInitializeNetworkMonitor(handle);
     if (CA_STATUS_OK != err)
     {
         OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR N/w Monitor Initialize failed!, error number [%d]",
@@ -196,13 +196,13 @@ CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
     return CA_STATUS_OK;
 }
 
-CAResult_t CAStartEDR(void)
+CAResult_t CAStartEDR()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
     //Start Monitoring EDR Network
     CAResult_t ret = CAEDRStartNetworkMonitor();
-    if(CA_STATUS_OK != ret)
+    if (CA_STATUS_OK != ret)
     {
        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start n/w monitor");
     }
@@ -219,7 +219,7 @@ CAResult_t CAStartEDR(void)
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
         g_adapterState = false;
-        return CA_STATUS_OK;
+        return CA_ADAPTER_NOT_ENABLED;
     }
 
     if (CA_STATUS_OK != (ret = CAEDRClientSetCallbacks()))
@@ -230,22 +230,21 @@ CAResult_t CAStartEDR(void)
 
     if (CA_STATUS_OK != (ret = CAAdapterStartQueue()))
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "CAAdapterStartQueue failed!, error number [%d] ",
-                  ret);
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret);
     }
 
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
     return ret;
 }
 
-CAResult_t CAStartEDRListeningServer(void)
+CAResult_t CAStartEDRListeningServer()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
     return CAStartServer();
 }
 
-CAResult_t CAStartEDRDiscoveryServer(void)
+CAResult_t CAStartEDRDiscoveryServer()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
@@ -253,33 +252,31 @@ CAResult_t CAStartEDRDiscoveryServer(void)
 }
 
 int32_t CASendEDRUnicastData(const CARemoteEndpoint_t *remoteEndpoint, const void *data,
-                              uint32_t dataLength)
+                             uint32_t dataLength)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
-    CAResult_t err = CA_STATUS_OK;
-
     // Input validation
     VERIFY_NON_NULL_RET(remoteEndpoint, EDR_ADAPTER_TAG, "Remote endpoint is null", -1);
     VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1);
 
-    if (0 == strlen(remoteEndpoint->addressInfo.BT.btMacAddress))
+    if (0 == dataLength)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: EDR Address is empty!");
+        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!");
         return -1;
     }
 
-    if (0 == dataLength)
+    if (0 == strlen(remoteEndpoint->addressInfo.BT.btMacAddress))
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!");
+        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: EDR Address is empty!");
         return -1;
     }
 
     uint32_t sentLength = 0;
     const char *serviceUUID = OIC_EDR_SERVICE_ID;
     const char *address = remoteEndpoint->addressInfo.BT.btMacAddress;
-    if (CA_STATUS_OK != (err = CAAdapterSendData(address, serviceUUID, data,
-                               dataLength, &sentLength)))
+    CAResult_t err = CAAdapterSendData(address, serviceUUID, data, dataLength, &sentLength);
+    if (CA_STATUS_OK != err)
     {
         OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send unicast data failed!, error num [%d]", err);
         return -1;
@@ -293,8 +290,6 @@ int32_t CASendEDRMulticastData(const void *data, uint32_t dataLength)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CASendEDRMulticastData");
 
-    CAResult_t err = CA_STATUS_OK;
-
     // Input validation
     VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1);
 
@@ -306,11 +301,10 @@ int32_t CASendEDRMulticastData(const void *data, uint32_t dataLength)
 
     uint32_t sentLen = 0;
     const char *serviceUUID = OIC_EDR_SERVICE_ID;
-    if (CA_STATUS_OK != (err = CAAdapterSendData(NULL, serviceUUID, data, dataLength,
-                               &sentLen)))
+    CAResult_t err = CAAdapterSendData(NULL, serviceUUID, data, dataLength, &sentLen);
+    if (CA_STATUS_OK != err)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send multicast data failed!, error num [%d]",
-                  err);
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send multicast data failed!, error num [%d]", err);
         return -1;
     }
 
@@ -339,14 +333,14 @@ CAResult_t CAGetEDRInterfaceInformation(CALocalConnectivity_t **info, uint32_t *
     return err;
 }
 
-CAResult_t CAReadEDRData(void)
+CAResult_t CAReadEDRData()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
     return CAEDRManagerReadData();
 }
 
-CAResult_t CAStopEDR(void)
+CAResult_t CAStopEDR()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
@@ -373,10 +367,12 @@ CAResult_t CAStopEDR(void)
     return CA_STATUS_OK;
 }
 
-void CATerminateEDR(void)
+void CATerminateEDR()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
+    // Stop EDR adapter
+    CAStopEDR();
     // Terminate EDR Network Monitor
     CAEDRTerminateNetworkMonitor();
 
@@ -389,10 +385,10 @@ void CATerminateEDR(void)
     // Terminate thread pool
     g_edrThreadPool = NULL;
 
-    // Terminate BT Client
+    // Terminate EDR Client
     CAEDRClientTerminate();
 
-    // Terminate BT Server
+    // Terminate EDR Server
     CAEDRServerTerminate();
 
     // Free LocalConnectivity information
@@ -402,7 +398,7 @@ void CATerminateEDR(void)
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
 }
 
-CAResult_t CAStartServer(void)
+CAResult_t CAStartServer()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
@@ -419,7 +415,7 @@ CAResult_t CAStartServer(void)
     if (-1 < g_serverId)
     {
         OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Server is already in running state.");
-        return CA_STATUS_OK;
+        return CA_SERVER_STARTED_ALREADY;
     }
 
     if (CA_STATUS_OK != (err = CAEDRServerStart(OIC_EDR_SERVICE_ID, &g_serverId, g_edrThreadPool)))
@@ -433,7 +429,7 @@ CAResult_t CAStartServer(void)
     return err;
 }
 
-CAResult_t CAEDRInitializeQueueHandlers(void)
+CAResult_t CAEDRInitializeQueueHandlers()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
@@ -448,7 +444,7 @@ CAResult_t CAEDRInitializeQueueHandlers(void)
     return CA_STATUS_FAILED;
 }
 
-CAResult_t CAEDRInitializeSendHandler(void)
+CAResult_t CAEDRInitializeSendHandler()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
     // Check if the message queue is already initialized
@@ -466,7 +462,7 @@ CAResult_t CAEDRInitializeSendHandler(void)
     }
 
     if (CA_STATUS_OK != CAQueueingThreadInitialize(g_sendQueueHandle, g_edrThreadPool,
-            CAAdapterDataSendHandler, CAEDRDataDestroyer))
+                                                   CAAdapterDataSendHandler, CAEDRDataDestroyer))
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread");
         return CA_STATUS_FAILED;
@@ -474,7 +470,7 @@ CAResult_t CAEDRInitializeSendHandler(void)
     return CA_STATUS_OK;
 }
 
-CAResult_t CAEDRInitializeReceiveHandler(void)
+CAResult_t CAEDRInitializeReceiveHandler()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
     // Check if the message queue is already initialized
@@ -492,7 +488,8 @@ CAResult_t CAEDRInitializeReceiveHandler(void)
     }
 
     if (CA_STATUS_OK != CAQueueingThreadInitialize(g_recvQueueHandle, g_edrThreadPool,
-            CAAdapterDataReceiverHandler, CAEDRDataDestroyer))
+                                                   CAAdapterDataReceiverHandler,
+                                                   CAEDRDataDestroyer))
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread");
         return CA_STATUS_FAILED;
@@ -502,7 +499,7 @@ CAResult_t CAEDRInitializeReceiveHandler(void)
     return CA_STATUS_OK;
 }
 
-void CAAdapterTerminateQueues(void)
+void CAAdapterTerminateQueues()
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
@@ -525,7 +522,7 @@ void CAAdapterDataSendHandler(void *context)
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterDataSendHandler");
 
     CAEDRData *message = (CAEDRData *) context;
-    if (message == NULL)
+    if (NULL == message)
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!");
         return;
@@ -535,30 +532,34 @@ void CAAdapterDataSendHandler(void *context)
     const char *serviceUUID = NULL;
     uint32_t sentLength = 0;
 
-    if(NULL == message->remoteEndpoint)
+    if (NULL == message->remoteEndpoint)
     {
         OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "remoteEndpoint is not available");
     }
+    else
+    {
+        remoteAddress = message->remoteEndpoint->addressInfo.BT.btMacAddress;
+        serviceUUID = message->remoteEndpoint->resourceUri;
+    }
 
-    remoteAddress = message->remoteEndpoint->addressInfo.BT.btMacAddress;
-    serviceUUID = message->remoteEndpoint->resourceUri;
-
+    uint32_t dataSegmentLength = message->dataLen + CA_HEADER_LENGTH;
+    uint32_t dataLen = message->dataLen;
     OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "checking for fragmentation and the dataLen is %d",
               message->dataLen);
 
     char *header = (char *) OICCalloc(CA_HEADER_LENGTH, sizeof(char));
-    VERIFY_NON_NULL_VOID(header, EDR_ADAPTER_TAG, "Malloc failed");
+    VERIFY_NON_NULL_VOID(header, EDR_ADAPTER_TAG, "Memory allocation failed");
 
-    char* dataSegment = (char *) OICCalloc(message->dataLen + CA_HEADER_LENGTH, sizeof(char));
+    char* dataSegment = (char *) OICCalloc(dataSegmentLength, sizeof(char));
     if (NULL == dataSegment)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Malloc failed");
+        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed");
         OICFree(header);
         return;
     }
 
-    CAResult_t result = CAGenerateHeader(header, message->dataLen);
-    if (CA_STATUS_OK != result )
+    CAResult_t result = CAGenerateHeader(header, dataLen);
+    if (CA_STATUS_OK != result)
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Generate header failed");
         OICFree(header);
@@ -568,25 +569,23 @@ void CAAdapterDataSendHandler(void *context)
 
     memcpy(dataSegment, header, CA_HEADER_LENGTH);
     OICFree(header);
-    int32_t length = 0;
-    if (CA_SUPPORTED_BLE_MTU_SIZE >= message->dataLen)
+    uint32_t length = 0;
+    if (CA_SUPPORTED_EDR_MTU_SIZE > dataSegmentLength)
     {
-        length = message->dataLen + CA_HEADER_LENGTH;
-        OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "length [%d]", length);
-        memcpy(dataSegment + CA_HEADER_LENGTH, message->data, message->dataLen);
+        length = dataSegmentLength;
+        memcpy(dataSegment + CA_HEADER_LENGTH, message->data, dataLen);
     }
     else
     {
-        length =  CA_SUPPORTED_BLE_MTU_SIZE;
-        OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "length [%d]", length);
+        length =  CA_SUPPORTED_EDR_MTU_SIZE;
         memcpy(dataSegment + CA_HEADER_LENGTH, message->data,
-               CA_SUPPORTED_BLE_MTU_SIZE - CA_HEADER_LENGTH);
+               CA_SUPPORTED_EDR_MTU_SIZE - CA_HEADER_LENGTH);
     }
 
-    int32_t iter = message->dataLen / CA_SUPPORTED_BLE_MTU_SIZE;
-    int32_t index = 0;
-    if (CA_STATUS_OK != CAEDRClientSendData(remoteAddress, serviceUUID,
-                                                dataSegment, length, &sentLength))
+    uint32_t iter = dataSegmentLength / CA_SUPPORTED_EDR_MTU_SIZE;
+    uint32_t index = 0;
+    if (CA_STATUS_OK != CAEDRClientSendData(remoteAddress, serviceUUID, dataSegment, length,
+                                            &sentLength))
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed");
         OICFree(dataSegment);
@@ -600,21 +599,22 @@ void CAAdapterDataSendHandler(void *context)
         OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "Sending the chunk number [%d]", index);
 
         if (CA_STATUS_OK != CAEDRClientSendData(remoteAddress, serviceUUID,
-                    message->data + ((index * CA_SUPPORTED_BLE_MTU_SIZE) - CA_HEADER_LENGTH),
-                    CA_SUPPORTED_BLE_MTU_SIZE, &sentLength))
+                    message->data + ((index * CA_SUPPORTED_EDR_MTU_SIZE) - CA_HEADER_LENGTH),
+                    CA_SUPPORTED_EDR_MTU_SIZE, &sentLength))
         {
             OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed");
             return;
         }
     }
 
-    if (message->dataLen / CA_SUPPORTED_BLE_MTU_SIZE)
+    uint32_t remainingLen = dataSegmentLength % CA_SUPPORTED_EDR_MTU_SIZE;
+    if (remainingLen &&  (dataSegmentLength > CA_SUPPORTED_EDR_MTU_SIZE))
     {
         // send the last segment of the data (Ex: 22 bytes of 622 bytes of data when MTU is 200)
         OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Sending the last chunk");
         if (CA_STATUS_OK != CAEDRClientSendData(remoteAddress, serviceUUID,
-                    message->data + (index * CA_SUPPORTED_BLE_MTU_SIZE) - CA_HEADER_LENGTH,
-                    message->dataLen % CA_SUPPORTED_BLE_MTU_SIZE + CA_HEADER_LENGTH, &sentLength))
+                    message->data + (index * CA_SUPPORTED_EDR_MTU_SIZE) - CA_HEADER_LENGTH,
+                    remainingLen, &sentLength))
         {
             OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed");
             return;
@@ -625,14 +625,14 @@ void CAAdapterDataSendHandler(void *context)
 }
 
 CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUID,
-                                      const void *data, uint32_t dataLength, uint32_t *sentLength)
+                               const void *data, uint32_t dataLength, uint32_t *sentLength)
 {
 
     // Send the first segment with the header.
     if ((NULL != remoteAddress) && (0 < strlen(remoteAddress))) //Unicast data
     {
-        if (CA_STATUS_OK != CAEDRClientSendUnicastData(remoteAddress, serviceUUID,
-                data, dataLength, sentLength))
+        if (CA_STATUS_OK != CAEDRClientSendUnicastData(remoteAddress, serviceUUID, data,
+                                                       dataLength, sentLength))
         {
             OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send unicast data !");
             return CA_STATUS_FAILED;
@@ -641,8 +641,8 @@ CAResult_t CAEDRClientSendData(const char *remoteAddress, const char *serviceUUI
     else
     {
         OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "sending multicast data : %s", data);
-        if (CA_STATUS_OK != CAEDRClientSendMulticastData(serviceUUID, data,
-                dataLength, sentLength))
+        if (CA_STATUS_OK != CAEDRClientSendMulticastData(serviceUUID, data, dataLength,
+                                                         sentLength))
         {
             OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send multicast data !");
             return CA_STATUS_FAILED;
@@ -656,7 +656,7 @@ void CAAdapterDataReceiverHandler(void *context)
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN_CAAdapterDataReceiverHandler");
 
     CAEDRData *message = (CAEDRData *) context;
-    if (message == NULL)
+    if (NULL == message)
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!");
         return;
@@ -670,14 +670,13 @@ void CAAdapterDataReceiverHandler(void *context)
     if (!g_isHeaderAvailable)
     {
         totalDataLen = CAParseHeader((char*)message->data);
-        if (totalDataLen == 0)
+        if (0 == totalDataLen)
         {
-            OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "totalDataLen is zero");
+            OIC_LOG(ERROR, EDR_ADAPTER_TAG, "totalDataLen is zero");
             return;
         }
 
-        OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "Total data to be accumulated [%d] bytes",
-                  totalDataLen);
+        OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "Total data to be accumulated [%d] bytes", totalDataLen);
 
         defragData = (char *) OICMalloc(sizeof(char) * totalDataLen);
         if (!defragData)
@@ -689,8 +688,7 @@ void CAAdapterDataReceiverHandler(void *context)
         const char *remoteAddress = message->remoteEndpoint->addressInfo.BT.btMacAddress;
         const char *serviceUUID = message->remoteEndpoint->resourceUri;
 
-        remoteEndpoint = CAAdapterCreateRemoteEndpoint(CA_EDR, remoteAddress,
-                         serviceUUID);
+        remoteEndpoint = CAAdapterCreateRemoteEndpoint(CA_EDR, remoteAddress, serviceUUID);
 
         memcpy(defragData + recvDataLen, message->data + CA_HEADER_LENGTH,
                message->dataLen - CA_HEADER_LENGTH);
@@ -754,28 +752,26 @@ CAResult_t CAAdapterStopQueue()
     return CA_STATUS_OK;
 }
 
-void CAAdapterRecvData(const char *remoteAddress, const void *data,
-                                    uint32_t dataLength, uint32_t *sentLength)
+void CAAdapterRecvData(const char *remoteAddress, const void *data, uint32_t dataLength,
+                       uint32_t *sentLength)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
     if (false == g_adapterState)
     {
-        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
         *sentLength = 0;
         return;
     }
 
-    char *serviceUUID = OIC_EDR_SERVICE_ID;
-
     // Input validation
-    VERIFY_NON_NULL_VOID(serviceUUID, EDR_ADAPTER_TAG, "service UUID is null");
     VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null");
     VERIFY_NON_NULL_VOID(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null");
 
+    static const char serviceUUID[] = OIC_EDR_SERVICE_ID;
     // Create remote endpoint
     CARemoteEndpoint_t *remoteEndpoint = CAAdapterCreateRemoteEndpoint(CA_EDR, remoteAddress,
-                                         serviceUUID);
+                                                                       serviceUUID);
     if (NULL == remoteEndpoint)
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
@@ -784,18 +780,17 @@ void CAAdapterRecvData(const char *remoteAddress, const void *data,
 
     // Add message to data queue
     CAEDRData *edrData =  CACreateEDRData(remoteEndpoint, data, dataLength);
-    CAQueueingThreadAddData(g_recvQueueHandle, edrData, sizeof(CARemoteEndpoint_t));
+    CAQueueingThreadAddData(g_recvQueueHandle, edrData, sizeof(CAEDRData));
     *sentLength = dataLength;
 
     // Free remote endpoint
     CAAdapterFreeRemoteEndpoint(remoteEndpoint);
 
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
-    return;
 }
 
-CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID,
-                               const void *data, uint32_t dataLength, uint32_t *sentLength)
+CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const void *data,
+                             uint32_t dataLength, uint32_t *sentLength)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterSendData");
 
@@ -812,7 +807,7 @@ CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID,
 
     // Create remote endpoint
     CARemoteEndpoint_t *remoteEndpoint = CAAdapterCreateRemoteEndpoint(CA_EDR, remoteAddress,
-                                         serviceUUID);
+                                                                       serviceUUID);
     if (NULL == remoteEndpoint)
     {
         OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
@@ -841,9 +836,9 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
         CAEDRGetInterfaceInformation(&g_localConnectivity);
     }
 
-    if(CA_INTERFACE_UP == status)
+    if (CA_INTERFACE_UP == status)
     {
-        if(false == g_adapterState)
+        if (false == g_adapterState)
         {
             // Get Bluetooth adapter state
             bool adapterState = false;
@@ -863,7 +858,7 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
             g_adapterState = true;
             CAAdapterStartQueue();
             // starting RFCommServer
-            if(true == g_serverState)
+            if (true == g_serverState)
             {
                 CAStartServer();
                 g_serverState = false;
@@ -875,15 +870,15 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
         g_adapterState = false;
     }
 
-    // Notity to upper layer
+    // Notify to upper layer
     if (g_networkChangeCallback && g_localConnectivity && g_edrThreadPool)
     {
         // Add notification task to thread pool
         CAEDRNetworkEvent *event = CAEDRCreateNetworkEvent(g_localConnectivity, status);
         if (NULL != event)
         {
-            if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool, CAEDROnNetworkStatusChanged,
-                    event))
+            if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool,
+                                                        CAEDROnNetworkStatusChanged,event))
             {
                 OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create threadpool!");
                 return;
@@ -891,7 +886,7 @@ void CAEDRNotifyNetworkStatus(CANetworkStatus_t status)
         }
     }
 
-    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
+    OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "OUT");
 }
 
 void CAEDROnNetworkStatusChanged(void *context)
@@ -906,7 +901,7 @@ void CAEDROnNetworkStatusChanged(void *context)
 
     CAEDRNetworkEvent *networkEvent = (CAEDRNetworkEvent *) context;
 
-    // Notity to upper layer
+    // Notify to upper layer
     if (g_networkChangeCallback)
     {
         g_networkChangeCallback(networkEvent->info, networkEvent->status);
@@ -972,8 +967,7 @@ CAEDRData *CACreateEDRData(const CARemoteEndpoint_t *remoteEndpoint, const void
 
 void CAFreeEDRData(CAEDRData *edrData)
 {
-    if (!edrData)
-        return;
+    VERIFY_NON_NULL_VOID(edrData, EDR_ADAPTER_TAG, "edrData is NULL");
 
     CAAdapterFreeRemoteEndpoint(edrData->remoteEndpoint);
     OICFree(edrData->data);
index d042e7d..6e5fdcd 100644 (file)
@@ -1,4 +1,4 @@
-/* ****************************************************************
+/******************************************************************
  *
  * Copyright 2014 Samsung Electronics All Rights Reserved.
  *
@@ -26,6 +26,7 @@
 
 #include <string.h>
 #include <bluetooth.h>
+
 #include "caedrinterface.h"
 #include "caedrdevicelist.h"
 #include "caedrutils.h"
@@ -45,7 +46,7 @@ static CAEDRNetworkStatusCallback g_edrNetworkChangeCallback = NULL;
 static void CAEDRAdapterStateChangeCallback(int result, bt_adapter_state_e adapterState,
                                             void *userData);
 
-CAResult_t CAEDRInitializeNetworkMonitor()
+CAResult_t CAEDRInitializeNetworkMonitor(const u_thread_pool_t threadPool)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
index c0ee01c..7d8be13 100644 (file)
@@ -1,4 +1,4 @@
-/* ****************************************************************
+/******************************************************************
  *
  * Copyright 2014 Samsung Electronics All Rights Reserved.
  *
  * This file provides the APIs to start and stop RFCOMM server.
  */
 
-
 #include <string.h>
 #include <bluetooth.h>
-#include "caedrinterface.h"
 
+#include "caedrinterface.h"
 #include "caadapterutils.h"
 #include "caedrutils.h"
 #include "logger.h"
@@ -55,8 +54,8 @@ CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_po
     bt_error_e err = bt_adapter_is_service_used(serviceUUID, &isRunning);
     if (BT_ERROR_NONE != err)
     {
-        OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG,
-                  "Unable to find whether service is already running or not! erorr num[%x]", err);
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
+                  "Unable to find whether service is already running or not! error num[%x]", err);
         return CA_STATUS_FAILED;
     }
 
@@ -71,18 +70,15 @@ CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_po
     err = bt_socket_create_rfcomm(serviceUUID, &socketFD);
     if (BT_ERROR_NONE != err)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to create rfcomm socket!, error num [%x]",
-                  err);
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to create rfcomm socket!, error num [%x]", err);
         return CA_STATUS_FAILED;
     }
 
     // Start listening and accepting
-    err = bt_socket_listen_and_accept_rfcomm(socketFD,
-                                g_maxPendingConnections);
+    err = bt_socket_listen_and_accept_rfcomm(socketFD, g_maxPendingConnections);
     if (BT_ERROR_NONE != err)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed in listen rfcomm socket!, error num [%x]",
-                  err);
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed in listen rfcomm socket!, error num [%x]", err);
 
         bt_socket_destroy_rfcomm(socketFD);
         return CA_STATUS_FAILED;
@@ -101,8 +97,7 @@ CAResult_t CAEDRServerStop(int serverFD)
     bt_error_e err = bt_socket_destroy_rfcomm(serverFD);
     if (BT_ERROR_NONE != err)
     {
-        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed close server socket!, error num [%x]",
-                  err);
+        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed close server socket!, error num [%x]", err);
         return CA_STATUS_FAILED;
     }