Heart Rate Monitor example for Delta BLE platform

This is a very basic BLE example for DELTA DFBM-NQ620 and DELTA DFCM-NNN50 platforms. This example is doing HRM (Heart Rate Monitor) application, the service spec can be found in here Once compiled and download to DELTA platforms, the module start advertising while LED1 is blinking. User can download the APP 'nRF Connect' available in both App Store and Google Play to scan the adverting and connect to the module.

Note that printf use the baudrate 9600 8n1 as default. In Windows, user could find the ready to use com port number in Device Manager and shown as 'mbed Serial Port(COM#)'

/media/uploads/tsungta/mbed_serial_port_1.png

Files at this revision

API Documentation at this revision

Comitter:
tsungta
Date:
Wed Mar 29 14:34:47 2017 +0000
Parent:
2:d4b007ee15dc
Commit message:
Add Serial to use for printf

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d4b007ee15dc -r f2861d705e88 main.cpp
--- a/main.cpp	Wed Mar 29 07:00:29 2017 +0000
+++ b/main.cpp	Wed Mar 29 14:34:47 2017 +0000
@@ -20,9 +20,10 @@
 #include "ble/services/BatteryService.h"
 #include "ble/services/DeviceInformationService.h"
 
+Serial uart(USBTX, USBRX);//9600 8n1 is set as default
 DigitalOut led1(LED1);
 
-const static char     DEVICE_NAME[]        = "DELTA_HRM1";
+const static char     DEVICE_NAME[]        = "DELTA_HRM";
 static const uint16_t uuid16_list[]        = {GattService::UUID_HEART_RATE_SERVICE,
                                               GattService::UUID_DEVICE_INFORMATION_SERVICE};
 static volatile bool  triggerSensorPolling = false;
@@ -35,7 +36,7 @@
 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
 {
     BLE::Instance(BLE::DEFAULT_INSTANCE).gap().startAdvertising(); // restart advertising
-    printf("BLE Disconnected, restart advertising!!\r\n");
+    uart.printf("BLE Disconnected, restart advertising!!\r\n");
 }
 
 void periodicCallback(void)
@@ -72,12 +73,12 @@
     ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.gap().setAdvertisingInterval(1000); /* 1000ms */
     ble.gap().startAdvertising();
-    printf("BLE start Advertising!!\r\n");
+    uart.printf("BLE start Advertising!!\r\n");
 }
 
 int main(void)
 {
-    printf("APPLICATION START!!\r\n");
+    uart.printf("APPLICATION START!!\r\n");
     led1 = 1;
     Ticker ticker;
     ticker.attach(periodicCallback, 1); // blink LED every second
@@ -105,7 +106,7 @@
             }
 
             hrService->updateHeartRate(hrmCounter);
-            printf("notify hrmCounter: %i\r\n", hrmCounter);
+            uart.printf("notify hrmCounter: %i\r\n", hrmCounter);
         } else {
             ble.waitForEvent(); // low power wait for event
         }