Skip to content

Commit 146cdc1

Browse files
committed
add debugging macros
1 parent 38daf1a commit 146cdc1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/AdafruitIO.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,37 @@
3030
#error "This sketch requires Adafruit MQTT Library v0.17.0 or higher. Please install or upgrade using the Library Manager."
3131
#endif
3232

33+
// Uncomment/comment to turn on/off debug output messages.
34+
// #define IO_DEBUG
35+
// Uncomment/comment to turn on/off error output messages.
36+
#define IO_ERROR
37+
38+
// Set where debug messages will be printed.
39+
#define IO_DEBUG_PRINTER Serial
40+
// If using something like Zero or Due, change the above to SerialUSB
41+
42+
// Define actual debug output functions when necessary.
43+
#ifdef IO_DEBUG
44+
#define IO_DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
45+
#define IO_DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
46+
#define IO_DEBUG_PRINTBUFFER(buffer, len) { printBuffer(buffer, len); }
47+
#else
48+
#define IO_DEBUG_PRINT(...) {}
49+
#define IO_DEBUG_PRINTLN(...) {}
50+
#define IO_DEBUG_PRINTBUFFER(buffer, len) {}
51+
#endif
52+
53+
#ifdef IO_ERROR
54+
#define IO_ERROR_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
55+
#define IO_ERROR_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
56+
#define IO_ERROR_PRINTBUFFER(buffer, len) { printBuffer(buffer, len); }
57+
#else
58+
#define IO_ERROR_PRINT(...) {}
59+
#define IO_ERROR_PRINTLN(...) {}
60+
#define IO_ERROR_PRINTBUFFER(buffer, len) {}
61+
#endif
62+
63+
3364
class AdafruitIO {
3465

3566
friend class AdafruitIO_Feed;

0 commit comments

Comments
 (0)