Lora OTA device for Everynet
Dependencies: LMiCLibOTADeviceEverynet SX1276Lib X_NUCLEO_IKS01A1 cantcoap lwip mbed-rtos mbed
Fork of LoRaWAN-test-10secs by
Diff: debug.cpp
- Revision:
- 4:5e274bf85bf0
- Parent:
- 1:60184eda0066
diff -r ce28e3313a88 -r 5e274bf85bf0 debug.cpp --- a/debug.cpp Thu Apr 16 20:00:01 2015 +0000 +++ b/debug.cpp Fri Nov 20 12:33:37 2015 +0000 @@ -13,23 +13,27 @@ #include "lmic.h" #include "debug.h" +#include "mbed.h" +Serial pc(USBTX, USBRX); + void debug_init () { + pc.baud(9600); // print banner debug_str("\r\n============== DEBUG STARTED ==============\r\n"); } - + void debug_led (u1_t val) { debug_val( "LED = ", val ); } - + void debug_char (u1_t c) { - fprintf(stderr, "%c", c ); + pc.printf("%c", c ); } - + void debug_hex (u1_t b) { - fprintf(stderr, "%02X", b ); + pc.printf("%02X", b ); } - + void debug_buf (const u1_t* buf, u2_t len) { while( len-- ) { debug_hex( *buf++ ); @@ -38,18 +42,32 @@ debug_char( '\r' ); debug_char( '\n' ); } - + void debug_uint (u4_t v) { for( s1_t n = 24; n >= 0; n -= 8 ) { debug_hex( v >> n ); } } + +void debug_str (const char* str) { + /*while( *str ) { + debug_char( *str++ ); + }*/ + pc.printf(str); +} void debug_str (const u1_t* str) { while( *str ) { debug_char( *str++ ); } } + +void debug_val (const char* label, u4_t val) { + debug_str( label ); + debug_uint( val ); + debug_char( '\r' ); + debug_char( '\n' ); +} void debug_val (const u1_t* label, u4_t val) { debug_str( label ); @@ -57,9 +75,9 @@ debug_char( '\r' ); debug_char( '\n' ); } - + void debug_event (int ev) { - static const u1_t* evnames[] = { + static const char* evnames[] = { [EV_SCAN_TIMEOUT] = "SCAN_TIMEOUT", [EV_BEACON_FOUND] = "BEACON_FOUND", [EV_BEACON_MISSED] = "BEACON_MISSED", @@ -79,4 +97,4 @@ debug_str(evnames[ev]); debug_char('\r'); debug_char('\n'); -} +} \ No newline at end of file