Alcatel-Lucent IoT Development / LMiC

Dependents:   LoRaWAN-lmic-app

Fork of LMiC by Pascal Nysten

Committer:
mluis
Date:
Thu Jan 22 12:50:49 2015 +0000
Revision:
0:62d1edcc13d1
Porting of IBM LoRa MAC in C (LMiC) to the mbed platform.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 0:62d1edcc13d1 1 /* Copyright (c) 2012 mbed.org, MIT License
mluis 0:62d1edcc13d1 2 *
mluis 0:62d1edcc13d1 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mluis 0:62d1edcc13d1 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
mluis 0:62d1edcc13d1 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
mluis 0:62d1edcc13d1 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
mluis 0:62d1edcc13d1 7 * furnished to do so, subject to the following conditions:
mluis 0:62d1edcc13d1 8 *
mluis 0:62d1edcc13d1 9 * The above copyright notice and this permission notice shall be included in all copies or
mluis 0:62d1edcc13d1 10 * substantial portions of the Software.
mluis 0:62d1edcc13d1 11 *
mluis 0:62d1edcc13d1 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mluis 0:62d1edcc13d1 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mluis 0:62d1edcc13d1 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mluis 0:62d1edcc13d1 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mluis 0:62d1edcc13d1 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mluis 0:62d1edcc13d1 17 */
mluis 0:62d1edcc13d1 18
mluis 0:62d1edcc13d1 19 #ifndef DEBUG_H
mluis 0:62d1edcc13d1 20 #define DEBUG_H
mluis 0:62d1edcc13d1 21
mluis 0:62d1edcc13d1 22 /** @file debug.h */
mluis 0:62d1edcc13d1 23
mluis 0:62d1edcc13d1 24 #ifndef NDEBUG
mluis 0:62d1edcc13d1 25
mluis 0:62d1edcc13d1 26 #include <stdarg.h>
mluis 0:62d1edcc13d1 27 #include <stdio.h>
mluis 0:62d1edcc13d1 28
mluis 0:62d1edcc13d1 29 /** Output a debug message
mluis 0:62d1edcc13d1 30 *
mluis 0:62d1edcc13d1 31 * @param format printf-style format string, followed by variables
mluis 0:62d1edcc13d1 32 */
mluis 0:62d1edcc13d1 33 static inline void debug(const char *format, ...) {
mluis 0:62d1edcc13d1 34 va_list args;
mluis 0:62d1edcc13d1 35 va_start(args, format);
mluis 0:62d1edcc13d1 36 vfprintf(stderr, format, args);
mluis 0:62d1edcc13d1 37 va_end(args);
mluis 0:62d1edcc13d1 38 }
mluis 0:62d1edcc13d1 39
mluis 0:62d1edcc13d1 40 /** Conditionally output a debug message
mluis 0:62d1edcc13d1 41 *
mluis 0:62d1edcc13d1 42 * @param condition output only if condition is true
mluis 0:62d1edcc13d1 43 * @param format printf-style format string, followed by variables
mluis 0:62d1edcc13d1 44 */
mluis 0:62d1edcc13d1 45 static inline void debug_if(bool condition, const char *format, ...) {
mluis 0:62d1edcc13d1 46 if(condition) {
mluis 0:62d1edcc13d1 47 va_list args;
mluis 0:62d1edcc13d1 48 va_start(args, format);
mluis 0:62d1edcc13d1 49 vfprintf(stderr, format, args);
mluis 0:62d1edcc13d1 50 va_end(args);
mluis 0:62d1edcc13d1 51 }
mluis 0:62d1edcc13d1 52 }
mluis 0:62d1edcc13d1 53
mluis 0:62d1edcc13d1 54 #else
mluis 0:62d1edcc13d1 55
mluis 0:62d1edcc13d1 56 static inline void debug(const char *format, ...) {}
mluis 0:62d1edcc13d1 57 static inline void debug(bool condition, const char *format, ...) {}
mluis 0:62d1edcc13d1 58
mluis 0:62d1edcc13d1 59 #endif
mluis 0:62d1edcc13d1 60
mluis 0:62d1edcc13d1 61 #endif