Demo Glucose Service
Dependencies: BLE_API mbed nRF51822
Fork of BLE_HeartRate by
BLE_Glucose_demo implements the Glucose Service which enables a collector device to connect and interact with.
There is a brief sample code edited with Android Studio for demo this BLE_Glucose_demo example, and it is public on github, everyone can clone it by this URL: https://github.com/Marcomissyou/BluetoothLeGlucose.git. It is convenient for you to development your BLE idea.
There is also provided apk file so you can download and install it directly then demo this code, but make sure your Android phone supports Bluetooth 4.0. /media/uploads/Marcomissyou/bleglucoseservice.apk
Diff: main.cpp
- Revision:
- 46:ee7c55907f36
- Parent:
- 45:98c5a34b07a4
- Child:
- 47:430545f41113
--- a/main.cpp Mon Sep 29 18:27:56 2014 +0000 +++ b/main.cpp Tue Sep 30 00:07:32 2014 +0000 @@ -19,20 +19,8 @@ #include "HeartRateService.h" #include "BatteryService.h" #include "DeviceInformationService.h" -#include "DFUService.h" BLEDevice ble; -// DigitalOut led1(LED1); - -#define NEED_CONSOLE_OUTPUT 0 /* Set this if you need debug messages on the console; - * it will have an impact on code-size and power consumption. */ - -#if NEED_CONSOLE_OUTPUT -Serial pc(USBTX, USBRX); -#define DEBUG(...) { pc.printf(__VA_ARGS__); } -#else -#define DEBUG(...) /* nothing */ -#endif /* #if NEED_CONSOLE_OUTPUT */ const static char DEVICE_NAME[] = "Nordic_HRM"; static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE, @@ -42,15 +30,11 @@ void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { - DEBUG("Disconnected handle %u!\n\r", handle); - DEBUG("Restarting the advertising process\n\r"); - ble.startAdvertising(); + ble.startAdvertising(); // restart advertising } void periodicCallback(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; @@ -58,11 +42,9 @@ int main(void) { - // led1 = 1; Ticker ticker; ticker.attach(periodicCallback, 1); - DEBUG("Initialising the nRF51822\n\r"); ble.init(); ble.onDisconnection(disconnectionCallback); @@ -73,7 +55,6 @@ /* Setup auxiliary services. */ BatteryService battery(ble); DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1"); - DFUService dfuService(ble); /* Setup advertising. */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);