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:
- 8:49d8ee0aac11
- Parent:
- 7:daab8ba5139e
- Child:
- 9:5d693381e883
--- a/main.cpp Tue Jun 10 09:21:43 2014 +0000 +++ b/main.cpp Tue Jun 10 11:03:03 2014 +0100 @@ -20,8 +20,6 @@ BLEPeripheral ble; /* BLE radio driver */ DigitalOut led1(LED1); -DigitalOut led2(LED2); -Ticker flipper; Serial pc(USBTX, USBRX); /* Battery Level Service */ @@ -48,7 +46,7 @@ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ); /* Device Information service */ -uint8_t deviceName[4] = {'m', 'b', 'e', 'd'}; +static const uint8_t deviceName[] = {'m', 'b', 'e', 'd'}; GattService deviceInformationService (GattService::UUID_DEVICE_INFORMATION_SERVICE); GattCharacteristic deviceManufacturer ( GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR, @@ -62,8 +60,6 @@ GattService::UUID_HEART_RATE_SERVICE }; -void tickerCallback(void); - void timeoutCallback(void) { pc.printf("Advertising Timeout!\n\r"); @@ -104,10 +100,7 @@ /**************************************************************************/ int main(void) { - /* Setup blinky: led1 is toggled in main, led2 is toggled via Ticker */ led1 = 1; - led2 = 1; - flipper.attach(&tickerCallback, 1.0); /* Setup the local GAP/GATT event handlers */ ble.onTimeout(timeoutCallback); @@ -184,13 +177,3 @@ ble.updateCharacteristicValue(hrmRate.getHandle(), bpm, sizeof(bpm)); } } - -/**************************************************************************/ -/*! - @brief Ticker callback to switch led2 state -*/ -/**************************************************************************/ -void tickerCallback(void) -{ - led2 = !led2; -}