example firmware for nRF51-Dongle to use with Opentrigger

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_Button by Bluetooth Low Energy

http://www.opentrigger.com

Revision:
20:7d2043754467
Parent:
19:3807de5c6a58
--- a/main.cpp	Tue Jun 21 19:22:32 2016 +0000
+++ b/main.cpp	Mon Jul 18 14:55:35 2016 +0000
@@ -179,9 +179,7 @@
 }
 
 int main(void)
-{
-    Ticker ticker;
-    
+{  
     // Turn off all LED's
     led1 = !0; led2 = !0; led3 = !0;
     
@@ -208,6 +206,7 @@
     button5.rise(button5ReleasedCallback);
     
     // This will make our green led blink
+    Ticker ticker;
     ticker.attach(periodicCallback, 1);
 
     BLE &ble = BLE::Instance();
@@ -223,7 +222,7 @@
         if (buttonState != IDLE) {
             if(buttonState == PRESSED)  led1=!1; 
             if(buttonState == RELEASED) led1=!0; 
-            
+            ticker.attach(periodicCallback, 1);
             updateManufacturerData();
             cnt = 0;
             buttonState = IDLE;
@@ -242,6 +241,9 @@
         if(cnt > 3){
             ble.gap().stopAdvertising();
             led3 = !0;
+            led2 = !0;
+            ticker.detach();
+            deepsleep();
         }else{
             if(!gpioSet()) cnt++;
         }