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:
14:b968df367145
Parent:
13:1c67c03bbf53
Child:
15:b2c8bdef2d20
--- a/main.cpp	Sun Dec 21 21:19:17 2014 +0000
+++ b/main.cpp	Mon Dec 22 15:05:32 2014 +0000
@@ -555,23 +555,38 @@
 //==========main==========
 int main(void)
 {    
-    vShowIO();
-
-    fL1level = 1; fL1pwm = fL1level;//Start LED1=OnMax
-    fL2level = 1; fL2pwm = fL2level;//Start LED2=OnMax
+    fL1level = 1.0; fL1pwm = fL1level;//Start LED1=OnMax
+    fL2level = 0.2; fL2pwm = fL2level;//Start LED2=Dim
 
     //Restart TeraTerm just before Pressing Reset on mbed, 9600-8N1(No Flow Control)
     DEBUG("\nBLE: ___%s___\n", pcDeviceName); 
-    DEBUG(" Built UTC:[ %s %s ]  Compiler:[ %s ]\n", __DATE__, __TIME__, __VERSION__);
-    DEBUG("BLE: Connect App for Data: nRF-MCP, nRF-Toolbox:HRM/HTM, Android Sample BluetoothLeGatt, etc.\n");
-    DEBUG("BLE: BluetoothLeGatt: App->mbed: LinkLoss->AlertLevel(UpArrow)\n"); 
-    DEBUG("BLE: BluetoothLeGatt: App->mbed: BatteryService->BatteryLevel(DownArrow)\n"); 
-    DEBUG("BLE: BluetoothLeGatt: mbed->App: BatteryService->BatteryLevel->EnableNotify(ThreeDownArrows), Also App Acks the send=DEBUG('SentI')\n"); 
+
+    //ARM Predefines: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/BABJFEFG.html
+    //  *Some are numbers not strings so printf(%s) not always appropriate
+    DEBUG(" ARM Compiler Predefines:\n");
+    DEBUG("   Built UTC:[ %s %s ]\n", __DATE__, __TIME__);
+    DEBUG("   __arm__[%d]", __arm__);
+    DEBUG("   __ARMCC_VERSION [%d]=[P:major V:minor bbbb:build]\n", __ARMCC_VERSION);
+    DEBUG("   __VERSION__(gnu Compiler)[" __VERSION__ "]\n");
+    //DEBUG("   __STDC_VERSION__ [%d]\n", __STDC_VERSION__);
+    //DEBUG("   __BIG_ENDIAN[%d] ", __BIG_ENDIAN);
+    DEBUG("   __OPTIMISE_LEVEL[%d]", __OPTIMISE_LEVEL);
+    //DEBUG("   __OPTIMISE_SPACE[%d]", __OPTIMISE_SPACE);
+    DEBUG("   __OPTIMISE_TIME[%d]", __OPTIMISE_TIME);
+    DEBUG("\n   __MODULE__[" __MODULE__ "] __FILE__[" __FILE__ "] __BASE_FILE__[" __BASE_FILE__ "]\n");
+    DEBUG("   __FUNCTION__[%s] __PRETTY_FUNCTION__[%s]\n", __FUNCTION__, __PRETTY_FUNCTION__)
+  
+    vShowIO();
 
     Ticker ticker1;                             //PR: Timer Object(Structure)
     ticker1.attach(CallbackTicker1, 5.0);       //PR: Timer Handler, Float=PeriodSeconds (Note BLE default wakes about 50Hz/20msec)
 
     //BLE1: Setup BLE Service (and event actions) //TODO: Check for services declared before main() - Is that OK?
+    DEBUG("\nBLE: Connect App for Data: nRF-MCP, nRF-Toolbox:HRM/HTM, Android Sample BluetoothLeGatt, etc.\n");
+    DEBUG(" nRF-MCP: App->mbed: LinkLoss->AlertLevel(UpArrow)\n"); 
+    DEBUG(" nRF-MCP: App->mbed: BatteryService->BatteryLevel(DownArrow)\n"); 
+    DEBUG(" nRF-MCP: mbed->App: BatteryService->BatteryLevel->EnableNotify(ThreeDownArrows), Also App Acks the send=DEBUG('SentI')\n"); 
+
     DEBUG("BLE: Setup BLE\n");
     ble.init();
     ble.onDisconnection(Callback_BLE_onDisconnect);     //PR: Host disconnects, restart advertising, clear any unnecessary functions to save power
@@ -600,7 +615,7 @@
 
     DEBUG("BLE: Setup Custom IO Service\n");
     ble.addService(ServiceIO); //Pointer: pServiceIO
-    vShowIO();
+    //vShowIO();
     //TODO: Ensure outputs in correct Initial state
 
     //BLE3: Setup advertising