Experimental BLE project showing how IO can be made with an App over BLE. Pointer to matching App will be added when ready, initially this works with: - Android App [nRF-Master Control Panel], supports Write,Read,Notify - Android Project [BluetoothLeGatt]

Dependencies:   BLE_API mbed nRF51822

This is an experimental project for BLE (Bluetooth LE == Bluetooth Low Energy == Bluetooth Smart).

  • It supports general IO over BLE with Read/Notify/Write support.
  • It is compatible with FOTA using Android App "nRF Master Control Panel" (20150126)
  • IO supported by:
    • Custom Android App is in the WIKI under: Android-App, developed from Android Sample "BluetoothLeGatt"
    • Android App: nRF-MCP (Master Control Panel)
    • iOS App LightBlue.
    • General HRM, HTM, Battery and similar apps should be able to access the matching services.
  • It includes combinations of code from other projects, alternative code included can be tried by moving comments (, //)
  • 20150126 bleIO r25: It compiles for both "Nordic nRF51822" and "Nordic nRF51822 FOTA" platforms
  • 20150126 The matching bleIO App (in wiki) doesn't support FOTA yet, use Android App "nRF Master Control Panel"

Feedback and ideas greatly appreciated!!!

Revision:
2:c77c2b06d604
Parent:
1:4a25d917fb6a
Child:
3:a98203f84063
--- a/main.cpp	Thu Dec 11 13:44:13 2014 +0000
+++ b/main.cpp	Sat Dec 13 14:14:39 2014 +0000
@@ -62,6 +62,13 @@
     #define DEBUG(...)            //Do Nothing
 #endif 
 
+//========== This Section is to Create Debug output showing variable prep before main() ==========
+bool u8_prep_dummy(void) {
+    DEBUG("\n\nBLE: ____Prep Memory____\n");
+    return true;
+}
+const bool bPrep = u8_prep_dummy();
+
 //==========LEDs==========
 //LEDs:
 //DigitalOut  out_led1(LED1);             //PR: Firmware heartbeat
@@ -93,6 +100,30 @@
     //GattService::UUID_SCAN_PARAMETERS_SERVICE,        = 0x1813,
  };
  
+//========== Prep UUID list (before main()) ==========
+// Gatt characteristic and service UUIDs - Readable to UUID
+const UUID stringToUUID(const char* str) {
+    uint8_t array[16] = {0x55,0x55,0x55,0x55, 0x55,0x55,0x55,0x55, 0x55,0x55,0x55,0x55, 0x55,0x55,0x55,0x55};//Prefill 'U' so fully specified even short string
+    for(int i = 0; i < strlen(str); i++) { //Don't convert unspecified bytes past end of string
+        array[i] = str[i];    
+    }
+    
+    DEBUG("UUID: Prep[%16s] --> [%02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x] %c\n", 
+        str, array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], 
+             array[8], array[9], array[10],array[11],array[12],array[13],array[14],array[15], array[15] );       
+       
+    return UUID(array);//TODO: Check if this array is safe or stack temporary??
+}
+//const UUID SCORING_GATT_SERVICE =               stringToUUID("nod.score1.serv ");
+//const UUID THRESHOLD_GATT_CHARACTERISTIC =      stringToUUID("nod.score1.thres");
+//const UUID DIVISOR_GATT_CHARACTERISTIC =        stringToUUID("nod.score1.div  ");
+//const UUID INTERVAL_US_GATT_CHARACTERISTIC =    stringToUUID("nod.score1.intus");
+// Strings to hex UUID                                         "0123456789ABCDEF"
+const UUID UUID_GATT_SERVICE_A                  = stringToUUID("com.test.servA");
+const UUID UUID_GATT_CHARACTERISTIC_A1          = stringToUUID("com.test.charA1");
+const UUID UUID_GATT_CHARACTERISTIC_A2          = stringToUUID("com.test.charA2");
+const UUID UUID_GATT_CHARACTERISTIC_SHORT       = stringToUUID("com.short");
+
 //==========Internal Temperature==========
 //Adopted From: https://developer.mbed.org/users/takafuminaka/code/BLE_HTM_by_InTempSensr/
 // Service:  https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.health_thermometer.xml