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:
20:fb286f736dc4
Parent:
19:ebe7b59d9c76
Child:
21:f92bb1c80538
--- a/main.cpp	Sun Dec 28 14:44:41 2014 +0000
+++ b/main.cpp	Mon Dec 29 17:09:29 2014 +0000
@@ -338,34 +338,38 @@
     int32_t i32_C_nRF; sd_temp_get(&i32_C_nRF); //Read the nRF Internal Temperature (Die in 0.25'C steps, offset +16'C)
     sIOn4.s.iTempC100 = (i32_C_nRF*25)-(1600);  //Save temperature in hundreths (0.01'C steps relative to 0'C)(.25'C * 25=.01'C steps)
     //float fTemperature = (float(i32_temp)/4.0) - 16.0;   // Scale&Shift (0.25'C from -16'C?)
+
+    ble.updateCharacteristicValue(IOr4.getValueHandle(), sIOr4.pu, sizeof(sIOr4)); // Update r4 data so ready for read (Doesn't Trigger Notify)
 }
 
+//PR: Notify: Doing Notify of Press and Release since n4 contains status of multiple inputs so need both bits to be correct. If Notify Characteristic is single button then notify could be on just press or just release.
+
 void onB1press(void)        // B1 Press == *Notify*
 {   // Update Characteristics that include this button
     uB1press++;             // Flag/Count Events (allows detect any missed processing)
     vFillIO();              // Prepare IO Characteristic data
-    ble.updateCharacteristicValue(IOn4.getValueHandle(), sIOn4.pu, sizeof(sIOn4));// Notify
+    ble.updateCharacteristicValue(IOn4.getValueHandle(), sIOn4.pu, sizeof(sIOn4));// Triggers Notify (Reading n4 at other times may have old data)
     DEBUG("\n B1p%d", uB1press); vShowIO();
 };
 void onB1release(void)      // B1 Release
 {   // Update Characteristics that include this button
     uB1release++;           // Flag/Count Events (allows detect any missed processing)
     vFillIO();              // Prepare IO Characteristic data
-    ble.updateCharacteristicValue(IOr4.getValueHandle(), sIOr4.pu, sizeof(sIOr4));
+    ble.updateCharacteristicValue(IOn4.getValueHandle(), sIOn4.pu, sizeof(sIOn4));// Triggers Notify (Reading n4 at other times may have old data)
     DEBUG("\n B1r%d", uB1release); vShowIO();
 };
 void onB2press(void)        // B2 Press
 {   // Update Characteristics that include this button
     uB2press++;             // Flag/Count Events (allows detect any missed processing)
     vFillIO();              // Prepare IO Characteristic data
-    ble.updateCharacteristicValue(IOr4.getValueHandle(), sIOr4.pu, sizeof(sIOr4));
+    ble.updateCharacteristicValue(IOn4.getValueHandle(), sIOn4.pu, sizeof(sIOn4));// Triggers Notify (Reading n4 at other times may have old data)
     DEBUG("\n B2p%d", uB2press); vShowIO();
 };
 void onB2release(void)      // B2 Release
 {   // Update Characteristics that include this button
     uB2release++;           // Flag/Count Events (allows detect any missed processing)
     vFillIO();              // Prepare IO Characteristic data
-    ble.updateCharacteristicValue(IOn4.getValueHandle(), sIOn4.pu, sizeof(sIOn4));// Notify
+    ble.updateCharacteristicValue(IOn4.getValueHandle(), sIOn4.pu, sizeof(sIOn4));// Triggers Notify (Reading n4 at other times may have old data)
     DEBUG("\n B2r%d", uB2release); vShowIO();
 };