CA Error handling for LE adapter
authorjnashok <jn.ashok@samsung.com>
Thu, 21 May 2015 12:22:54 +0000 (21:22 +0900)
committerErich Keane <erich.keane@intel.com>
Mon, 29 Jun 2015 06:09:36 +0000 (06:09 +0000)
This adds error handling from LE adapter to the interface controller
Interface controller to RI Error Handling was submitted in
https://gerrit.iotivity.org/gerrit/#/c/1046/

Change-Id: If7cceb4db3a0c47c1fee6cd6814fd1257fc856e8
Signed-off-by: jnashok <jn.ashok@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1069
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/inc/caleadapter.h
resource/csdk/connectivity/inc/caleinterface.h
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/bt_le_adapter/linux/caleadapter.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/cableclient.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/cableserver.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c

index 58ffe7e..64feca3 100644 (file)
@@ -60,13 +60,15 @@ typedef struct
  *                               started at Connectivity Abstraction Layer.
  * @param  netCallback      [IN] Callback to notify the network additions to Connectivity
  *                               Abstraction Layer.
+ * @param  errorCallback    [IN] errorCallback to notify error to connectivity common logic
+ *                               layer from adapter
  * @param  handle           [IN] Threadpool Handle
  * @return #CA_STATUS_OK or Appropriate error code
  */
 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback reqRespCallback,
                           CANetworkChangeCallback netCallback,
-                          ca_thread_pool_t handle);
+                          CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
 
 /**
  * @brief Starting LE connectivity adapters.
index ff1ab29..6879214 100644 (file)
@@ -286,6 +286,33 @@ void CASetBleClientThreadPoolHandle(ca_thread_pool_t handle);
  * @retval #CA_STATUS_FAILED Operation failed
  */
 CAResult_t CAUnSetLEAdapterStateChangedCb();
+
+/**
+ * @brief This will be used to notify errors in BLE adapter
+ * @param  remoteAddress    [IN] Remote endpoint Address
+ * @param  serviceUUID      [IN] Service UUID
+ * @param  data             [IN] Data received
+ * @param  dataLength       [IN] Length of the data received
+ * @param  result           [IN] error code as per CAResult_t
+ * @return NONE
+ */
+typedef void (*CABLEErrorHandleCallback)(const char *remoteAddress, const void *data,
+                                         uint32_t dataLength, CAResult_t result);
+/**
+ * @brief  sets the error handle callback
+ * @param  callback [IN] Callback function to update error to the adapter
+ * @return NONE
+ */
+void CASetBLEClientErrorHandleCallback(CABLEErrorHandleCallback callback);
+
+
+/**
+ * @brief  sets the error handle callback
+ * @param  callback [IN] Callback function to update error to the adapter
+ * @return NONE
+ */
+void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback);
+
 #ifdef __cplusplus
 }
 #endif
index 645ff1d..1c67fba 100644 (file)
@@ -49,6 +49,7 @@ static u_arraylist_t *g_gattObjectList = NULL;
 static u_arraylist_t *g_deviceStateList = NULL;
 
 static CAPacketReceiveCallback g_packetReceiveCallback = NULL;
+static CABLEErrorHandleCallback g_clientErrorCallback;
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 static jobject g_leScanCallback = NULL;
 static jobject g_leGattCallback = NULL;
@@ -487,6 +488,11 @@ void CALEClientSetCallback(CAPacketReceiveCallback callback)
     g_packetReceiveCallback = callback;
 }
 
