For switch science magazine

Dependencies:   BLE_API mbed nRF51822

Fork of mbed_EddystoneURL_Beacon by Roy Want

Files at this revision

API Documentation at this revision

Comitter:
roywant
Date:
Wed Aug 19 04:41:21 2015 +0000
Parent:
1:0ad7573b5918
Child:
3:159eb1a94bbb
Commit message:
On disconnect: a) Timer is stopped b) ADV parameters recreated c) starts advertizing. This is so that the ADV starts again right after disconnect. Before it only started after the long timeout, which makes it hard for the Validator to do its work.

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BLE_API.lib	Tue Aug 18 00:45:39 2015 +0000
+++ b/BLE_API.lib	Wed Aug 19 04:41:21 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/roywant/code/BLE_API/#fc73c1ddcd09
+https://developer.mbed.org/users/roywant/code/BLE_API/#13164356b568
--- a/main.cpp	Tue Aug 18 00:45:39 2015 +0000
+++ b/main.cpp	Wed Aug 19 04:41:21 2015 +0000
@@ -33,7 +33,7 @@
  *
  * The following help with this switch.
  */
-static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 15;  // Duration after power-on that config service is available.
+static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 30;  // Duration after power-on that config service is available.
 Ticker configAdvertisementTimeoutTicker;
 
 /**
@@ -44,10 +44,9 @@
     Gap::GapState_t state;
     state = ble.getGapState();
     if (!state.connected) { /* don't switch if we're in a connected state. */
+        configAdvertisementTimeoutTicker.detach(); /* disable the callback from the timeout Ticker. */
         eddystoneUrlConfig->setupEddystoneURLAdvertisements();
         ble.startAdvertising();
-
-        configAdvertisementTimeoutTicker.detach(); /* disable the callback from the timeout Ticker. */
     }
 }
 
@@ -56,6 +55,8 @@
  */
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
+    configAdvertisementTimeoutTicker.detach(); /* disable the callback from the timeout Ticker. */
+    eddystoneUrlConfig->setupEddystoneURLAdvertisements();
     ble.startAdvertising();
 }