nordic

Fork of nRF51822 by Nordic Semiconductor

Revision:
544:53215259c0d2
Parent:
543:1bf9c597f44f
Child:
545:9e3d053ad4ec
diff -r 1bf9c597f44f -r 53215259c0d2 source/btle/btle_discovery.cpp
--- a/source/btle/btle_discovery.cpp	Mon Jan 11 10:19:02 2016 +0000
+++ b/source/btle/btle_discovery.cpp	Mon Jan 11 10:19:03 2016 +0000
@@ -97,16 +97,24 @@
 
         case BLE_GATTC_EVT_DESC_DISC_RSP: {
             uint16_t conn_handle = p_ble_evt->evt.gattc_evt.conn_handle;
+            uint16_t status = p_ble_evt->evt.gattc_evt.gatt_status;
+            ble_gattc_evt_desc_disc_rsp_t discovered_descriptors = p_ble_evt->evt.gattc_evt.params.desc_disc_rsp;
 
-            if (p_ble_evt->evt.gattc_evt.gatt_status != BLE_GATT_STATUS_SUCCESS) { 
-                characteristicDescriptorDiscoverer.terminate(conn_handle);
-                return;
+            switch(status) { 
+                case BLE_GATT_STATUS_SUCCESS:
+                    characteristicDescriptorDiscoverer.process(
+                        conn_handle, 
+                        discovered_descriptors
+                    );                
+                    break;
+                case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
+                    // end of discovery 
+                    characteristicDescriptorDiscoverer.terminate(conn_handle, BLE_ERROR_NONE);
+                    break;
+                default:
+                    characteristicDescriptorDiscoverer.terminate(conn_handle, BLE_ERROR_UNSPECIFIED);
+                    break;
             }
-
-            characteristicDescriptorDiscoverer.process(
-                conn_handle, 
-                /* discoveredDescriptors */ p_ble_evt->evt.gattc_evt.params.desc_disc_rsp
-            );
         }   break;
     }