+void CASetBLEClientErrorHandleCallback(CABLEErrorHandleCallback callback)
+{
+    g_clientErrorCallback = callback;
+}
+
 CAResult_t CALEClientGetInterfaceInfo(char **address)
 {
     OIC_LOG(INFO, TAG, "CALEClientGetInterfaceInfo is not supported");
@@ -737,6 +743,7 @@ CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const char* data,
         if (CA_STATUS_OK != res)
         {
             OIC_LOG_V(INFO, TAG, "multicast : send has failed for this device[%s]", address);
+            g_clientErrorCallback(address, data, dataLen, res);
             (*env)->ReleaseStringUTFChars(env, jni_address, address);
             continue;
         }
index adcdc11..9f812a6 100644 (file)
@@ -44,6 +44,8 @@ static jobject g_bluetoothGattServerCallback = NULL;
 static jobject g_leAdvertiseCallback = NULL;
 
 static CAPacketReceiveCallback g_packetReceiveCallback = NULL;
+static CABLEErrorHandleCallback g_serverErrorCallback;
+
 static u_arraylist_t *g_connectedDeviceList = NULL;
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 
@@ -1616,7 +1618,7 @@ CAResult_t CALEServerStartMulticastServer()
     ret = CALEServerStartAdvertise(env, g_leAdvertiseCallback);
     if (CA_STATUS_OK != ret)
     {
-        OIC_LOG(ERROR, TAG, "CALEServerSendMulticastMessageImpl has failed");
+        OIC_LOG(ERROR, TAG, "CALEServerStartAdvertise has failed");
     }
 
     if (isAttached)
@@ -1663,7 +1665,7 @@ CAResult_t CALEServerStopMulticastServer()
     CAResult_t ret = CALEServerStopAdvertise(env, g_leAdvertiseCallback);
     if (CA_STATUS_OK != ret)
     {
-        OIC_LOG(ERROR, TAG, "CALEServerSendMulticastMessageImpl has failed");
+        OIC_LOG(ERROR, TAG, "CALEServerStopAdvertise has failed");
     }
 
     g_isStartServer = false;
@@ -2340,9 +2342,15 @@ void CASetBLEReqRespServerCallback(CABLEServerDataReceivedCallback callback)
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
+void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback)
+{
+    g_serverErrorCallback = callback;
+}
+
 CAResult_t CAUpdateCharacteristicsToGattClient(const char* address, const char *charValue,
                                                const uint32_t charValueLen)
 {
+    CAResult_t result = CA_SEND_FAILED;
     OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL(address, TAG, "env is null");
     VERIFY_NON_NULL(charValue, TAG, "device is null");
@@ -2350,12 +2358,12 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char* address, const char *
     if (address)
     {
         OIC_LOG(DEBUG, TAG, "CALEServerSendUnicastData");
-        CALEServerSendUnicastMessage(address, charValue, charValueLen);
+        result = CALEServerSendUnicastMessage(address, charValue, charValueLen);
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
 
-    return CA_STATUS_OK;
+    return result;
 }
 
 CAResult_t CAUpdateCharacteristicsToAllGattClients(const char *charValue,
@@ -2365,10 +2373,10 @@ CAResult_t CAUpdateCharacteristicsToAllGattClients(const char *charValue,
     VERIFY_NON_NULL(charValue, TAG, "device is null");
 
     OIC_LOG(DEBUG, TAG, "CALEServerSendMulticastMessage");
-    CALEServerSendMulticastMessage(charValue, charValueLen);
+    CAResult_t result = CALEServerSendMulticastMessage(charValue, charValueLen);
 
     OIC_LOG(DEBUG, TAG, "OUT");
-    return CA_STATUS_OK;
+    return result;
 }
 
 void CASetBleServerThreadPoolHandle(ca_thread_pool_t handle)
index e5e8385..877814b 100644 (file)
@@ -152,6 +152,18 @@ static ca_mutex g_bleAdapterReqRespCbMutex = NULL;
 static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
 
 /**
+ * @var g_errorHandler
+ * @brief Callback to notify error from the BLE adapter
+ */
+static CAErrorHandleCallback g_errorHandler = NULL;
+
+/**
+ * @var g_bleAdapterState
+ * @brief Storing Adapter state information
+ */
+static CAAdapterState_t g_bleAdapterState = CA_ADAPTER_DISABLED;
+
+/**
  * @ENUM CALeServerStatus
  * @brief status of BLE Server Status
  *  This ENUM provides information of LE Adapter Server status
@@ -234,10 +246,20 @@ void CATerminateBleAdapterMutex();
 */
 static void CALEDataDestroyer(void *data, uint32_t size);
 
+/**
+* @fn  CALEErrorHandler
+* @brief  prepares and notify error through error callback
+*
+* @return  void
+*/
+static void CALEErrorHandler(const char *remoteAddress, const void *data, uint32_t dataLen,
+                             CAResult_t result);
+
+
 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
                           CANetworkPacketReceivedCallback reqRespCallback,
                           CANetworkChangeCallback netCallback,
-                          ca_thread_pool_t handle)
+                          CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
 
@@ -269,8 +291,12 @@ CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
     CASetBLEReqRespClientCallback(CABLEClientReceivedData);
     CASetBLEReqRespAdapterCallback(reqRespCallback);
 
+    CASetBLEClientErrorHandleCallback(CALEErrorHandler);
+    CASetBLEServerErrorHandleCallback(CALEErrorHandler);
     CALERegisterNetworkNotifications(netCallback);
 
+    g_errorHandler = errorCallback;
+
     CAConnectivityHandler_t connHandler;
     connHandler.startAdapter = CAStartLE;
     connHandler.stopAdapter = CAStopLE;
@@ -291,8 +317,7 @@ CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
 CAResult_t CAStartLE()
 {
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
-    OIC_LOG(DEBUG, CALEADAPTER_TAG,
-        "There is no concept of unicast/multicast in LE. So This function is not implemented");
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "CAStartLE, not implemented");
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
     return CA_STATUS_OK;
 }
