Giorgos Tsapparellas / SX1272Lib

Dependents:   LoRaWAN_mbed_lmic_agriculture_app

Fork of SX1272Lib by Semtech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

Go to the documentation of this file.
00001 /* Copyright (c) 2012 mbed.org, MIT License
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  *
00018  * /////////////////////////////////////////////////////////////////////////////
00019  *
00020  * Used by Giorgos Tsapparellas for Internet of Things (IoT) smart monitoring
00021  * device for agriculture using LoRaWAN technology.
00022  * 
00023  * Date of issued copy: 20 January 2018
00024  *
00025  * Modifications: 
00026  * - No external modifications of the existing "AS IT IS" software.
00027  */
00028  
00029 #ifndef DEBUG_H
00030 #define DEBUG_H
00031 
00032 /** @file debug.h */
00033 
00034 #ifndef NDEBUG
00035 
00036 #include <stdarg.h>
00037 #include <stdio.h>
00038 
00039 /** Output a debug message
00040  * 
00041  * @param format printf-style format string, followed by variables
00042  */
00043 static inline void debug(const char *format, ...) {
00044     va_list args;
00045     va_start(args, format);
00046     vfprintf(stderr, format, args);
00047     va_end(args);
00048 }
00049 
00050 /** Conditionally output a debug message
00051  * 
00052  * @param condition output only if condition is true
00053  * @param format printf-style format string, followed by variables
00054  */
00055 static inline void debug_if(bool condition, const char *format, ...) {
00056     if(condition) {
00057         va_list args;
00058         va_start(args, format);
00059         vfprintf(stderr, format, args);
00060         va_end(args);
00061     }
00062 }
00063 
00064 #else
00065 
00066 static inline void debug(const char *format, ...) {}
00067 static inline void debug(bool condition, const char *format, ...) {}
00068 
00069 #endif
00070 
00071 #endif