LoRaWAN-hello-world- code

Dependencies:   mbed LoRaWAN-lib

Committer:
amirchaudhary
Date:
Fri Mar 22 16:24:25 2019 +0000
Revision:
12:813e9e5f5ff6
Updated the code to Class C Lorawan.

Who changed what in which revision?

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