@@ -459,6 +484,7 @@ int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint, const void *data, uint
         {
             OIC_LOG(ERROR, CALEADAPTER_TAG,
                     "[SendLEUnicastData] CABleServerSenderQueueEnqueueMessage failed \n");
+            g_errorHandler((void *) endpoint, (void *) data, dataLen, result);
             ca_mutex_unlock(g_bleIsServerMutex);
             return -1;
         }
@@ -470,6 +496,7 @@ int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint, const void *data, uint
         {
             OIC_LOG(ERROR, CALEADAPTER_TAG,
                     "[SendLEUnicastData] CABleClientSenderQueueEnqueueMessage failed \n");
+            g_errorHandler(endpoint, data, dataLen, result);
             ca_mutex_unlock(g_bleIsServerMutex);
             return -1;
         }
@@ -498,22 +525,24 @@ int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint, const void *data, ui
     ca_mutex_lock(g_bleIsServerMutex);
     if (true  == g_isServer)
     {
-        result = CABLEServerSendData(NULL, data, dataLen);
+        result = CABLEServerSendData(endpoint, data, dataLen);
         if (CA_STATUS_OK != result)
         {
             OIC_LOG(ERROR, CALEADAPTER_TAG,
                     "[SendLEMulticastDataToAll] CABleServerSenderQueueEnqueueMessage failed" );
             ca_mutex_unlock(g_bleIsServerMutex);
+            g_errorHandler(endpoint, data, dataLen, result);
             return -1;
         }
     }
     else
     {
-        result = CABLEClientSendData(NULL, data, dataLen);
+        result = CABLEClientSendData(endpoint, data, dataLen);
         if (CA_STATUS_OK != result)
         {
             OIC_LOG(ERROR, CALEADAPTER_TAG,
                     "[SendLEMulticastDataToAll] CABleClientSenderQueueEnqueueMessage failed" );
+            g_errorHandler(endpoint, data, dataLen, result);
             ca_mutex_unlock(g_bleIsServerMutex);
             return -1;
         }
@@ -618,6 +647,7 @@ void CALEDeviceStateChangedCb( CAAdapterState_t adapter_state)
     OICStrcpy(localEndpoint.addr, sizeof(localEndpoint.addr), g_localBLEAddress);
     ca_mutex_unlock(g_bleLocalAddressMutex);
 
+    g_bleAdapterState = adapter_state;
     // Start a GattServer/Client if gLeServerStatus is SET
     if (CA_LISTENING_SERVER == gLeServerStatus)
     {
@@ -1323,6 +1353,7 @@ void CABLEServerSendDataThread(void *threadData)
         if (CA_STATUS_OK != result)
         {
             OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]", result);
+            g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
             OICFree(dataSegment);
             return;
         }
@@ -1340,6 +1371,7 @@ void CABLEServerSendDataThread(void *threadData)
             {
                 OIC_LOG_V(ERROR, CALEADAPTER_TAG,
                             "Update characteristics failed, result [%d]", result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1360,6 +1392,7 @@ void CABLEServerSendDataThread(void *threadData)
             {
                 OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
                                                    result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1372,7 +1405,9 @@ void CABLEServerSendDataThread(void *threadData)
         result = CAUpdateCharacteristicsToAllGattClients(dataSegment, length);
         if (CA_STATUS_OK != result)
         {
-            OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]", result);
+            OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
+                      result);
+            g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
             OICFree(dataSegment);
             return;
         }
@@ -1386,7 +1421,9 @@ void CABLEServerSendDataThread(void *threadData)
                          CA_SUPPORTED_BLE_MTU_SIZE);
             if (CA_STATUS_OK != result)
             {
-                OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]", result);
+                OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
+                          result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1404,7 +1441,8 @@ void CABLEServerSendDataThread(void *threadData)
             if (CA_STATUS_OK != result)
             {
                 OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
-                                                   result);
+                          result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1479,6 +1517,7 @@ void CABLEClientSendDataThread(void *threadData)
         if (CA_STATUS_OK != result)
         {
             OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]", result);
+            g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
             OICFree(dataSegment);
             return ;
         }
