SmartMesh QSL for STM32F4 version

Fork of COG-AD4050_QSL by APS Lab

Revision:
0:8ca1e814a851
Child:
1:b909b8399252
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sm_qsl/dn_debug.h	Wed May 02 09:26:10 2018 +0000
@@ -0,0 +1,44 @@
+/*
+Copyright (c) 2016, Dust Networks. All rights reserved.
+
+Debug macros (based on http://c.learncodethehardway.org/book/ex20.html ).
+
+\license See attached DN_LICENSE.txt.
+*/
+
+#ifndef DN_DEBUG_H
+#define DN_DEBUG_H
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+/* Comment out this define to include debug messages */
+#define NDEBUG 0
+
+/* Comment out this define to include log messages */
+#define NLOG 0
+
+#if 0
+#ifdef NDEBUG
+#define debug(M, ...)	do {}while(0)
+#else
+#define debug(M, ...)	fprintf(stderr, "DEBUG %s:%d: " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__)
+#endif
+
+#define clean_errno() (errno == 0 ? "None" : strerror(errno))
+
+#ifdef NLOG
+#define log_err(M, ...)		do {}while(0)
+#define log_warn(M, ...)	do {}while(0)
+#define log_info(M, ...)	do {}while(0)
+#else
+#define log_err(M, ...)		fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\r\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
+#define log_warn(M, ...)	fprintf(stderr, "[WARN] (%s:%d: errno: %s) " M "\r\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
+#define log_info(M, ...)	fprintf(stderr, "[INFO] (%s:%d) " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__)
+#endif
+
+#endif
+
+#endif
+