LoRaWAN end device MAC layer for SX1272 and SX1276. Supports LoRaWAN-1.0 and LoRaWAN-1.1

Dependencies:   sx12xx_hal

Dependents:   LoRaWAN-SanJose_Bootcamp LoRaWAN-grove-cayenne LoRaWAN-classC-demo LoRaWAN-grove-cayenne ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lorawan_board.h Source File

lorawan_board.h

00001 #include "mbed.h"
00002 #ifdef MBED_DEBUG
00003 //#error mbed_debug
00004 #endif
00005 #include "utilities.h"
00006 #include "eeprom.h"
00007 #include "Commissioning.h"
00008 #define __STDC_FORMAT_MACROS
00009 #include <inttypes.h>
00010 #include <stdlib.h>
00011 
00012 #include "target.h"
00013 
00014 #if defined( USE_BAND_868 )
00015     #define DUTY_ENABLE
00016     #include "duty.h"
00017 #endif
00018 
00019 #ifdef ENABLE_VT100
00020     #include "SerialDisplay.h"
00021 #else
00022     extern RawSerial pc;
00023     #define APP_DEBUG
00024     //#define MAC_DEBUG
00025     //#define CRYPT_DEBUG
00026     //#define MIC_DEBUG_DOWN
00027     //#define DEBUG_MAC_CMD
00028 #endif /* ENABLE_VT100 */
00029 //#define MIC_DEBUG_UP
00030 //#define MIC_DEBUG_DOWN
00031 
00032 #ifdef APP_DEBUG
00033     #define APP_PRINTF(...) pc.printf("\e[33m" __VA_ARGS__); pc.printf("\e[0m")  /* yellow */
00034 #else
00035     #define APP_PRINTF(...)    
00036 #endif
00037 
00038 #ifdef MAC_DEBUG
00039     #define DEBUG_MAC_BUF(w,x,y,z)    print_buf(w,x,y,z)
00040     #define MAC_PRINTF(...)           pc.printf("\e[36m" __VA_ARGS__); pc.printf("\e[0m")  /* cyan */
00041 #else
00042     #define DEBUG_MAC_BUF(w,x,y,z)
00043     #define MAC_PRINTF(...)  
00044 #endif
00045 
00046 #ifdef CRYPT_DEBUG
00047     #define DEBUG_CRYPT_BUF(w,x,y,z)  print_buf(w,x,y,z)
00048     #define DEBUG_CRYPT(...)      pc.printf(__VA_ARGS__)
00049 #else
00050     #define DEBUG_CRYPT_BUF(w,x,y,z)
00051     #define DEBUG_CRYPT(...)
00052 #endif
00053 
00054 #ifdef MIC_DEBUG_DOWN
00055     #ifdef ENABLE_VT100
00056         #define DEBUG_MIC_BUF_DOWN(w,x,y,z)    print_buf(w,x,y,z)
00057         #define DEBUG_MIC_DOWN(...)    vt.SetCursorPos(ROW_MIC, 1);      vt.printf(__VA_ARGS__)
00058     #else
00059         #define DEBUG_MIC_BUF_DOWN(w,x,y,z)    print_buf(w,x,y,z)
00060         #define DEBUG_MIC_DOWN(...)        pc.printf(__VA_ARGS__)
00061     #endif
00062 #else
00063     #define DEBUG_MIC_BUF_DOWN(w,x,y,z)
00064     #define DEBUG_MIC_DOWN(...)
00065 #endif
00066 
00067         
00068 #ifdef MIC_DEBUG_UP
00069     #ifdef ENABLE_VT100
00070         #define DEBUG_MIC_BUF_UP(w,x,y,z)    print_buf(w,x,y,z)
00071         #define DEBUG_MIC_UP(...)      vt.SetCursorPos(ROW_MIC, 1);  vt.printf(__VA_ARGS__)
00072     #else
00073         #define DEBUG_MIC_BUF_UP(w,x,y,z)    print_buf(w,x,y,z)
00074         #define DEBUG_MIC_UP(...)        pc.printf(__VA_ARGS__)
00075     #endif
00076 #else
00077     #define DEBUG_MIC_BUF_UP(w,x,y,z)    
00078     #define DEBUG_MIC_UP(...)
00079 #endif
00080 
00081 #ifdef DEBUG_MAC_CMD
00082     #define MACC_PRINTF(...)    pc.printf("\e[0m");
00083 #else
00084     #define MACC_PRINTF(...)
00085 #endif
00086 
00087 
00088 uint8_t BoardGetBatteryLevel(void);