@@ -1496,6 +1535,7 @@ void CABLEClientSendDataThread(void *threadData)
             {
                 OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
                                                    result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1518,6 +1558,7 @@ void CABLEClientSendDataThread(void *threadData)
             {
                 OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed, result [%d]",
                                                    result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1532,7 +1573,9 @@ void CABLEClientSendDataThread(void *threadData)
         result = CAUpdateCharacteristicsToAllGattServers(dataSegment, length);
         if (CA_STATUS_OK != result)
         {
-            OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics failed (all), result [%d]", result);
+            OIC_LOG_V(ERROR, CALEADAPTER_TAG,
+                      "Update characteristics (all) failed, result [%d]", result);
+            g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
             OICFree(dataSegment);
             return ;
         }
@@ -1545,11 +1588,14 @@ void CABLEClientSendDataThread(void *threadData)
                          CA_SUPPORTED_BLE_MTU_SIZE);
             if (CA_STATUS_OK != result)
             {
-                OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics (all) failed, result [%d]", result);
+                OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics (all) failed, result [%d]",
+                          result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
-            OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Client Sent Data length  is [%d]", CA_SUPPORTED_BLE_MTU_SIZE);
+            OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Client Sent Data length  is [%d]",
+                      CA_SUPPORTED_BLE_MTU_SIZE);
         }
 
         uint32_t remainingLen = totalLength % CA_SUPPORTED_BLE_MTU_SIZE;
@@ -1562,7 +1608,9 @@ void CABLEClientSendDataThread(void *threadData)
                           remainingLen);
             if (CA_STATUS_OK != result)
             {
-                OIC_LOG_V(ERROR, CALEADAPTER_TAG, "Update characteristics (all) failed, result [%d]", result);
+                OIC_LOG_V(ERROR, CALEADAPTER_TAG,
+                          "Update characteristics (all) failed, result [%d]", result);
+                g_errorHandler(bleData->remoteEndpoint, bleData->data, bleData->dataLen, result);
                 OICFree(dataSegment);
                 return;
             }
@@ -1794,3 +1842,31 @@ void CASetBLEReqRespAdapterCallback(CANetworkPacketReceivedCallback callback)
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
 }
 
+void CALEErrorHandler(const char *remoteAddress, const void *data, uint32_t dataLen,
+                      CAResult_t result)
+{
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEErrorHandler IN");
+
+    VERIFY_NON_NULL_VOID(data, CALEADAPTER_TAG, "Data is null");
+    CAEndpoint_t *rep = OICCalloc(1, sizeof(CAEndpoint_t));
+
+    if (!rep)
+    {
+        OIC_LOG(ERROR, CALEADAPTER_TAG, "Failed to create remote endpoint !");
+        return;
+    }
+
+    if (remoteAddress)
+    {
+        OICStrcpy(rep->addr, sizeof(rep->addr), remoteAddress);
+    }
+
+    rep->adapter = CA_ADAPTER_GATT_BTLE;
+    rep->flags = CA_DEFAULT_FLAGS;
+
+    //if required, will be used to build remote end point
+    g_errorHandler(rep, data, dataLen, result);
+    CAAdapterFreeEndpoint(rep);
+
+    OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEErrorHandler OUT");
+}
index 8bfb50b..3e8d709 100644 (file)
@@ -31,8 +31,9 @@ static CANetworkPacketReceivedCallback g_leReceivedCallback = NULL;
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 
 CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
