Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822 nRF51_Vdd
Fork of BLE_Temp_Vdd_via_UART by
Diff: main.cpp
- Revision:
- 5:2607923acfa1
- Parent:
- 0:2130d7f559dc
- Child:
- 8:f9bf6d403cde
diff -r 6e389d8897bf -r 2607923acfa1 main.cpp
--- 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();
}
