This is a simple program to work with RedBearLab BLE Controller App. Type something from the Terminal to send to the BLEController App or vice verse. Characteristics received from App will print on Terminal.

Dependencies:   BLE_API mbed nRF51822

Fork of nRF51822_SimpleChat by RedBearLab

Revision:
3:2b4b55b7f467
Parent:
2:4b66b69c7ecb
Child:
4:4b070c445de4
--- a/main.cpp	Mon Jul 27 06:52:44 2015 +0000
+++ b/main.cpp	Wed Sep 02 14:09:36 2015 +0000
@@ -61,6 +61,22 @@
 
 GattService         uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *));
 
+// Temperature 0-100 C, simulated
+static uint8_t      temperature = 32;
+GattCharacteristic  tempMeas(GattCharacteristic::UUID_TEMPERATURE_MEASUREMENT_CHAR, (uint8_t *)temperature, sizeof(temperature), sizeof(temperature),
+                           GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
+GattCharacteristic *temperatureChars[] = {&tempMeas };
+// TODO add custom service instead of Heart rate
+GattService         temperatureService(GattService::UUID_HEART_RATE_SERVICE, temperatureChars, sizeof(temperatureChars) / sizeof(GattCharacteristic *));
+
+static uint8_t      batteryLevel = 0xAA;
+GattCharacteristic  batteryPercentage(GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, (uint8_t *)batteryLevel, sizeof(batteryLevel), sizeof(batteryLevel),
+                           GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
+GattCharacteristic *batteryChars[] = {&batteryPercentage };
+GattService         batteryService(GattService::UUID_BATTERY_SERVICE, batteryChars, sizeof(batteryChars) / sizeof(GattCharacteristic *));
+
+
+
 
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
@@ -131,7 +147,9 @@
     // 100ms; in multiples of 0.625ms. 
     ble.setAdvertisingInterval(160);
 
-    ble.addService(uartService);
+    //ble.addService(uartService);
+    ble.addService(temperatureService);
+    ble.addService(batteryService);
     
     ble.startAdvertising(); 
     pc.printf("Advertising Start \r\n");