gjhn

Dependents:   BLE_GENERALE

Fork of X_NUCLEO_IDB0XA1 by ST

Revision:
186:7e3a549b9678
Parent:
182:e7cff2f17ef9
Parent:
181:749071129d2e
Child:
187:2e517d3ddd71
--- a/source/BlueNRGGap.cpp	Thu Nov 19 14:23:44 2015 +0100
+++ b/source/BlueNRGGap.cpp	Thu Nov 19 14:51:40 2015 +0100
@@ -998,9 +998,30 @@
 
 static void radioScanning(void)
 {
+  ble_error_t ret;
+
   GapScanningParams* scanningParams = BlueNRGGap::getInstance().getScanningParams();
 
-  BlueNRGGap::getInstance().startRadioScan(*scanningParams);
+  ret = BlueNRGGap::getInstance().startRadioScan(*scanningParams);
+
+  // On error, reschedule myself
+  // NOTE: this workaround causes a potential risk for an endless loop!!!
+  if(ret != BLE_ERROR_NONE) {
+    minar::Scheduler::postCallback(radioScanning).delay(minar::milliseconds(100));
+  }
+}
+
+static void makeConnection(void)
+{
+  ble_error_t ret;
+
+  ret = BlueNRGGap::getInstance().createConnection();
+
+  // On error, reschedule myself
+  // NOTE: this workaround causes a potential risk for an endless loop!!!
+  if(ret != BLE_ERROR_NONE) {
+    minar::Scheduler::postCallback(makeConnection).delay(minar::milliseconds(100));
+  }
 }
 
 static void makeConnection(void)
@@ -1202,7 +1223,7 @@
   (void)connectionParams;
   (void)scanParams;
 
-    // Save the peer address
+  // Save the peer address
   for(int i=0; i<BDADDR_SIZE; i++) {
     _peerAddr[i] = peerAddr[i];
   }