Rene Miedema / Mbed 2 deprecated BLE_Feedback

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_HeartRate by Bluetooth Low Energy

Revision:
63:3c5ca3832415
Parent:
56:83623419d5e4
Child:
64:4ced7a1586b0
--- a/main.cpp	Mon May 18 09:05:19 2015 +0000
+++ b/main.cpp	Fri Jun 12 08:23:05 2015 +0000
@@ -16,8 +16,8 @@
 
 #include "mbed.h"
 #include "BLEDevice.h"
-#include "HeartRateService.h"
-#include "DeviceInformationService.h"
+#include "ble_feedback.h"
+
 
 /* Enable the following if you need to throttle the connection interval. This has
  * the effect of reducing energy consumption after a connection is made;
@@ -27,10 +27,8 @@
 
 BLEDevice  ble;
 DigitalOut led1(LED1);
+Serial pc(USBTX, USBRX); // tx, rx
 
-const static char     DEVICE_NAME[]        = "HRM1";
-static const uint16_t uuid16_list[]        = {GattService::UUID_HEART_RATE_SERVICE,
-                                              GattService::UUID_DEVICE_INFORMATION_SERVICE};
 static volatile bool  triggerSensorPolling = false;
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
@@ -53,24 +51,11 @@
     Ticker ticker;
     ticker.attach(periodicCallback, 1); // blink LED every second
 
-    ble.init();
     ble.onDisconnection(disconnectionCallback);
 
     /* Setup primary service. */
-    uint8_t hrmCounter = 100; // init HRM to 100bps
-    HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
-
-    /* Setup auxiliary service. */
-    DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
-
-    /* Setup advertising. */
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
-    ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
-    ble.setAdvertisingInterval(1000);
-    ble.startAdvertising();
+    uint8_t battery = 100; 
+    FeedbackService FService(ble);
 
     // infinite loop
     while (1) {
@@ -78,17 +63,13 @@
         if (triggerSensorPolling && ble.getGapState().connected) {
             triggerSensorPolling = false;
 
-            // Do blocking calls or whatever is necessary for sensor polling.
-            // In our case, we simply update the HRM measurement. 
-            hrmCounter++;
+            battery--;
             
-            //  100 <= HRM bps <=175
-            if (hrmCounter == 175) {
-                hrmCounter = 100;
+            if (battery == 0) {
+                battery = 100;
             }
-            
-            // update bps
-            hrService.updateHeartRate(hrmCounter);
+            pc.printf("\n\r geschreven %d \n\r", FService.getTest());
+            FService.updateBatteryValue(battery);
         } else {
             ble.waitForEvent(); // low power wait for event
         }