This is mandatory

Dependencies:   BLE_API mbed nRF51822 SHT21_ncleee

Revision:
1:f7fe82a00d4e
Parent:
0:7f951f57dbd2
Child:
2:654ee4b3950f
--- a/main.cpp	Mon Nov 09 18:57:46 2015 +0000
+++ b/main.cpp	Mon Nov 09 20:58:25 2015 +0000
@@ -16,14 +16,13 @@
 
 #include "mbed.h"
 #include "BLE.h"
-#include "HealthThermometerService.h"
-#include "EnvSense.h"
+#include "EnvironmentalService.h"
 
 BLE        ble;
 DigitalOut led1(LED1);
 
 const static char     DEVICE_NAME[]        = "Weather Station";
-static const uint16_t uuid16_list[]        = {EnvironmentalSensingService::SERVICE_UUID};
+static const uint16_t uuid16_list[]        = {GattService::UUID_ENVIRONMENTAL_SERVICE};
 static volatile bool  triggerSensorPolling = false;
 
 /* Restart Advertising on disconnection*/
@@ -32,12 +31,9 @@
     ble.gap().startAdvertising();
 }
 
-void periodicCallback(void)
+void blink(void)
 {
     led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
-
-    /* Note that the periodicCallback() executes in interrupt context, so it is safer to do
-     * heavy-weight sensor polling from the main thread. */
     triggerSensorPolling = true;
 }
 
@@ -45,14 +41,14 @@
 {
     led1 = 1;
     Ticker ticker;
-    ticker.attach(periodicCallback, 1);
+    ticker.attach(blink, 1);
 
     ble.init();
     ble.gap().onDisconnection(disconnectionCallback);
 
     /* Setup primary service. */
-    uint8_t currentTemperature = 42;
-    EnvironmentalSensingService thermometerService(ble, currentTemperature);
+    float currentTemperature = 42.22;
+    EnvironmentalService envService(ble);
 
     /* setup advertising */
     ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
@@ -74,8 +70,8 @@
             // }
 
             /* In our case, we simply update the dummy temperature measurement. */
-            currentTemperature += 0.1;
-            thermometerService.updateTemperature(22);
+//            currentTemperature += 0.1;
+            envService.updateTemperature(currentTemperature);
         } else {
             ble.waitForEvent();
         }