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

Files at this revision

API Documentation at this revision

Comitter:
0xf10
Date:
Mon Jul 18 14:55:35 2016 +0000
Parent:
19:3807de5c6a58
Commit message:
force deepsleep

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3807de5c6a58 -r 7d2043754467 main.cpp
--- 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++;
         }