mbed code for UberVest health monitoring

Dependencies:   BLE_API mbed nRF51822

Revision:
2:9b977e86e2d5
Parent:
0:b6fae6eb2bfe
Child:
3:183823979708
--- a/main.cpp	Mon Oct 19 19:25:06 2015 +0000
+++ b/main.cpp	Mon Oct 19 19:29:31 2015 +0000
@@ -19,7 +19,7 @@
 #include "UberVestService.h"
 
 BLE         ble;
-DigitalOut  led1(LED1);
+DigitalOut  connectionLed(LED1);
 InterruptIn button(BUTTON1);
 BusIn ecg(p20, p23, p24, p25, p28, p29, p0, p30);
 
@@ -50,25 +50,24 @@
     buttonState = RELEASED;
 }
 
+void connectionCallback(const Gap::ConnectionCallbackParams_t *params)
+{
+    connectionLed = 1;
+}
+
 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
 {
     ble.gap().startAdvertising();
-}
-
-void periodicCallback(void)
-{
-    led1 = !led1; /* Do blinky on LED1 to indicate system aliveness. */
+    connectionLed = 0;
 }
 
 int main(void)
 {
-    led1 = 1;
-    Ticker ticker;
-    ticker.attach(periodicCallback, 1);
     button.fall(buttonPressedCallback);
     button.rise(buttonReleasedCallback);
 
     ble.init();
+    ble.gap().onConnection(connectionCallback);
     ble.gap().onDisconnection(disconnectionCallback);
 
     UberVestService uberVestService(ble, false /* initial value for button pressed */, 0);