https://www.hackster.io/PSoC_Rocks/water-quality-monitoring-autonomous-robot-0bbf88

Dependencies:   BLE_API MAG3110 MMA8652 PID mbed nRF51822

Fork of uBit_BLE_UART_Voltmeter_IoT by Shahariar Hossain

Revision:
5:2607923acfa1
Parent:
0:2130d7f559dc
Child:
8:f9bf6d403cde
--- a/main.cpp	Wed Nov 05 14:27:12 2014 +0000
+++ b/main.cpp	Fri Dec 05 09:51:39 2014 +0000
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <string.h>
 #include "mbed.h"
 #include "BLEDevice.h"
 
@@ -23,13 +24,14 @@
                                * it will have an impact on code-size and power consumption. */
 
 #if NEED_CONSOLE_OUTPUT
-#define DEBUG(...) { printf(__VA_ARGS__); }
+#define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); }
 #else
 #define DEBUG(...) /* nothing */
 #endif /* #if NEED_CONSOLE_OUTPUT */
 
 BLEDevice  ble;
 DigitalOut led1(LED1);
+UARTService *uart;
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
@@ -53,6 +55,8 @@
     DEBUG("Initialising the nRF51822\n\r");
     ble.init();
     ble.onDisconnection(disconnectionCallback);
+    
+    uart = new UARTService(ble);
 
     /* setup advertising */
     ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
@@ -65,9 +69,6 @@
     ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
     ble.startAdvertising();
 
-    UARTService uartService(ble);
-    uartService.retargetStdout();
-
     while (true) {
         ble.waitForEvent();
     }