diff --git a/platform/system/printf-stdarg.c b/platform/system/printf-stdarg.c index 9a1c57b..c695fa5 100644 --- a/platform/system/printf-stdarg.c +++ b/platform/system/printf-stdarg.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include "tremo_uart.h" #include "tremo_regs.h" diff --git a/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/Makefile b/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/Makefile index 0e7d934..8b4f730 100644 --- a/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/Makefile +++ b/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/Makefile @@ -34,14 +34,36 @@ $(PROJECT)_INC_PATH := inc \ $(TREMO_SDK_PATH)/lora/linkwan/region $(PROJECT)_CFLAGS := -Wall -Os -ffunction-sections -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -fsingle-precision-constant -std=gnu99 -fno-builtin-printf -fno-builtin-sprintf -fno-builtin-snprintf +$(PROJECT)_ADDRESS := 0x08008000 #自己添加的根据 LoraWanRegionDefine 编译不同频段的LoRaWAN ifeq ($(LoraWanRegionDefine),REGION_EU868) $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionEU868.c $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_EU868 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_EU433) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionEU433.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_EU433 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_AU915) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionAU915.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_AU915 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA else ifeq ($(LoraWanRegionDefine),REGION_US915) $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionUS915.c $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_US915 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_AS923) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionAS923.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_AS923 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_CN779) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionCN779.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_CN779 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_IN865) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionIN865.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_IN865 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_KR920) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionKR920.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_KR920 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA +else ifeq ($(LoraWanRegionDefine),REGION_US915-Hybrid) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionUS915-Hybrid.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_US915-Hybrid -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA else $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionCN470.c $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_CN470 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA diff --git a/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/inc/aithinker_code.h b/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/inc/aithinker_code.h index 190d446..e217a9c 100644 --- a/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/inc/aithinker_code.h +++ b/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/inc/aithinker_code.h @@ -1,38 +1,52 @@ -#ifndef __AITHINKER_CODE_H__ -#define __AITHINKER_CODE_H__ -#include - +#ifndef __AITHINKER_CODE_H__ +#define __AITHINKER_CODE_H__ +#include + //下面是Aithinker工程添加 -//#define FARMWARE_VERSION "debug/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用) -#define FARMWARE_VERSION "release/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用) +//#define FARMWARE_VERSION "debug/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用) +#define FARMWARE_VERSION "release/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用) //LoRaWAN国家设置 #ifdef REGION_EU868 #define LORAWAN_REGION_STR "EU868" +#elif defined(REGION_EU433) + #define LORAWAN_REGION_STR "EU433" +#elif defined(REGION_AU915) + #define LORAWAN_REGION_STR "AU915" #elif defined(REGION_US915) #define LORAWAN_REGION_STR "US915" +#elif defined(REGION_AS923) + #define LORAWAN_REGION_STR "AS923" +#elif defined(REGION_CN779) + #define LORAWAN_REGION_STR "CN779" +#elif defined(REGION_IN865) + #define LORAWAN_REGION_STR "IN865" +#elif defined(REGION_KR920) + #define LORAWAN_REGION_STR "KR920" +#elif defined(REGION_US915-Hybrid) + #define LORAWAN_REGION_STR "US915H" #else #define LORAWAN_REGION_STR "CN470" #endif //事件状态机,每个位表示一个事件 #define EVENT_AITHINKER (1<<0) //开发板测试事件 -#define EVENT_LEDTEST (1<<1) //LED测试事件 - -//aithinker 指令 -#define LORA_AT_SYSGPIOWRITE "+SYSGPIOWRITE" -#define LORA_AT_SYSGPIOREAD "+SYSGPIOREAD" -#define LORA_AT_NODEMCUTEST "+NodeMCUTEST" -#define LORA_AT_LEDTEST "+LEDTEST" - +#define EVENT_LEDTEST (1<<1) //LED测试事件 + +//aithinker 指令 +#define LORA_AT_SYSGPIOWRITE "+SYSGPIOWRITE" +#define LORA_AT_SYSGPIOREAD "+SYSGPIOREAD" +#define LORA_AT_NODEMCUTEST "+NodeMCUTEST" +#define LORA_AT_LEDTEST "+LEDTEST" + extern volatile uint32_t g_aithinkerEvent; -extern uint8_t g_ledIndex; -extern uint8_t *g_pAtCmd; - -void AithinkerPrintInfo(void); -void AithinkerEventProcess(void); -int at_sysGpioWrite_func(int opt, int argc, char *argv[]); -int at_sysGpioRead_func(int opt, int argc, char *argv[]); -int at_nodeMcuTest_func(int opt, int argc, char *argv[]); -int at_ledTest_func(int opt, int argc, char *argv[]); - -#endif //end of __AITHINKER_CODE_H__ +extern uint8_t g_ledIndex; +extern uint8_t *g_pAtCmd; + +void AithinkerPrintInfo(void); +void AithinkerEventProcess(void); +int at_sysGpioWrite_func(int opt, int argc, char *argv[]); +int at_sysGpioRead_func(int opt, int argc, char *argv[]); +int at_nodeMcuTest_func(int opt, int argc, char *argv[]); +int at_ledTest_func(int opt, int argc, char *argv[]); + +#endif //end of __AITHINKER_CODE_H__ diff --git a/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/readme.md b/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/readme.md new file mode 100644 index 0000000..0ca9c55 --- /dev/null +++ b/projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/readme.md @@ -0,0 +1,41 @@ +# Extra LoraWAN AT building information +The AT firmware as presented in this SDK requires the OTA firmware installed, which has to be either installed by flashing full original LORAWAN AT firmware first, or by building it in [../../ota/bootloader/](../../ota/bootloader/) directory and flashing it before installing the custom-built AT firmware. + +To build AT firmware for your specific LoRaWAN band, follow the instructions in main document [/readme.md](/readme.md), especially + +``` +source build/envsetup.sh +``` + +Before building the specific variant of the firmware, use one of following lines to export the correct variable (not needed for CN470 band): + +``` +export LoraWanRegionDefine=REGION_EU868 # for Ra-08H EU +export LoraWanRegionDefine=REGION_US915 # for Ra-08H US band +export LoraWanRegionDefine=REGION_AU915 # for Ra-08H Australia band +export LoraWanRegionDefine=REGION_EU433 # for Ra08 EU 433 band +export LoraWanRegionDefine=REGION_CN470 # for Ra08 CN 470 band (default if this variable is not set) +... +``` +After that, you can continue with + +``` +make clean +make +make flash # do not forget to put the board in download mode first +``` + +You can add any future aditional regions by modifying the *Makefile* and *inc/aithinker_code.h* to support them. The additional available bands can be found in [/lora/mac/region](/lora/mac/region/) directory. The modifications would look like this: + +``` +else ifeq ($(LoraWanRegionDefine),REGION_XXFFF) + $(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionXXFFF.c + $(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_XXFFF -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA + +``` +in Makefile before final else, and in *inc/aithinker_code.h* +``` +#elif defined(REGION_XXFFF) + #define LORAWAN_REGION_STR "XXFFF" +``` +where *XX* is the country code and *FFF* is the frequency of band in MHz.