-                          CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback,
-                          ca_thread_pool_t handle)
+                          CANetworkPacketReceivedCallback reqRespCallback,
+                          CANetworkChangeCallback netCallback,
+                          CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
 {
     OIC_LOG(DEBUG, TAG, "CAInitializeLE");
 
index eb71734..54c3e69 100644 (file)
@@ -116,6 +116,12 @@ static ca_mutex g_bleClientThreadPoolMutex = NULL;
 static CABLEClientDataReceivedCallback g_bleClientDataReceivedCallback = NULL;
 
 /**
+ * @var g_clientErrorCallback
+ * @brief callback to update the error to le adapter
+ */
+static CABLEErrorHandleCallback g_clientErrorCallback;
+
+/**
  * @var g_eventLoop
  * @brief gmainLoop to manage the threads to receive the callback from the platfrom.
  */
@@ -652,6 +658,12 @@ void CASetBLEReqRespClientCallback(CABLEClientDataReceivedCallback callback)
     OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
 }
 
+
+void CASetBLEClientErrorHandleCallback(CABLEErrorHandleCallback callback)
+{
+    g_clientErrorCallback = callback;
+}
+
 CAResult_t CAStartBLEGattClient()
 {
     OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
@@ -1458,12 +1470,14 @@ CAResult_t  CAUpdateCharacteristicsToAllGattServers(const char  *data,
         /*remoteAddress will be NULL.
           Since we have to send to all destinations. pos will be used for getting remote address.
          */
-        int32_t ret = CAUpdateCharacteristicsToGattServer(NULL, data, dataLen, LE_MULTICAST, pos);
+        CAResult_t  ret = CAUpdateCharacteristicsToGattServer(NULL, data, dataLen, LE_MULTICAST, pos);
 
         if (CA_STATUS_OK != ret)
         {
             OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
                       "CAUpdateCharacteristicsToGattServer Failed with return val [%d] ", ret);
+            g_clientErrorCallback(NULL, data, dataLen, ret);
+            continue;
         }
     }
 
index baa636d..3d3cd61 100644 (file)
@@ -85,6 +85,12 @@ static bt_advertiser_h g_hAdvertiser = NULL;
 static CABLEServerDataReceivedCallback g_bleServerDataReceivedCallback = NULL;
 
 /**
+ * @var g_serverErrorCallback
+ * @brief callback to update the error to le adapter
+ */
+static CABLEErrorHandleCallback g_serverErrorCallback;
+
+/**
  * @var g_isBleGattServerStarted
  * @brief Boolean variable to keep the state of the GATTServer
  */
@@ -813,3 +819,8 @@ void CASetBLEReqRespServerCallback(CABLEServerDataReceivedCallback callback)
 
     OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "OUT");
 }
+
+void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback)
+{
+    g_serverErrorCallback = callback;
+}
index 4f227c2..0497a38 100644 (file)
@@ -158,7 +158,7 @@ void CAInitializeAdapters(ca_thread_pool_t handle)
 
 #ifdef LE_ADAPTER
     CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
-                   handle);
+                   CAAdapterErrorHandleCallback, handle);
 #endif /* LE_ADAPTER */
 
 }
index 200a9f4..6e5b85c 100644 (file)
@@ -276,7 +276,6 @@ static void CASendThreadProcess(void *threadData)
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
-                CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
                 coap_delete_pdu(pdu);
                 return;
             }
@@ -311,7 +310,6 @@ static void CASendThreadProcess(void *threadData)
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
-                CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
                 coap_delete_pdu(pdu);
                 return;
             }