From 68c0714817930f07e5c3dc9955b081102bf4109f Mon Sep 17 00:00:00 2001 From: Heltec-Aaron-Lee Date: Tue, 11 Feb 2020 22:51:17 +0800 Subject: [PATCH] Optimized code structure, naming in Arduino style. --- cores/asr650x/board/src/asr_board.c | 2 +- cores/asr650x/cores/AT_Command.h | 18 +- .../kernel/protocols/lorawan/README.md | 2 - .../kernel/protocols/lorawan/lorawan.mk | 54 -- .../lorawan/lora => loramac}/LICENSE.txt | 0 cores/asr650x/loramac/mac/Commissioning.h | 44 ++ .../lorawan/lora => loramac}/mac/LoRaMac.c | 25 +- .../lorawan/lora => loramac}/mac/LoRaMac.h | 4 +- .../lora => loramac}/mac/LoRaMacClassB.h | 0 .../mac/LoRaMacClassBConfig.h | 0 .../mac/LoRaMacConfirmQueue.c | 0 .../mac/LoRaMacConfirmQueue.h | 0 .../lora => loramac}/mac/LoRaMacCrypto.c | 0 .../lora => loramac}/mac/LoRaMacCrypto.h | 0 .../lora => loramac}/mac/LoRaMacTest.h | 0 .../lora => loramac}/mac/region/Region.c | 0 .../lora => loramac}/mac/region/Region.h | 0 .../lora => loramac}/mac/region/RegionAS923.c | 4 +- .../lora => loramac}/mac/region/RegionAS923.h | 0 .../lora => loramac}/mac/region/RegionAU915.c | 4 +- .../lora => loramac}/mac/region/RegionAU915.h | 0 .../lora => loramac}/mac/region/RegionCN470.c | 5 +- .../lora => loramac}/mac/region/RegionCN470.h | 0 .../lora => loramac}/mac/region/RegionCN779.c | 4 +- .../lora => loramac}/mac/region/RegionCN779.h | 0 .../mac/region/RegionCommon.c | 0 .../mac/region/RegionCommon.h | 0 .../lora => loramac}/mac/region/RegionEU433.c | 4 +- .../lora => loramac}/mac/region/RegionEU433.h | 0 .../lora => loramac}/mac/region/RegionEU868.c | 4 +- .../lora => loramac}/mac/region/RegionEU868.h | 0 .../lora => loramac}/mac/region/RegionIN865.c | 4 +- .../lora => loramac}/mac/region/RegionIN865.h | 0 .../lora => loramac}/mac/region/RegionKR920.c | 4 +- .../lora => loramac}/mac/region/RegionKR920.h | 0 .../mac/region/RegionUS915-Hybrid.c | 4 +- .../mac/region/RegionUS915-Hybrid.h | 0 .../lora => loramac}/mac/region/RegionUS915.c | 4 +- .../lora => loramac}/mac/region/RegionUS915.h | 0 .../lorawan/lora => loramac}/radio/radio.h | 0 .../lorawan/lora => loramac}/readme.md | 0 .../lora => loramac}/system/crypto/aes.c | 0 .../lora => loramac}/system/crypto/aes.h | 0 .../lora => loramac}/system/crypto/cmac.c | 0 .../lora => loramac}/system/crypto/cmac.h | 0 .../lorawan/lora => loramac}/system/delay.c | 0 .../lorawan/lora => loramac}/system/delay.h | 0 .../lora => loramac}/system/low_power.c | 6 +- .../lora => loramac}/system/low_power.h | 2 +- .../lora => loramac}/system/timeServer.h | 0 .../lorawan/lora => loramac}/system/timer.h | 0 .../lora => loramac}/system/utilities.c | 0 .../lora => loramac}/system/utilities.h | 0 cores/asr650x/projects/CubeCellLib.a | Bin 253120 -> 253360 bytes .../Factory_Test_AB01/Factory_Test_AB01.ino | 64 +-- .../Factory_Test_AM01/Factory_Test_AM01.ino | 38 +- .../LowPower_WakeUpByGPIO.ino | 14 +- .../LowPower_WakeUpByTimer.ino | 18 +- .../LoRa/examples/AT_Command/AT_Command.ino | 116 ++-- .../LoRaBasic/LoRaSender/LoRaSender.ino | 32 +- .../LoRaSender_ReadBattery.ino | 27 +- .../examples/LoRaBasic/pingpong/pingpong.ino | 32 +- .../LoRaWan_BH1750/LoRaWan_BH1750.ino | 110 ++-- .../LoRaWan_BMP180/LoRaWan_BMP180.ino | 129 +++-- .../LoRaWan_CCS811/LoRaWan_CCS811.ino | 114 ++-- .../LoRaWan_HDC1080/LoRaWan_HDC1080.ino | 132 +++-- .../LoRaWan_MPU9250/LoRaWan_MPU9250.ino | 204 +++---- .../LoRaWan_MultiSensor.ino | 507 +++++++++--------- .../LoRaWAN_BMP280/LoRaWAN_BMP280.ino | 231 ++++---- .../LoRa/examples/LoRaWAN/LoRaWan/LoRaWan.ino | 102 ++-- .../LoRaWan_downlinkdatahandle.ino | 108 ++-- .../LoRaWan_interrupt/LoRaWan_interrupt.ino | 208 +++---- .../LoRaWan_multicast/LoRaWan_multicast.ino | 112 ++-- .../LoRaWan_user_AT/LoRaWan_user_AT.ino | 105 ++-- .../LoRaWan_HDC1080/LoRaWan_HDC1080.ino | 155 ------ libraries/LoRa/src/Commissioning.h | 81 --- libraries/LoRa/src/LoRaWan_APP.cpp | 215 ++++---- libraries/LoRa/src/LoRaWan_APP.h | 62 ++- libraries/LoRa/src/LoRa_APP.cpp | 18 +- libraries/LoRa/src/LoRa_APP.h | 10 +- .../SSD1306DrawingDemo_I2C.ino | 4 +- .../SSD1306DrawingDemo_SPI.ino | 4 +- .../SSD1306SimpleDemo_I2C.ino | 2 +- .../SSD1306SimpleDemo_SPI.ino | 2 +- .../examples/SSD1306UiDemo/SSD1306UiDemo.ino | 6 +- .../SSD1306UiDemo_I2C/SSD1306UiDemo_I2C.ino | 10 +- .../SSD1306UiDemo_SPI/SSD1306UiDemo_SPI.ino | 6 +- ...EDDisplay.cpp => cubecell_OLEDDisplay.cpp} | 2 +- .../{OLEDDisplay.h => cubecell_OLEDDisplay.h} | 2 +- ...layFonts.h => cubecell_OLEDDisplayFonts.h} | 0 ...splayUi.cpp => cubecell_OLEDDisplayUi.cpp} | 2 +- ...EDDisplayUi.h => cubecell_OLEDDisplayUi.h} | 2 +- .../{SSD1306Spi.h => cubecell_SSD1306Spi.h} | 2 +- .../{SSD1306Wire.h => cubecell_SSD1306Wire.h} | 2 +- 94 files changed, 1585 insertions(+), 1603 deletions(-) delete mode 100644 cores/asr650x/kernel/protocols/lorawan/README.md delete mode 100644 cores/asr650x/kernel/protocols/lorawan/lorawan.mk rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/LICENSE.txt (100%) create mode 100644 cores/asr650x/loramac/mac/Commissioning.h rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMac.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMac.h (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacClassB.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacClassBConfig.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacConfirmQueue.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacConfirmQueue.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacCrypto.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacCrypto.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/LoRaMacTest.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/Region.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/Region.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionAS923.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionAS923.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionAU915.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionAU915.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionCN470.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionCN470.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionCN779.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionCN779.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionCommon.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionCommon.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionEU433.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionEU433.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionEU868.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionEU868.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionIN865.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionIN865.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionKR920.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionKR920.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionUS915-Hybrid.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionUS915-Hybrid.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionUS915.c (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/mac/region/RegionUS915.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/radio/radio.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/readme.md (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/crypto/aes.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/crypto/aes.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/crypto/cmac.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/crypto/cmac.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/delay.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/delay.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/low_power.c (97%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/low_power.h (99%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/timeServer.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/timer.h (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/utilities.c (100%) rename cores/asr650x/{kernel/protocols/lorawan/lora => loramac}/system/utilities.h (100%) delete mode 100644 libraries/LoRa/examples/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino delete mode 100644 libraries/LoRa/src/Commissioning.h rename libraries/SSD1306/src/{OLEDDisplay.cpp => cubecell_OLEDDisplay.cpp} (99%) rename libraries/SSD1306/src/{OLEDDisplay.h => cubecell_OLEDDisplay.h} (99%) rename libraries/SSD1306/src/{OLEDDisplayFonts.h => cubecell_OLEDDisplayFonts.h} (100%) rename libraries/SSD1306/src/{OLEDDisplayUi.cpp => cubecell_OLEDDisplayUi.cpp} (99%) rename libraries/SSD1306/src/{OLEDDisplayUi.h => cubecell_OLEDDisplayUi.h} (99%) rename libraries/SSD1306/src/{SSD1306Spi.h => cubecell_SSD1306Spi.h} (98%) rename libraries/SSD1306/src/{SSD1306Wire.h => cubecell_SSD1306Wire.h} (99%) diff --git a/cores/asr650x/board/src/asr_board.c b/cores/asr650x/board/src/asr_board.c index 65272cdf..0884c4be 100644 --- a/cores/asr650x/board/src/asr_board.c +++ b/cores/asr650x/board/src/asr_board.c @@ -458,7 +458,7 @@ static const double TWO52[2]={ -void BoardInitMcu( void ) +void boardInitMcu( void ) { SpiInit(); Asr_Timer_Init(); diff --git a/cores/asr650x/cores/AT_Command.h b/cores/asr650x/cores/AT_Command.h index 78c025d6..1d9386ab 100644 --- a/cores/asr650x/cores/AT_Command.h +++ b/cores/asr650x/cores/AT_Command.h @@ -30,17 +30,17 @@ enum eDeviceState_Lora }; -void Enable_AT(void); +void enableAt(void); void getDevParam(void); void printDevParam(void); -void SaveNetInfo(uint8_t *joinpayload, uint16_t size); -void SaveUpCnt(void); -void SaveDownCnt(void); -void GetNetInfo(void); -void SaveDr(void); -bool CheckNetInfo(void); -void NetInfoDisable(void); -extern bool AT_user_check(char * cmd, char * content); +void saveNetInfo(uint8_t *joinpayload, uint16_t size); +void saveUpCnt(void); +void saveDownCnt(void); +void getNetInfo(void); +void saveDr(void); +bool checkNetInfo(void); +void netInfoDisable(void); +extern bool checkUserAt(char * cmd, char * content); diff --git a/cores/asr650x/kernel/protocols/lorawan/README.md b/cores/asr650x/kernel/protocols/lorawan/README.md deleted file mode 100644 index 4180ca8a..00000000 --- a/cores/asr650x/kernel/protocols/lorawan/README.md +++ /dev/null @@ -1,2 +0,0 @@ -#lib_lorawan -This is lib_lorawan component. \ No newline at end of file diff --git a/cores/asr650x/kernel/protocols/lorawan/lorawan.mk b/cores/asr650x/kernel/protocols/lorawan/lorawan.mk deleted file mode 100644 index c613de4a..00000000 --- a/cores/asr650x/kernel/protocols/lorawan/lorawan.mk +++ /dev/null @@ -1,54 +0,0 @@ - -NAME := lorawan - -$(NAME)_SOURCES := lora/system/crypto/aes.c \ - lora/system/crypto/cmac.c \ - lora/system/timeServer.c \ - lora/system/low_power.c \ - lora/system/utilities.c \ - lora/system/delay.c \ - lora/mac/region/Region.c \ - lora/mac/region/RegionCommon.c \ - lora/mac/LoRaMac.c \ - lora/mac/LoRaMacCrypto.c \ - ../../../device/lora/sx1276/sx1276.c - -GLOBAL_INCLUDES += . \ - ../../../device/lora/sx1276 \ - lora/system/crypto \ - lora/radio \ - lora/mac \ - lora/mac/region \ - lora/system - -linkwan?=0 -ifeq ($(linkwan), 1) -GLOBAL_DEFINES += CONFIG_LINKWAN -GLOBAL_DEFINES += CONFIG_DEBUG_LINKWAN -GLOBAL_DEFINES += CONFIG_AOS_DISABLE_TICK -GLOBAL_DEFINES += REGION_CN470A -$(NAME)_SOURCES += linkwan/region/RegionCN470A.c -$(NAME)_SOURCES += linkwan/linkwan.c - -GLOBAL_INCLUDES += linkwan/include -GLOBAL_INCLUDES += linkwan/region - -linkwanat ?= 0 -ifeq ($(linkwanat), 1) -GLOBAL_DEFINES += CONFIG_LINKWAN_AT -GLOBAL_DEFINES += LOW_POWER_DISABLE -$(NAME)_SOURCES += linkwan/linkwan_ica_at.c -#$(NAME)_SOURCES += linkwan/linkwan_at.c -endif -else -$(NAME)_SOURCES += lora/mac/region/RegionAS923.c \ - lora/mac/region/RegionAU915.c \ - lora/mac/region/RegionCN470.c \ - lora/mac/region/RegionCN779.c \ - lora/mac/region/RegionEU433.c \ - lora/mac/region/RegionEU868.c \ - lora/mac/region/RegionIN865.c \ - lora/mac/region/RegionKR920.c \ - lora/mac/region/RegionUS915.c \ - lora/mac/region/RegionUS915-Hybrid.c -endif diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/LICENSE.txt b/cores/asr650x/loramac/LICENSE.txt similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/LICENSE.txt rename to cores/asr650x/loramac/LICENSE.txt diff --git a/cores/asr650x/loramac/mac/Commissioning.h b/cores/asr650x/loramac/mac/Commissioning.h new file mode 100644 index 00000000..5f287679 --- /dev/null +++ b/cores/asr650x/loramac/mac/Commissioning.h @@ -0,0 +1,44 @@ +/*! + * \file Commissioning.h + * + * \brief End device commissioning parameters + * + * \copyright Revised BSD License, see section \ref LICENSE. + * + * \code + * ______ _ + * / _____) _ | | + * ( (____ _____ ____ _| |_ _____ ____| |__ + * \____ \| ___ | (_ _) ___ |/ ___) _ \ + * _____) ) ____| | | || |_| ____( (___| | | | + * (______/|_____)_|_|_| \__)_____)\____)_| |_| + * (C)2013-2017 Semtech + * + * \endcode + * + * \author Miguel Luis ( Semtech ) + * + * \author Gregory Cristian ( Semtech ) + */ +#ifndef __LORA_COMMISSIONING_H__ +#define __LORA_COMMISSIONING_H__ + +#include "LoRaMac.h" + +/*! + * User application data buffer size + */ +#define LORAWAN_APP_DATA_MAX_SIZE 128 //if use AT mode, don't modify this value or may run dead + +/*! + * Indicates if the end-device is to be connected to a private or public network + */ +#define LORAWAN_PUBLIC_NETWORK true + +/*! + * Current network ID + */ +#define LORAWAN_NETWORK_ID ( uint32_t )0 + + +#endif // __LORA_COMMISSIONING_H__ diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.c b/cores/asr650x/loramac/mac/LoRaMac.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.c rename to cores/asr650x/loramac/mac/LoRaMac.c index bc731f1f..96b74cb0 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.c +++ b/cores/asr650x/loramac/mac/LoRaMac.c @@ -699,6 +699,7 @@ static void OpenContinuousRx2Window( void ); static void OnRadioTxDone( void ) { + DIO_PRINTF("Event : Tx Done\r\n"); GetPhyParams_t getPhy; PhyParam_t phyParam; SetBandTxDoneParams_t txDone; @@ -772,7 +773,7 @@ static void OnRadioTxDone( void ) #endif #if (LoraWan_RGB==1) - RGB_OFF(); + turnOffRGB(); #endif } @@ -795,6 +796,7 @@ static void PrepareRxDoneAbort( void ) void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) { + DIO_PRINTF("Event : Rx Done\r\n"); uint8_t * temp = payload; LoRaMacHeader_t macHdr; LoRaMacFrameCtrl_t fCtrl; @@ -932,7 +934,7 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) LoRaMacConfirmQueueSetStatus( LORAMAC_EVENT_INFO_STATUS_OK, MLME_JOIN ); IsLoRaMacNetworkJoined = true; - SaveNetInfo(temp, size); + saveNetInfo(temp, size); //Joined save its DR using LoRaMacParams.ChannelsDatarate, if set it will be default // LoRaMacParams.ChannelsDatarate = LoRaMacParamsDefaults.ChannelsDatarate; } else { @@ -1088,7 +1090,7 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) } DownLinkCounter = downLinkCounter; if(DownLinkCounter%15000==0){ - SaveDownCnt(); + saveDownCnt(); } } @@ -1213,8 +1215,9 @@ void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) static void OnRadioTxTimeout( void ) { #if (LoraWan_RGB==1) - RGB_OFF(); + turnOffRGB(); #endif + DIO_PRINTF("Event : Tx Timeout\r\n"); if( LoRaMacDeviceClass != CLASS_C ) { @@ -1235,6 +1238,7 @@ static void OnRadioTxTimeout( void ) static void OnRadioRxError( void ) { + DIO_PRINTF("Event : Rx Error\r\n"); bool classBRx = false; if( LoRaMacDeviceClass != CLASS_C ) @@ -1307,8 +1311,10 @@ static void OnRadioRxError( void ) static void OnRadioRxTimeout( void ) { #if (LoraWan_RGB==1) - RGB_OFF(); + turnOffRGB(); #endif + DIO_PRINTF("Event : Rx Timeout\r\n"); + bool classBRx = false; if( LoRaMacDeviceClass != CLASS_C ) @@ -1707,7 +1713,7 @@ static void OnRxWindow1TimerEvent( void ) //printf("w1 dr:%d\r\n",McpsIndication.RxDatarate); RxWindowSetup( RxWindow1Config.RxContinuous, LoRaMacParams.MaxRxWindow ); #if(LoraWan_RGB==1) - RGB_ON(COLOR_RXWINDOW1,0); + turnOnRGB(COLOR_RXWINDOW1,0); #endif } @@ -1733,7 +1739,7 @@ static void OnRxWindow2TimerEvent( void ) RxSlot = RX_SLOT_WIN_2; } #if(LoraWan_RGB==1) - RGB_ON(COLOR_RXWINDOW2,0); + turnOnRGB(COLOR_RXWINDOW2,0); #endif } @@ -2843,7 +2849,7 @@ LoRaMacStatus_t SendFrameOnChannel( uint8_t channel ) } // Send now #if (LoraWan_RGB==1) - RGB_ON(COLOR_SEND,0); + turnOnRGB(COLOR_SEND,0); #endif Radio.Send( LoRaMacBuffer, LoRaMacBufferPktLen ); @@ -3672,8 +3678,7 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest ) case MLME_JOIN: { if ( ( mlmeRequest->Req.Join.DevEui == NULL ) || ( mlmeRequest->Req.Join.AppEui == NULL ) || - ( mlmeRequest->Req.Join.AppKey == NULL ) || - ( mlmeRequest->Req.Join.NbTrials == 0 ) ) { + ( mlmeRequest->Req.Join.AppKey == NULL )) { return LORAMAC_STATUS_PARAMETER_INVALID; } diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.h b/cores/asr650x/loramac/mac/LoRaMac.h similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.h rename to cores/asr650x/loramac/mac/LoRaMac.h index 30d89a7b..5dd283dd 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMac.h +++ b/cores/asr650x/loramac/mac/LoRaMac.h @@ -2449,8 +2449,8 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest ); */ LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest ); -extern void RGB_ON(uint32_t color,uint32_t time); -extern void RGB_OFF(void); +extern void turnOnRGB(uint32_t color,uint32_t time); +extern void turnOffRGB(void); #ifdef __cplusplus diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacClassB.h b/cores/asr650x/loramac/mac/LoRaMacClassB.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacClassB.h rename to cores/asr650x/loramac/mac/LoRaMacClassB.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacClassBConfig.h b/cores/asr650x/loramac/mac/LoRaMacClassBConfig.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacClassBConfig.h rename to cores/asr650x/loramac/mac/LoRaMacClassBConfig.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacConfirmQueue.c b/cores/asr650x/loramac/mac/LoRaMacConfirmQueue.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacConfirmQueue.c rename to cores/asr650x/loramac/mac/LoRaMacConfirmQueue.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacConfirmQueue.h b/cores/asr650x/loramac/mac/LoRaMacConfirmQueue.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacConfirmQueue.h rename to cores/asr650x/loramac/mac/LoRaMacConfirmQueue.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacCrypto.c b/cores/asr650x/loramac/mac/LoRaMacCrypto.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacCrypto.c rename to cores/asr650x/loramac/mac/LoRaMacCrypto.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacCrypto.h b/cores/asr650x/loramac/mac/LoRaMacCrypto.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacCrypto.h rename to cores/asr650x/loramac/mac/LoRaMacCrypto.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacTest.h b/cores/asr650x/loramac/mac/LoRaMacTest.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/LoRaMacTest.h rename to cores/asr650x/loramac/mac/LoRaMacTest.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/Region.c b/cores/asr650x/loramac/mac/region/Region.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/Region.c rename to cores/asr650x/loramac/mac/region/Region.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/Region.h b/cores/asr650x/loramac/mac/region/Region.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/Region.h rename to cores/asr650x/loramac/mac/region/Region.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAS923.c b/cores/asr650x/loramac/mac/region/RegionAS923.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAS923.c rename to cores/asr650x/loramac/mac/region/RegionAS923.c index 5c62a9f5..982cf4ab 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAS923.c +++ b/cores/asr650x/loramac/mac/region/RegionAS923.c @@ -663,7 +663,7 @@ bool RegionAS923RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) } Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -693,7 +693,7 @@ bool RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime modem = MODEM_LORA; Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); } - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( modem, txConfig->PktLen ); // Get the time-on-air of the next tx frame diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAS923.h b/cores/asr650x/loramac/mac/region/RegionAS923.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAS923.h rename to cores/asr650x/loramac/mac/region/RegionAS923.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.c b/cores/asr650x/loramac/mac/region/RegionAU915.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.c rename to cores/asr650x/loramac/mac/region/RegionAU915.c index 3df268f5..613ca075 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.c +++ b/cores/asr650x/loramac/mac/region/RegionAU915.c @@ -572,7 +572,7 @@ bool RegionAU915RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateAU915[dr]; } Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); -// printf("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -592,7 +592,7 @@ bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen ); Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); -// printf("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); *txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen ); *txPower = txPowerLimited; diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.h b/cores/asr650x/loramac/mac/region/RegionAU915.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionAU915.h rename to cores/asr650x/loramac/mac/region/RegionAU915.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN470.c b/cores/asr650x/loramac/mac/region/RegionCN470.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN470.c rename to cores/asr650x/loramac/mac/region/RegionCN470.c index 1dc33b5d..a20bca8d 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN470.c +++ b/cores/asr650x/loramac/mac/region/RegionCN470.c @@ -134,7 +134,7 @@ static uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMas } } } - //printf("nbEnabledChannels: %d ",nbEnabledChannels); + *delayTx = delayTransmission; return nbEnabledChannels; } @@ -529,6 +529,7 @@ bool RegionCN470RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateCN470[dr]; } Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -547,6 +548,8 @@ bool RegionCN470TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime Radio.SetChannel( Channels[txConfig->Channel].Frequency ); Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, 0, phyDr, 1, 8, false, true, 0, 0, false, 3000 ); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen ); // Get the time-on-air of the next tx frame diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN470.h b/cores/asr650x/loramac/mac/region/RegionCN470.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN470.h rename to cores/asr650x/loramac/mac/region/RegionCN470.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN779.c b/cores/asr650x/loramac/mac/region/RegionCN779.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN779.c rename to cores/asr650x/loramac/mac/region/RegionCN779.c index 020fe8f4..aed5f951 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN779.c +++ b/cores/asr650x/loramac/mac/region/RegionCN779.c @@ -604,7 +604,7 @@ bool RegionCN779RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateCN779[dr]; } Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -634,7 +634,7 @@ bool RegionCN779TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime modem = MODEM_LORA; Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); } - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( modem, txConfig->PktLen ); // Get the time-on-air of the next tx frame diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN779.h b/cores/asr650x/loramac/mac/region/RegionCN779.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCN779.h rename to cores/asr650x/loramac/mac/region/RegionCN779.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCommon.c b/cores/asr650x/loramac/mac/region/RegionCommon.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCommon.c rename to cores/asr650x/loramac/mac/region/RegionCommon.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCommon.h b/cores/asr650x/loramac/mac/region/RegionCommon.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionCommon.h rename to cores/asr650x/loramac/mac/region/RegionCommon.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU433.c b/cores/asr650x/loramac/mac/region/RegionEU433.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU433.c rename to cores/asr650x/loramac/mac/region/RegionEU433.c index 47e4979a..a6fe27aa 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU433.c +++ b/cores/asr650x/loramac/mac/region/RegionEU433.c @@ -604,7 +604,7 @@ bool RegionEU433RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateEU433[dr]; } Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -634,7 +634,7 @@ bool RegionEU433TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime modem = MODEM_LORA; Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); } - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( modem, txConfig->PktLen ); // Get the time-on-air of the next tx frame diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU433.h b/cores/asr650x/loramac/mac/region/RegionEU433.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU433.h rename to cores/asr650x/loramac/mac/region/RegionEU433.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU868.c b/cores/asr650x/loramac/mac/region/RegionEU868.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU868.c rename to cores/asr650x/loramac/mac/region/RegionEU868.c index 3049b53a..872b34a1 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU868.c +++ b/cores/asr650x/loramac/mac/region/RegionEU868.c @@ -634,7 +634,7 @@ bool RegionEU868RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) } Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); -// printf("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -664,7 +664,7 @@ bool RegionEU868TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime modem = MODEM_LORA; Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3000 ); } -// printf("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( modem, txConfig->PktLen ); // Get the time-on-air of the next tx frame diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU868.h b/cores/asr650x/loramac/mac/region/RegionEU868.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionEU868.h rename to cores/asr650x/loramac/mac/region/RegionEU868.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionIN865.c b/cores/asr650x/loramac/mac/region/RegionIN865.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionIN865.c rename to cores/asr650x/loramac/mac/region/RegionIN865.c index ebcdb321..63c8fd53 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionIN865.c +++ b/cores/asr650x/loramac/mac/region/RegionIN865.c @@ -608,7 +608,7 @@ bool RegionIN865RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateIN865[dr]; } Radio.SetMaxPayloadLength( modem, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -638,7 +638,7 @@ bool RegionIN865TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime modem = MODEM_LORA; Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); } - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( modem, txConfig->PktLen ); // Get the time-on-air of the next tx frame diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionIN865.h b/cores/asr650x/loramac/mac/region/RegionIN865.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionIN865.h rename to cores/asr650x/loramac/mac/region/RegionIN865.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionKR920.c b/cores/asr650x/loramac/mac/region/RegionKR920.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionKR920.c rename to cores/asr650x/loramac/mac/region/RegionKR920.c index a96e53de..273231f7 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionKR920.c +++ b/cores/asr650x/loramac/mac/region/RegionKR920.c @@ -609,7 +609,7 @@ bool RegionKR920RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) Radio.SetRxConfig( MODEM_LORA, rxConfig->Bandwidth, phyDr, 1, 0, 8, rxConfig->WindowTimeout, false, 0, false, 0, 0, true, rxConfig->RxContinuous ); maxPayload = MaxPayloadOfDatarateKR920[dr]; Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -634,7 +634,7 @@ bool RegionKR920TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime Radio.SetChannel( Channels[txConfig->Channel].Frequency ); Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 4e3 ); - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); // Setup maximum payload lenght of the radio driver Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen ); diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionKR920.h b/cores/asr650x/loramac/mac/region/RegionKR920.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionKR920.h rename to cores/asr650x/loramac/mac/region/RegionKR920.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915-Hybrid.c b/cores/asr650x/loramac/mac/region/RegionUS915-Hybrid.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915-Hybrid.c rename to cores/asr650x/loramac/mac/region/RegionUS915-Hybrid.c index d2238c99..bddb1d44 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915-Hybrid.c +++ b/cores/asr650x/loramac/mac/region/RegionUS915-Hybrid.c @@ -673,7 +673,7 @@ bool RegionUS915HybridRxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateUS915_HYBRID[dr]; } Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -693,7 +693,7 @@ bool RegionUS915HybridTxConfig( TxConfigParams_t* txConfig, int8_t* txPower, Tim Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen ); Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); *txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen ); *txPower = txPowerLimited; diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915-Hybrid.h b/cores/asr650x/loramac/mac/region/RegionUS915-Hybrid.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915-Hybrid.h rename to cores/asr650x/loramac/mac/region/RegionUS915-Hybrid.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915.c b/cores/asr650x/loramac/mac/region/RegionUS915.c similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915.c rename to cores/asr650x/loramac/mac/region/RegionUS915.c index 1ba7f6ea..ead9adc2 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915.c +++ b/cores/asr650x/loramac/mac/region/RegionUS915.c @@ -586,7 +586,7 @@ bool RegionUS915RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ) maxPayload = MaxPayloadOfDatarateUS915[dr]; } Radio.SetMaxPayloadLength( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD ); - DBG_PRINTF("RX on freq %u Hz at DR %d\n\r", (unsigned int)frequency, dr); + FREQ_PRINTF("RX on freq %u Hz at DR %d\r\n", (unsigned int)frequency, dr); *datarate = (uint8_t) dr; return true; @@ -606,7 +606,7 @@ bool RegionUS915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime Radio.SetMaxPayloadLength( MODEM_LORA, txConfig->PktLen ); Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3e3 ); - DBG_PRINTF("TX on freq %u Hz at DR %d\n\r", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); + FREQ_PRINTF("TX on freq %u Hz at DR %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate); *txTimeOnAir = Radio.TimeOnAir( MODEM_LORA, txConfig->PktLen ); *txPower = txPowerLimited; diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915.h b/cores/asr650x/loramac/mac/region/RegionUS915.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/mac/region/RegionUS915.h rename to cores/asr650x/loramac/mac/region/RegionUS915.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/radio/radio.h b/cores/asr650x/loramac/radio/radio.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/radio/radio.h rename to cores/asr650x/loramac/radio/radio.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/readme.md b/cores/asr650x/loramac/readme.md similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/readme.md rename to cores/asr650x/loramac/readme.md diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/aes.c b/cores/asr650x/loramac/system/crypto/aes.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/aes.c rename to cores/asr650x/loramac/system/crypto/aes.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/aes.h b/cores/asr650x/loramac/system/crypto/aes.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/aes.h rename to cores/asr650x/loramac/system/crypto/aes.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/cmac.c b/cores/asr650x/loramac/system/crypto/cmac.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/cmac.c rename to cores/asr650x/loramac/system/crypto/cmac.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/cmac.h b/cores/asr650x/loramac/system/crypto/cmac.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/crypto/cmac.h rename to cores/asr650x/loramac/system/crypto/cmac.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/delay.c b/cores/asr650x/loramac/system/delay.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/delay.c rename to cores/asr650x/loramac/system/delay.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/delay.h b/cores/asr650x/loramac/system/delay.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/delay.h rename to cores/asr650x/loramac/system/delay.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/low_power.c b/cores/asr650x/loramac/system/low_power.c similarity index 97% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/low_power.c rename to cores/asr650x/loramac/system/low_power.c index c3724c53..1be0e895 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/system/low_power.c +++ b/cores/asr650x/loramac/system/low_power.c @@ -61,7 +61,7 @@ static uint32_t LowPower_State = 0; /* Private function prototypes -----------------------------------------------*/ -extern bool WakeByUart; +extern bool wakeByUart; @@ -109,11 +109,11 @@ uint32_t LowPower_GetState( void ) * @param None * @retval None */ -void LowPower_Handler( void ) +void lowPowerHandler( void ) { CPSR_ALLOC(); RHINO_CPU_INTRPT_DISABLE(); - if (LowPower_State == 0 && WakeByUart == false) { + if (LowPower_State == 0 && wakeByUart == false) { // printf("s"); DBG_PRINTF_CRITICAL("dz\n\r"); aos_lrwan_chg_mode.enter_stop_mode(); diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/low_power.h b/cores/asr650x/loramac/system/low_power.h similarity index 99% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/low_power.h rename to cores/asr650x/loramac/system/low_power.h index acd8ee7e..1dc47216 100644 --- a/cores/asr650x/kernel/protocols/lorawan/lora/system/low_power.h +++ b/cores/asr650x/loramac/system/low_power.h @@ -87,7 +87,7 @@ uint32_t LowPower_GetState( void ); * @param none * @retval none */ -void LowPower_Handler( void ); +void lowPowerHandler( void ); #ifdef __cplusplus } diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/timeServer.h b/cores/asr650x/loramac/system/timeServer.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/timeServer.h rename to cores/asr650x/loramac/system/timeServer.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/timer.h b/cores/asr650x/loramac/system/timer.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/timer.h rename to cores/asr650x/loramac/system/timer.h diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/utilities.c b/cores/asr650x/loramac/system/utilities.c similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/utilities.c rename to cores/asr650x/loramac/system/utilities.c diff --git a/cores/asr650x/kernel/protocols/lorawan/lora/system/utilities.h b/cores/asr650x/loramac/system/utilities.h similarity index 100% rename from cores/asr650x/kernel/protocols/lorawan/lora/system/utilities.h rename to cores/asr650x/loramac/system/utilities.h diff --git a/cores/asr650x/projects/CubeCellLib.a b/cores/asr650x/projects/CubeCellLib.a index e51c8ef689c9f5a4716435817f3e3c7f94ec719f..6ed82808c9ad62d852edd49ef6f3a49af03460bd 100644 GIT binary patch delta 26034 zcmcJ%349bq`Zr$HJxOLd8A!qaAs0y|;XV>3fg}Xvc0vLK!Yu-U1PE6+f|DVU;N+BB_fyRvgC$!f4jJW<0_@4y-3;)qN zq5ZeVr&opcza1(6o6wRScDVB7;T-La&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eQ}k34Z3M+nC>K?kDqi+L#}N`9U_v-q8~Lmu<{< zoAU24|7RQX`H!RTn$>y_Kl1?apeg|BlWUG9a|zl%dDrc~+Ik8U?df*2Iqn41r_B5l z%)7)go4Fzr!~JPaW9_c^-g!@e8E*xGyXzKDsclRm%JDSS+&o-%s=TI+C>D?0N@xZ0 zhvKIXy|CjSblyAoUNY2bst@FL&?DRUt1&l!h&~s!F%S6%);!E;!ZQ5KE83VxnP*|{ zvtEn4x?Svp`6{TAIqpYVTCZsDkp4pQPeM+{Owdb|&0Y7|>KRjyu(+`~*E6#_wS8c=S7`SbRMtS4t QpSuRoSkEzUKBsm1ZzZ9KP5=M^ diff --git a/libraries/Basics/examples/Factory_Test_AB01/Factory_Test_AB01.ino b/libraries/Basics/examples/Factory_Test_AB01/Factory_Test_AB01.ino index 16c8d440..6d3426dc 100644 --- a/libraries/Basics/examples/Factory_Test_AB01/Factory_Test_AB01.ino +++ b/libraries/Basics/examples/Factory_Test_AB01/Factory_Test_AB01.ino @@ -1,6 +1,6 @@ #include "LoRaWan_APP.h" #include "Arduino.h" -#include "SSD1306Wire.h" +#include "cubecell_SSD1306Wire.h" #include "Wire.h" /* * set LoraWan_RGB to 1,the RGB active @@ -44,7 +44,7 @@ void OnTxTimeout( void ); void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ); void displayInof(); void sleep(void); -void RGB_test(void); +void testRGB(void); typedef enum { @@ -53,15 +53,15 @@ typedef enum TX }States_t; -int16_t txnumber; +int16_t txNumber; States_t state; -bool sleepmode = false; -int16_t RSSI,rxSize; +bool sleepMode = false; +int16_t rssi,rxSize; void setup() { - BoardInitMcu( ); + boardInitMcu( ); Serial.begin(115200); pinMode(Vext, OUTPUT); digitalWrite(Vext, LOW); @@ -69,9 +69,9 @@ void setup() { display.init(); //display.flipScreenVertically(); - RGB_test(); - txnumber=0; - RSSI=0; + testRGB(); + txNumber=0; + rssi=0; pinMode(P3_3,INPUT); attachInterrupt(P3_3,sleep,FALLING); @@ -102,12 +102,12 @@ void loop() { case TX: delay(1000); - txnumber++; + txNumber++; sprintf(txpacket,"%s","hello"); - sprintf(txpacket+strlen(txpacket),"%d",txnumber); + sprintf(txpacket+strlen(txpacket),"%d",txNumber); sprintf(txpacket+strlen(txpacket),"%s"," rssi : "); - sprintf(txpacket+strlen(txpacket),"%d",RSSI); - RGB_ON(0x100000,0); + sprintf(txpacket+strlen(txpacket),"%d",rssi); + turnOnRGB(0x100000,0); Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); @@ -120,22 +120,22 @@ void loop() state=LOWPOWER; break; case LOWPOWER: - if(sleepmode) + if(sleepMode) { Radio.Sleep( ); Wire.end(); detachInterrupt(RADIO_DIO_1); - RGB_OFF(); + turnOffRGB(); pinMode(GPIO0,ANALOG); pinMode(GPIO1,ANALOG); pinMode(GPIO2,ANALOG); pinMode(GPIO3,ANALOG); - pinMode(GPIO4,ANALOG); + pinMode(GPIO4,ANALOG); pinMode(GPIO5,ANALOG); - pinMode(Vext,ANALOG); + pinMode(Vext,ANALOG); pinMode(ADC,ANALOG); } - LowPower_Handler(); + lowPowerHandler(); break; default: break; @@ -147,7 +147,7 @@ void OnTxDone( void ) { Serial.print("TX done......"); displayInof(); - RGB_ON(0,0); + turnOnRGB(0,0); state=RX; } @@ -160,15 +160,15 @@ void OnTxTimeout( void ) void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) { gpioOn(); - RSSI=rssi; + rssi=rssi; rxSize=size; memcpy(rxpacket, payload, size ); rxpacket[size]='\0'; - RGB_ON(0x001000,100); - RGB_ON(0,0); + turnOnRGB(0x001000,100); + turnOnRGB(0,0); Radio.Sleep( ); - Serial.printf("\r\nreceived packet \"%s\" with RSSI %d , length %d\r\n",rxpacket,RSSI,rxSize); + Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize); Serial.println("wait to send next packet"); displayInof(); @@ -178,10 +178,10 @@ void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) void displayInof() { display.clear(); - display.drawString(0, 50, "Packet " + String(txnumber,DEC) + " sent done"); + display.drawString(0, 50, "Packet " + String(txNumber,DEC) + " sent done"); display.drawString(0, 0, "Received Size" + String(rxSize,DEC) + " packages:"); display.drawString(0, 15, rxpacket); - display.drawString(0, 30, "With RSSI " + String(RSSI,DEC)); + display.drawString(0, 30, "With rssi " + String(rssi,DEC)); display.display(); } @@ -191,27 +191,27 @@ void sleep(void) delay(10); if(digitalRead(P3_3)==0) { - sleepmode = true; + sleepMode = true; } } -void RGB_test(void) +void testRGB(void) { display.drawString(0, 20, "RGB Testing"); - display.display(); + display.display(); for(uint32_t i=0;i<=30;i++) { - RGB_ON(i<<16,10); + turnOnRGB(i<<16,10); } for(uint32_t i=0;i<=30;i++) { - RGB_ON(i<<8,10); + turnOnRGB(i<<8,10); } for(uint32_t i=0;i<=30;i++) { - RGB_ON(i,10); + turnOnRGB(i,10); } - RGB_ON(0,0); + turnOnRGB(0,0); } void gpioOn(void) diff --git a/libraries/Basics/examples/Factory_Test_AM01/Factory_Test_AM01.ino b/libraries/Basics/examples/Factory_Test_AM01/Factory_Test_AM01.ino index ca95e2e1..4af1a3fd 100644 --- a/libraries/Basics/examples/Factory_Test_AM01/Factory_Test_AM01.ino +++ b/libraries/Basics/examples/Factory_Test_AM01/Factory_Test_AM01.ino @@ -1,6 +1,6 @@ #include "LoRaWan_APP.h" #include "Arduino.h" -#include "SSD1306Wire.h" +#include "cubecell_SSD1306Wire.h" #include "Wire.h" /* * set LoraWan_RGB to 1,the RGB active @@ -52,15 +52,15 @@ typedef enum TX }States_t; -int16_t txnumber; +int16_t txNumber; States_t state; -bool sleepmode = false; -int16_t RSSI,rxSize; +bool sleepMode = false; +int16_t rssi,rxSize; void setup() { - BoardInitMcu( ); + boardInitMcu( ); Serial.begin(115200); pinMode(ADC, OUTPUT); digitalWrite(ADC, HIGH); @@ -68,8 +68,8 @@ void setup() { display.init(); //display.flipScreenVertically(); - txnumber=0; - RSSI=0; + txNumber=0; + rssi=0; pinMode(GPIO7,INPUT); attachInterrupt(GPIO7,sleep,FALLING); @@ -100,11 +100,11 @@ void loop() { case TX: delay(1000); - txnumber++; + txNumber++; sprintf(txpacket,"%s","hello"); - sprintf(txpacket+strlen(txpacket),"%d",txnumber); + sprintf(txpacket+strlen(txpacket),"%d",txNumber); sprintf(txpacket+strlen(txpacket),"%s"," rssi : "); - sprintf(txpacket+strlen(txpacket),"%d",RSSI); + sprintf(txpacket+strlen(txpacket),"%d",rssi); Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); @@ -117,21 +117,21 @@ void loop() state=LOWPOWER; break; case LOWPOWER: - if(sleepmode) + if(sleepMode) { Radio.Sleep( ); Wire.end(); - Serial.end(); + Serial.end(); detachInterrupt(RADIO_DIO_1); pinMode(GPIO0,ANALOG); pinMode(GPIO1,ANALOG); pinMode(GPIO2,ANALOG); pinMode(GPIO3,ANALOG); - pinMode(GPIO4,ANALOG); + pinMode(GPIO4,ANALOG); pinMode(GPIO5,ANALOG); pinMode(ADC,ANALOG); } - LowPower_Handler(); + lowPowerHandler(); break; default: break; @@ -155,13 +155,13 @@ void OnTxTimeout( void ) void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) { gpioOn(); - RSSI=rssi; + rssi=rssi; rxSize=size; memcpy(rxpacket, payload, size ); rxpacket[size]='\0'; Radio.Sleep( ); - Serial.printf("\r\nreceived packet \"%s\" with RSSI %d , length %d\r\n",rxpacket,RSSI,rxSize); + Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize); Serial.println("wait to send next packet"); displayInof(); @@ -171,10 +171,10 @@ void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) void displayInof() { display.clear(); - display.drawString(0, 50, "Packet " + String(txnumber,DEC) + " sent done"); + display.drawString(0, 50, "Packet " + String(txNumber,DEC) + " sent done"); display.drawString(0, 0, "Received Size" + String(rxSize,DEC) + " packages:"); display.drawString(0, 15, rxpacket); - display.drawString(0, 30, "With RSSI " + String(RSSI,DEC)); + display.drawString(0, 30, "With rssi " + String(rssi,DEC)); display.display(); } @@ -184,7 +184,7 @@ void sleep(void) delay(10); if(digitalRead(P3_3)==0) { - sleepmode = true; + sleepMode = true; } } diff --git a/libraries/Basics/examples/LowPower_WakeUpByGPIO/LowPower_WakeUpByGPIO.ino b/libraries/Basics/examples/LowPower_WakeUpByGPIO/LowPower_WakeUpByGPIO.ino index 9ac45c57..a0517209 100644 --- a/libraries/Basics/examples/LowPower_WakeUpByGPIO/LowPower_WakeUpByGPIO.ino +++ b/libraries/Basics/examples/LowPower_WakeUpByGPIO/LowPower_WakeUpByGPIO.ino @@ -5,12 +5,12 @@ static TimerEvent_t sleep; uint8_t lowpower=1; -void OnSleep() +void onSleep() { Serial.println("into lowpower mode. press user key to wake up"); lowpower=1; } -void wakeup() +void wakeUp() { delay(10); if(digitalRead(GPIO7)==0) @@ -26,18 +26,18 @@ void wakeup() void setup() { // put your setup code here, to run once: Serial.begin(115200); - BoardInitMcu(); + boardInitMcu(); Radio.Sleep( ); pinMode(GPIO7,INPUT); - attachInterrupt(GPIO7,wakeup,FALLING); - TimerInit( &sleep, OnSleep ); + attachInterrupt(GPIO7,wakeUp,FALLING); + TimerInit( &sleep, onSleep ); Serial.println("into lowpower mode. press user key to wake up."); } void loop() { if(lowpower){ - //note that LowPower_Handler() run six times the mcu into lowpower mode; - LowPower_Handler(); + //note that lowPowerHandler() run six times the mcu into lowpower mode; + lowPowerHandler(); } // put your main code here, to run repeatedly: } diff --git a/libraries/Basics/examples/LowPower_WakeUpByTimer/LowPower_WakeUpByTimer.ino b/libraries/Basics/examples/LowPower_WakeUpByTimer/LowPower_WakeUpByTimer.ino index d367908e..d0800e28 100644 --- a/libraries/Basics/examples/LowPower_WakeUpByTimer/LowPower_WakeUpByTimer.ino +++ b/libraries/Basics/examples/LowPower_WakeUpByTimer/LowPower_WakeUpByTimer.ino @@ -4,18 +4,18 @@ #define timetosleep 5000 #define timetowake 5000 static TimerEvent_t sleep; -static TimerEvent_t wakeup; +static TimerEvent_t wakeUp; uint8_t lowpower=1; -void OnSleep() +void onSleep() { Serial.printf("into lowpower mode, %d ms later wake up.\r\n",timetowake); lowpower=1; //timetosleep ms later wake up; - TimerSetValue( &wakeup, timetowake ); - TimerStart( &wakeup ); + TimerSetValue( &wakeUp, timetowake ); + TimerStart( &wakeUp ); } -void OnWakeup() +void onWakeUp() { Serial.printf("wake up, %d ms later into lowpower mode.\r\n",timetosleep); lowpower=0; @@ -27,17 +27,17 @@ void OnWakeup() void setup() { // put your setup code here, to run once: Serial.begin(115200); - BoardInitMcu(); + boardInitMcu(); Radio.Sleep( ); TimerInit( &sleep, OnSleep ); - TimerInit( &wakeup, OnWakeup ); + TimerInit( &wakeUp, onWakeUp ); OnSleep(); } void loop() { if(lowpower){ - //note that LowPower_Handler() run six times the mcu into lowpower mode; - LowPower_Handler(); + //note that lowPowerHandler() run six times the mcu into lowpower mode; + lowPowerHandler(); } // put your main code here, to run repeatedly: } diff --git a/libraries/LoRa/examples/AT_Command/AT_Command.ino b/libraries/LoRa/examples/AT_Command/AT_Command.ino index 284a37ec..47403ad4 100644 --- a/libraries/LoRa/examples/AT_Command/AT_Command.ino +++ b/libraries/LoRa/examples/AT_Command/AT_Command.ino @@ -11,20 +11,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = true; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -45,114 +64,115 @@ bool IsTxConfirmed = true; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { - AppDataSize = 4;//AppDataSize max value is 64 - AppData[0] = 0x00; - AppData[1] = 0x01; - AppData[2] = 0x02; - AppData[3] = 0x03; + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ + appDataSize = 4; + appData[0] = 0x00; + appData[1] = 0x01; + appData[2] = 0x02; + appData[3] = 0x03; } void setup() { - BoardInitMcu(); + boardInitMcu(); Serial.begin(115200); - PassthroughMode = true; - Enable_AT(); + passthroughMode = true; + enableAt(); getDevParam(); printDevParam(); - DeviceState = DEVICE_STATE_SLEEP; - LoRaWAN.Ifskipjoin(); - DeviceState_lora = LORA_INIT; + deviceState = DEVICE_STATE_SLEEP; + LoRaWAN.ifskipjoin(); + deviceState_lora = LORA_INIT; } void loop() { - if(Mode_LoraWan)//loraWan mode(defalt;) + if(modeLoraWan)//loraWan mode(defalt;) { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { //Serial.printf("LoRaWan PassthroughMode start!\r\n"); //Serial.printf("please start with command\r\n"); getDevParam(); - LoRaWAN.Init(CLASS,ACTIVE_REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_SLEEP; + LoRaWAN.send(); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_CYCLE: { // only used while joining - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - DeviceState = DEVICE_STATE_SLEEP; - LoRaWAN.Cycle(TxDutyCycleTime); + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + deviceState = DEVICE_STATE_SLEEP; + LoRaWAN.cycle(txDutyCycleTime); break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_SLEEP; + deviceState = DEVICE_STATE_SLEEP; break; } } } else//lora mode { - switch( DeviceState_lora ) + switch( deviceState_lora ) { case LORA_INIT: { getDevParam(); - LoRa.Init(Lora_FREQ, Lora_TXPW, Lora_SF); - DeviceState_lora = MCU_SLEEP; + LoRa.init(Lora_FREQ, Lora_TXPW, Lora_SF); + deviceState_lora = MCU_SLEEP; break; } case LORA_SEND: { - LoRa.Send(); - DeviceState_lora = MCU_SLEEP; + LoRa.send(); + deviceState_lora = MCU_SLEEP; break; } case LORA_RECEIVE: { - LoRa.Receive(); - DeviceState_lora = MCU_SLEEP; + LoRa.receive(); + deviceState_lora = MCU_SLEEP; break; } case MCU_SLEEP: { - LoRa.LOWPOWER(); + LoRa.lowpower(); break; } default: { - DeviceState_lora = MCU_SLEEP; + deviceState_lora = MCU_SLEEP; break; } } diff --git a/libraries/LoRa/examples/LoRaBasic/LoRaSender/LoRaSender.ino b/libraries/LoRa/examples/LoRaBasic/LoRaSender/LoRaSender.ino index 6ece593c..6dd17b28 100644 --- a/libraries/LoRa/examples/LoRaBasic/LoRaSender/LoRaSender.ino +++ b/libraries/LoRa/examples/LoRaBasic/LoRaSender/LoRaSender.ino @@ -47,21 +47,17 @@ char rxpacket[BUFFER_SIZE]; static RadioEvents_t RadioEvents; -int16_t txnumber; +int16_t txNumber; -int16_t RSSI,rxSize; +int16_t rssi,rxSize; void setup() { - BoardInitMcu( ); + boardInitMcu( ); Serial.begin(115200); - txnumber=0; - RSSI=0; - - - - + txNumber=0; + rssi=0; Radio.Init( &RadioEvents ); Radio.SetChannel( RF_FREQUENCY ); @@ -75,20 +71,16 @@ void setup() { void loop() { - - - delay(1000); - txnumber++; - sprintf(txpacket,"%s","Hello world number"); //start a package - sprintf(txpacket+strlen(txpacket),"%d",txnumber); //add to the end of package + delay(1000); + txNumber++; + sprintf(txpacket,"%s","Hello world number"); //start a package + sprintf(txpacket+strlen(txpacket),"%d",txNumber); //add to the end of package - RGB_ON(COLOR_SEND,0); //change rgb light + turnOnRGB(COLOR_SEND,0); //change rgb color - Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); + Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); - Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out - - + Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out } diff --git a/libraries/LoRa/examples/LoRaBasic/LoRaSender_ReadBattery/LoRaSender_ReadBattery.ino b/libraries/LoRa/examples/LoRaBasic/LoRaSender_ReadBattery/LoRaSender_ReadBattery.ino index 9ae1a26d..9043e555 100644 --- a/libraries/LoRa/examples/LoRaBasic/LoRaSender_ReadBattery/LoRaSender_ReadBattery.ino +++ b/libraries/LoRa/examples/LoRaBasic/LoRaSender_ReadBattery/LoRaSender_ReadBattery.ino @@ -51,7 +51,7 @@ #define RX_TIMEOUT_VALUE 1000 #define BUFFER_SIZE 30 // Define the payload size here -char txpacket[BUFFER_SIZE]; +char txPacket[BUFFER_SIZE]; static RadioEvents_t RadioEvents; void OnTxDone( void ); @@ -67,17 +67,16 @@ typedef enum }States_t; States_t state; -bool sleepmode = false; -int16_t RSSI,rxSize; +bool sleepMode = false; +int16_t rssi,rxSize; uint16_t voltage; void setup() { - BoardInitMcu( ); + boardInitMcu( ); Serial.begin(115200); - // txnumber=0; voltage = 0; - RSSI=0; + rssi=0; RadioEvents.TxDone = OnTxDone; RadioEvents.TxTimeout = OnTxTimeout; @@ -100,19 +99,19 @@ void loop() { case TX: { - sprintf(txpacket,"%s","ADC_battery: "); - sprintf(txpacket+strlen(txpacket),"%d",voltage); - RGB_ON(COLOR_SEND,0); - Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); - Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); + sprintf(txPacket,"%s","ADC_battery: "); + sprintf(txPacket+strlen(txPacket),"%d",voltage); + turnOnRGB(COLOR_SEND,0); + Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txPacket, strlen(txPacket)); + Radio.Send( (uint8_t *)txPacket, strlen(txPacket) ); state=LOWPOWER; break; } case LOWPOWER: { - LowPower_Handler(); + lowPowerHandler(); delay(100); - RGB_OFF(); + turnOffRGB(); delay(2000); //LowPower time state = ReadVoltage; break; @@ -134,7 +133,7 @@ void loop() void OnTxDone( void ) { Serial.print("TX done!"); - RGB_ON(0,0); + turnOnRGB(0,0); state=TX; } diff --git a/libraries/LoRa/examples/LoRaBasic/pingpong/pingpong.ino b/libraries/LoRa/examples/LoRaBasic/pingpong/pingpong.ino index c623db65..94f8966f 100644 --- a/libraries/LoRa/examples/LoRaBasic/pingpong/pingpong.ino +++ b/libraries/LoRa/examples/LoRaBasic/pingpong/pingpong.ino @@ -58,8 +58,6 @@ void OnTxDone( void ); void OnTxTimeout( void ); void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ); - - typedef enum { LOWPOWER, @@ -67,18 +65,18 @@ typedef enum TX }States_t; -int16_t txnumber; +int16_t txNumber; States_t state; -bool sleepmode = false; -int16_t RSSI,rxSize; +bool sleepMode = false; +int16_t rssi,rxSize; void setup() { - BoardInitMcu( ); + boardInitMcu( ); Serial.begin(115200); - txnumber=0; - RSSI=0; + txNumber=0; + rssi=0; RadioEvents.TxDone = OnTxDone; RadioEvents.TxTimeout = OnTxTimeout; @@ -106,12 +104,12 @@ void loop() { case TX: delay(1000); - txnumber++; + txNumber++; sprintf(txpacket,"%s","hello"); - sprintf(txpacket+strlen(txpacket),"%d",txnumber); + sprintf(txpacket+strlen(txpacket),"%d",txNumber); sprintf(txpacket+strlen(txpacket),"%s"," rssi : "); - sprintf(txpacket+strlen(txpacket),"%d",RSSI); - RGB_ON(COLOR_SEND,0); + sprintf(txpacket+strlen(txpacket),"%d",rssi); + turnOnRGB(COLOR_SEND,0); Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); @@ -124,7 +122,7 @@ void loop() state=LOWPOWER; break; case LOWPOWER: - LowPower_Handler(); + lowPowerHandler(); break; default: break; @@ -135,7 +133,7 @@ void loop() void OnTxDone( void ) { Serial.print("TX done......"); - RGB_ON(0,0); + turnOnRGB(0,0); state=RX; } @@ -147,14 +145,14 @@ void OnTxTimeout( void ) } void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) { - RSSI=rssi; + rssi=rssi; rxSize=size; memcpy(rxpacket, payload, size ); rxpacket[size]='\0'; - RGB_ON(COLOR_RECEIVED,0); + turnOnRGB(COLOR_RECEIVED,0); Radio.Sleep( ); - Serial.printf("\r\nreceived packet \"%s\" with RSSI %d , length %d\r\n",rxpacket,RSSI,rxSize); + Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize); Serial.println("wait to send next packet"); state=TX; diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BH1750/LoRaWan_BH1750.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BH1750/LoRaWan_BH1750.ino index 5b95b6e4..4799a2e9 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BH1750/LoRaWan_BH1750.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BH1750/LoRaWan_BH1750.ino @@ -12,20 +12,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -46,18 +65,20 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ BH1750 lightMeter; -static void PrepareTxFrame( uint8_t port ) + +static void prepareTxFrame( uint8_t port ) { + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ pinMode(GPIO0, OUTPUT); pinMode(Vext, OUTPUT); digitalWrite(GPIO0, HIGH); @@ -70,38 +91,39 @@ static void PrepareTxFrame( uint8_t port ) digitalWrite(Vext, HIGH); digitalWrite(GPIO0, LOW); pinMode(GPIO0, ANALOG); - uint16_t BatteryVoltage = GetBatteryVoltage(); + uint16_t batteryVoltage = getBatteryVoltage(); unsigned char *puc; puc = (unsigned char *)(&lux); - AppDataSize = 6;//AppDataSize max value is 64 - AppData[0] = puc[0]; - AppData[1] = puc[1]; - AppData[2] = puc[2]; - AppData[3] = puc[3]; - AppData[4] = (uint8_t)(BatteryVoltage>>8); - AppData[5] = (uint8_t)BatteryVoltage; + + appDataSize = 6; + appData[0] = puc[0]; + appData[1] = puc[1]; + appData[2] = puc[2]; + appData[3] = puc[3]; + appData[4] = (uint8_t)(batteryVoltage>>8); + appData[5] = (uint8_t)batteryVoltage; Serial.print("Light: "); Serial.print(lux); Serial.print(" lx,");Serial.print("BatteryVoltage:"); - Serial.println(BatteryVoltage); + Serial.println(batteryVoltage); } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { @@ -109,40 +131,40 @@ void loop() getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BMP180/LoRaWan_BMP180.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BMP180/LoRaWan_BMP180.ino index bacc3e22..83e3002c 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BMP180/LoRaWan_BMP180.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_BMP180/LoRaWan_BMP180.ino @@ -12,20 +12,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -46,18 +65,20 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ BMP085 bmp; -static void PrepareTxFrame( uint8_t port ) + +static void prepareTxFrame( uint8_t port ) { + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ pinMode(Vext, OUTPUT); digitalWrite(Vext, LOW); @@ -65,7 +86,7 @@ static void PrepareTxFrame( uint8_t port ) float temperature = bmp.readTemperature(); float pressure = bmp.readPressure(); float altitude = bmp.readAltitude(); - float sealevelpressure = bmp.readSealevelPressure(); + float sealevelPressure = bmp.readSealevelPressure(); // you can get a more precise measurement of altitude // if you know the current sea level pressure which will @@ -77,30 +98,30 @@ static void PrepareTxFrame( uint8_t port ) Wire.end(); digitalWrite(Vext, HIGH); - uint16_t BatteryVoltage = GetBatteryVoltage(); + uint16_t batteryVoltage = getBatteryVoltage(); unsigned char *puc; puc = (unsigned char *)(&temperature); - AppDataSize = 14;//AppDataSize max value is 64 - AppData[0] = puc[0]; - AppData[1] = puc[1]; - AppData[2] = puc[2]; - AppData[3] = puc[3]; + appDataSize = 14; + appData[0] = puc[0]; + appData[1] = puc[1]; + appData[2] = puc[2]; + appData[3] = puc[3]; puc = (unsigned char *)(&pressure); - AppData[4] = puc[0]; - AppData[5] = puc[1]; - AppData[6] = puc[2]; - AppData[7] = puc[3]; + appData[4] = puc[0]; + appData[5] = puc[1]; + appData[6] = puc[2]; + appData[7] = puc[3]; puc = (unsigned char *)(&altitude); - AppData[8] = puc[0]; - AppData[9] = puc[1]; - AppData[10] = puc[2]; - AppData[11] = puc[3]; + appData[8] = puc[0]; + appData[9] = puc[1]; + appData[10] = puc[2]; + appData[11] = puc[3]; - AppData[12] = (uint8_t)(BatteryVoltage>>8); - AppData[13] = (uint8_t)BatteryVoltage; + appData[12] = (uint8_t)(batteryVoltage>>8); + appData[13] = (uint8_t)batteryVoltage; Serial.print("Temperature: "); Serial.print(temperature); @@ -108,64 +129,64 @@ static void PrepareTxFrame( uint8_t port ) Serial.print(pressure); Serial.print("Pa, "); Serial.print("BatteryVoltage:"); - Serial.println(BatteryVoltage); + Serial.println(batteryVoltage); } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: - { + { #if(AT_SUPPORT) getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_CCS811/LoRaWan_CCS811.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_CCS811/LoRaWan_CCS811.ino index 82f7a876..fc292693 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_CCS811/LoRaWan_CCS811.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_CCS811/LoRaWan_CCS811.ino @@ -3,6 +3,7 @@ #include #include + /* * set LoraWan_RGB to Active,the RGB active in loraWan * RGB red means sending; @@ -12,20 +13,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -46,18 +66,20 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ CCS811 ccs; -static void PrepareTxFrame( uint8_t port ) + +static void prepareTxFrame( uint8_t port ) { + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ pinMode(Vext, OUTPUT); digitalWrite(Vext, LOW); pinMode(GPIO0,OUTPUT); @@ -91,16 +113,16 @@ static void PrepareTxFrame( uint8_t port ) digitalWrite(Vext, HIGH); digitalWrite(GPIO0,HIGH); digitalWrite(GPIO4,LOW); - uint16_t BatteryVoltage = GetBatteryVoltage(); + uint16_t batteryVoltage = getBatteryVoltage(); - AppDataSize = 6;//AppDataSize max value is 64 - AppData[0] = (uint8_t)(co2>>8); - AppData[1] = (uint8_t)co2; - AppData[2] = (uint8_t)(tvoc>>8); - AppData[3] = (uint8_t)tvoc; - - AppData[4] = (uint8_t)(BatteryVoltage>>8); - AppData[5] = (uint8_t)BatteryVoltage; + appDataSize = 6; + appData[0] = (uint8_t)(co2>>8); + appData[1] = (uint8_t)co2; + appData[2] = (uint8_t)(tvoc>>8); + appData[3] = (uint8_t)tvoc; + + appData[4] = (uint8_t)(batteryVoltage>>8); + appData[5] = (uint8_t)batteryVoltage; Serial.print("CO2: "); Serial.print(co2); @@ -109,64 +131,64 @@ static void PrepareTxFrame( uint8_t port ) Serial.print(tvoc); Serial.print(" ppb,"); Serial.print("BatteryVoltage:"); - Serial.println(BatteryVoltage); + Serial.println(batteryVoltage); } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: - { + { #if(AT_SUPPORT) getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino index 9520d782..bb927772 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino @@ -2,6 +2,8 @@ #include "Arduino.h" #include #include "HDC1080.h" +#include "LoRaWan_APP.h" +#include "Arduino.h" /* * set LoraWan_RGB to Active,the RGB active in loraWan @@ -12,20 +14,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -46,110 +67,111 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /*! * \brief Prepares the payload of the frame */ HDC1080 hdc1080; -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ pinMode(Vext,OUTPUT); digitalWrite(Vext,LOW); hdc1080.begin(0x40); - float Temperature = (float)(hdc1080.readTemperature()); - float Humidity = (float)(hdc1080.readHumidity()); + float temperature = (float)(hdc1080.readTemperature()); + float humidity = (float)(hdc1080.readHumidity()); hdc1080.end(); digitalWrite(Vext,HIGH); - uint16_t BatteryVoltage = GetBatteryVoltage(); + uint16_t batteryVoltage = getBatteryVoltage(); unsigned char *puc; - puc = (unsigned char *)(&Temperature); - AppDataSize = 10;//AppDataSize max value is 64 - AppData[0] = puc[0]; - AppData[1] = puc[1]; - AppData[2] = puc[2]; - AppData[3] = puc[3]; + puc = (unsigned char *)(&temperature); + appDataSize = 10; + appData[0] = puc[0]; + appData[1] = puc[1]; + appData[2] = puc[2]; + appData[3] = puc[3]; - puc = (unsigned char *)(&Humidity); - AppData[4] = puc[0]; - AppData[5] = puc[1]; - AppData[6] = puc[2]; - AppData[7] = puc[3]; + puc = (unsigned char *)(&humidity); + appData[4] = puc[0]; + appData[5] = puc[1]; + appData[6] = puc[2]; + appData[7] = puc[3]; - AppData[8] = (uint8_t)(BatteryVoltage>>8); - AppData[9] = (uint8_t)BatteryVoltage; + appData[8] = (uint8_t)(batteryVoltage>>8); + appData[9] = (uint8_t)batteryVoltage; Serial.print("T="); - Serial.print(Temperature); + Serial.print(temperature); Serial.print("C, RH="); - Serial.print(Humidity); + Serial.print(humidity); Serial.print("%,"); Serial.print("BatteryVoltage:"); - Serial.println(BatteryVoltage); + Serial.println(batteryVoltage); } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: - { + { #if(AT_SUPPORT) getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MPU9250/LoRaWan_MPU9250.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MPU9250/LoRaWan_MPU9250.ino index 66247719..d2ac24f8 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MPU9250/LoRaWan_MPU9250.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MPU9250/LoRaWan_MPU9250.ino @@ -3,7 +3,6 @@ #include #include - /* * set LoraWan_RGB to Active,the RGB active in loraWan * RGB red means sending; @@ -13,20 +12,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -47,23 +65,23 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; - +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ MPU9250 mySensor; -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ float aX, aY, aZ, aSqrt, gX, gY, gZ, mDirection, mX, mY, mZ; - pinMode(Vext, OUTPUT); - digitalWrite(Vext, LOW); + pinMode(Vext, OUTPUT); + digitalWrite(Vext, LOW); Wire.begin(); mySensor.setWire(&Wire); @@ -120,90 +138,90 @@ static void PrepareTxFrame( uint8_t port ) Serial.print("mDirection:"); Serial.println(mDirection); - Wire.end(); - digitalWrite(Vext, HIGH); - uint16_t BatteryVoltage = GetBatteryVoltage(); - unsigned char *puc; - - puc = (unsigned char *)(&aX); - AppDataSize = 46;//AppDataSize max value is 64 - AppData[0] = puc[0]; - AppData[1] = puc[1]; - AppData[2] = puc[2]; - AppData[3] = puc[3]; + Wire.end(); + digitalWrite(Vext, HIGH); + uint16_t batteryVoltage = getBatteryVoltage(); + unsigned char *puc; + + puc = (unsigned char *)(&aX); + appDataSize = 46; + appData[0] = puc[0]; + appData[1] = puc[1]; + appData[2] = puc[2]; + appData[3] = puc[3]; puc = (unsigned char *)(&aY); - AppData[4] = puc[0]; - AppData[5] = puc[1]; - AppData[6] = puc[2]; - AppData[7] = puc[3]; + appData[4] = puc[0]; + appData[5] = puc[1]; + appData[6] = puc[2]; + appData[7] = puc[3]; puc = (unsigned char *)(&aZ); - AppData[8] = puc[0]; - AppData[9] = puc[1]; - AppData[10] = puc[2]; - AppData[11] = puc[3]; + appData[8] = puc[0]; + appData[9] = puc[1]; + appData[10] = puc[2]; + appData[11] = puc[3]; puc = (unsigned char *)(&gX); - AppData[12] = puc[0]; - AppData[13] = puc[1]; - AppData[14] = puc[2]; - AppData[15] = puc[3]; + appData[12] = puc[0]; + appData[13] = puc[1]; + appData[14] = puc[2]; + appData[15] = puc[3]; puc = (unsigned char *)(&gY); - AppData[16] = puc[0]; - AppData[17] = puc[1]; - AppData[18] = puc[2]; - AppData[19] = puc[3]; + appData[16] = puc[0]; + appData[17] = puc[1]; + appData[18] = puc[2]; + appData[19] = puc[3]; puc = (unsigned char *)(&gZ); - AppData[20] = puc[0]; - AppData[21] = puc[1]; - AppData[22] = puc[2]; - AppData[23] = puc[3]; + appData[20] = puc[0]; + appData[21] = puc[1]; + appData[22] = puc[2]; + appData[23] = puc[3]; puc = (unsigned char *)(&mX); - AppData[24] = puc[0]; - AppData[25] = puc[1]; - AppData[26] = puc[2]; - AppData[27] = puc[3]; + appData[24] = puc[0]; + appData[25] = puc[1]; + appData[26] = puc[2]; + appData[27] = puc[3]; puc = (unsigned char *)(&mY); - AppData[28] = puc[0]; - AppData[29] = puc[1]; - AppData[30] = puc[2]; - AppData[31] = puc[3]; + appData[28] = puc[0]; + appData[29] = puc[1]; + appData[30] = puc[2]; + appData[31] = puc[3]; puc = (unsigned char *)(&mZ); - AppData[32] = puc[0]; - AppData[33] = puc[1]; - AppData[34] = puc[2]; - AppData[35] = puc[3]; + appData[32] = puc[0]; + appData[33] = puc[1]; + appData[34] = puc[2]; + appData[35] = puc[3]; puc = (unsigned char *)(&aSqrt); - AppData[36] = puc[0]; - AppData[37] = puc[1]; - AppData[38] = puc[2]; - AppData[39] = puc[3]; + appData[36] = puc[0]; + appData[37] = puc[1]; + appData[38] = puc[2]; + appData[39] = puc[3]; puc = (unsigned char *)(&mDirection); - AppData[40] = puc[0]; - AppData[41] = puc[1]; - AppData[42] = puc[2]; - AppData[43] = puc[3]; + appData[40] = puc[0]; + appData[41] = puc[1]; + appData[42] = puc[2]; + appData[43] = puc[3]; - AppData[44] = (uint8_t)(BatteryVoltage>>8); - AppData[45] = (uint8_t)BatteryVoltage; + appData[44] = (uint8_t)(batteryVoltage>>8); + appData[45] = (uint8_t)batteryVoltage; Serial.print("BatteryVoltage:"); - Serial.println(BatteryVoltage); + Serial.println(batteryVoltage); } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { @@ -211,40 +229,40 @@ void loop() getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MultiSensor/LoRaWan_MultiSensor.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MultiSensor/LoRaWan_MultiSensor.ino index 76a36264..f077d5c3 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MultiSensor/LoRaWan_MultiSensor.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_MultiSensor/LoRaWan_MultiSensor.ino @@ -30,18 +30,15 @@ #define ModularNode 0 // TCS9548A I2C 8 port Switch -const char myDevEui[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const char myAppEui[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const char myAppKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; -/* the application data transmission duty cycle. value in [ms]. */ -uint32_t APP_TX_DUTYCYCLE = 900000; - -/* Indicates if the node is sending confirmed or unconfirmed messages. */ -bool IsTxConfirmed = false; - -/* Number of trials to transmit the frame. */ -uint8_t ConfirmedNbTrials = 8; +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; /* @@ -86,59 +83,51 @@ bool HMC_5883L_e[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // 12 bool UART_e = false; // 200 bool One_Wire_e = false; // 100-103 -/* - set LoraWan_RGB to Active,the RGB active in loraWan - RGB red means sending; - RGB purple means joined done; - RGB blue means RxWindow1; - RGB yellow means RxWindow2; - RGB green means received done; -*/ -#ifndef LoraWan_RGB -#define LoraWan_RGB 0 -#endif -/* - set to 1 the enable AT mode - set to 0 the disable support AT mode -*/ -#ifndef AT_SUPPORT -#define AT_SUPPORT 0 -#endif +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; -#ifndef ACTIVE_REGION -#define ACTIVE_REGION LORAMAC_REGION_EU868 -#endif +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; -#ifndef LORAWAN_CLASS -#define LORAWAN_CLASS CLASS_A -#endif +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; -#ifndef LORAWAN_NETMODE -#define LORAWAN_NETMODE 0 -#endif - -#ifndef LORAWAN_ADR -#define LORAWAN_ADR 1 -#endif - -#ifndef LORAWAN_Net_Reserve -#define LORAWAN_Net_Reserve 1 -#endif - -/*LoraWan Class*/ -DeviceClass_t CLASS = LORAWAN_CLASS; /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; + +/* Indicates if the node is sending confirmed or unconfirmed messages */ +bool isTxConfirmed = LORAWAN_UPLINKMODE; /* Application port */ -uint8_t AppPort = 2; +uint8_t appPort = 2; +/*! +* Number of trials to transmit the frame, if the LoRaMAC layer did not +* receive an acknowledgment. The MAC performs a datarate adaptation, +* according to the LoRaWAN Specification V1.0.2, chapter 18.4, according +* to the following table: +* +* Transmission nb | Data Rate +* ----------------|----------- +* 1 (first) | DR +* 2 | DR +* 3 | max(DR-1,0) +* 4 | max(DR-1,0) +* 5 | max(DR-2,0) +* 6 | max(DR-2,0) +* 7 | max(DR-3,0) +* 8 | max(DR-3,0) +* +* Note, that if NbTrials is set to 1 or 2, the MAC will not decrease +* the datarate, in case the LoRaMAC layer did not receive an acknowledgment +*/ +uint8_t confirmedNbTrials = 8; float Temperature, Humidity, Pressure, lux, co2, tvoc; uint16_t baseline, baselinetemp; @@ -170,7 +159,7 @@ SC16IS740 extSerial(Wire, 0); \brief Prepares the payload of the frame */ -static void PrepareTxFrame(uint8_t port) +static void prepareTxFrame(uint8_t port) { pinMode(Vext, OUTPUT); digitalWrite(Vext, LOW); @@ -178,7 +167,7 @@ static void PrepareTxFrame(uint8_t port) pinMode(GPIO0, OUTPUT); digitalWrite(GPIO0, LOW); - AppDataSize = 0; + appDataSize = 0; int pnr = 0; #if (ModularNode == 1) @@ -221,24 +210,24 @@ static void PrepareTxFrame(uint8_t port) tvoc = CalculateIAQ(); Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 1; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 1; - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); - AppData[AppDataSize++] = (uint8_t)((int)(Humidity * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)(Humidity * 10.0)); + appData[appDataSize++] = (uint8_t)((int)(Humidity * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)(Humidity * 10.0)); - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0) >> 8); ; - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0)); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0)); - AppData[AppDataSize++] = (uint8_t)((int)co2 >> 8); - AppData[AppDataSize++] = (uint8_t)((int)co2); + appData[appDataSize++] = (uint8_t)((int)co2 >> 8); + appData[appDataSize++] = (uint8_t)((int)co2); - AppData[AppDataSize++] = (uint8_t)((int)tvoc >> 8); - AppData[AppDataSize++] = (uint8_t)((int)tvoc); + appData[appDataSize++] = (uint8_t)((int)tvoc >> 8); + appData[appDataSize++] = (uint8_t)((int)tvoc); Serial.print(" BME680: T = "); Serial.print(Temperature); @@ -275,18 +264,18 @@ static void PrepareTxFrame(uint8_t port) Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 2; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 2; - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); - AppData[AppDataSize++] = (uint8_t)((int)(Humidity * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)(Humidity * 10.0)); + appData[appDataSize++] = (uint8_t)((int)(Humidity * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)(Humidity * 10.0)); - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0) >> 8); ; - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0)); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0)); Serial.print(" BME280: T = "); Serial.print(Temperature); @@ -334,14 +323,14 @@ static void PrepareTxFrame(uint8_t port) } hdc1080.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 4; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 4; - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); - AppData[AppDataSize++] = ((int)(Humidity * 10.0)) >> 8; - AppData[AppDataSize++] = (int)(Humidity * 10.0); + appData[appDataSize++] = ((int)(Humidity * 10.0)) >> 8; + appData[appDataSize++] = (int)(Humidity * 10.0); Serial.print(" HDC1080: T = "); Serial.print(Temperature); @@ -411,14 +400,14 @@ static void PrepareTxFrame(uint8_t port) Serial.println(" CCS ERROR"); } - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 3; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 3; - AppData[AppDataSize++] = (uint8_t)((int)co2 >> 8); - AppData[AppDataSize++] = (uint8_t)((int)co2); + appData[appDataSize++] = (uint8_t)((int)co2 >> 8); + appData[appDataSize++] = (uint8_t)((int)co2); - AppData[AppDataSize++] = (uint8_t)((int)tvoc >> 8); - AppData[AppDataSize++] = (uint8_t)((int)tvoc); + appData[appDataSize++] = (uint8_t)((int)tvoc >> 8); + appData[appDataSize++] = (uint8_t)((int)tvoc); Serial.print(" CCS811: CO2 = "); Serial.print(co2); @@ -464,15 +453,15 @@ static void PrepareTxFrame(uint8_t port) Serial.println(" BMP ERROR"); } - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 5; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 5; - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0) >> 8); ; - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0)); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0)); Serial.print(" BMP180: T = "); Serial.print(Temperature); @@ -506,11 +495,11 @@ static void PrepareTxFrame(uint8_t port) lightMeter.end(); Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 6; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 6; - AppData[AppDataSize++] = (uint8_t)((int)(lux * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)(lux * 10.0)); + appData[appDataSize++] = (uint8_t)((int)(lux * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)(lux * 10.0)); Serial.print(" BH1750: Light = "); Serial.print(lux); @@ -561,15 +550,15 @@ static void PrepareTxFrame(uint8_t port) Serial.println(" BMP ERROR"); } - AppData[AppDataSize++] = pnr; + appData[appDataSize++] = pnr; - AppData[AppDataSize++] = 7; + appData[appDataSize++] = 7; - AppData[AppDataSize++] = (uint8_t)(((int)((Temperature + 100.0) * 10.0)) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = (uint8_t)(((int)((Temperature + 100.0) * 10.0)) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); - AppData[AppDataSize++] = (uint8_t)(((int)(Pressure * 10.0)) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)(Pressure * 10.0)); + appData[appDataSize++] = (uint8_t)(((int)(Pressure * 10.0)) >> 8); + appData[appDataSize++] = (uint8_t)((int)(Pressure * 10.0)); Serial.print(" BMP280: T="); Serial.print(Temperature); @@ -612,14 +601,14 @@ static void PrepareTxFrame(uint8_t port) */ Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 8; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 8; - AppData[AppDataSize++] = (uint8_t)(((int)((Temperature + 100.0) * 10.0)) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = (uint8_t)(((int)((Temperature + 100.0) * 10.0)) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); - AppData[AppDataSize++] = ((int)(Humidity * 10.0)) >> 8; - AppData[AppDataSize++] = (int)(Humidity * 10.0); + appData[appDataSize++] = ((int)(Humidity * 10.0)) >> 8; + appData[appDataSize++] = (int)(Humidity * 10.0); Serial.print(" SHT2X: T="); Serial.print(Temperature); @@ -648,17 +637,17 @@ static void PrepareTxFrame(uint8_t port) adc2 = ads1015.readADC_SingleEnded(2); adc3 = ads1015.readADC_SingleEnded(3); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 9; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 9; - AppData[AppDataSize++] = ((int)adc0) >> 8; - AppData[AppDataSize++] = (int)adc0; - AppData[AppDataSize++] = ((int)adc1) >> 8; - AppData[AppDataSize++] = (int)adc1; - AppData[AppDataSize++] = ((int)adc2) >> 8; - AppData[AppDataSize++] = (int)adc2; - AppData[AppDataSize++] = ((int)adc3) >> 8; - AppData[AppDataSize++] = (int)adc3; + appData[appDataSize++] = ((int)adc0) >> 8; + appData[appDataSize++] = (int)adc0; + appData[appDataSize++] = ((int)adc1) >> 8; + appData[appDataSize++] = (int)adc1; + appData[appDataSize++] = ((int)adc2) >> 8; + appData[appDataSize++] = (int)adc2; + appData[appDataSize++] = ((int)adc3) >> 8; + appData[appDataSize++] = (int)adc3; Serial.print(" ADS1015: ADC0="); Serial.print(adc0); @@ -754,65 +743,65 @@ static void PrepareTxFrame(uint8_t port) Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 10; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 10; unsigned char *puc; puc = (unsigned char *)(&aX); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&aY); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&aZ); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&gX); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&gY); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&gZ); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&mX); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&mY); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&mZ); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&aSqrt); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&mDirection); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; } /* @@ -844,15 +833,15 @@ static void PrepareTxFrame(uint8_t port) Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 11; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 11; unsigned char *puc; puc = (unsigned char *)(&distance); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; } /* @@ -886,25 +875,25 @@ static void PrepareTxFrame(uint8_t port) Wire.end(); - AppData[AppDataSize++] = pnr; - AppData[AppDataSize++] = 12; + appData[appDataSize++] = pnr; + appData[appDataSize++] = 12; unsigned char *puc; puc = (unsigned char *)(&raw.XAxis); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&raw.YAxis); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; puc = (unsigned char *)(&raw.ZAxis); - AppData[AppDataSize++] = puc[0]; - AppData[AppDataSize++] = puc[1]; - AppData[AppDataSize++] = puc[2]; - AppData[AppDataSize++] = puc[3]; + appData[appDataSize++] = puc[0]; + appData[appDataSize++] = puc[1]; + appData[appDataSize++] = puc[2]; + appData[appDataSize++] = puc[3]; } #if (ModularNode == 1) } @@ -936,8 +925,8 @@ static void PrepareTxFrame(uint8_t port) Wire.end(); - AppData[AppDataSize++] = 0; - AppData[AppDataSize++] = 200; + appData[appDataSize++] = 0; + appData[appDataSize++] = 200; } @@ -956,10 +945,10 @@ static void PrepareTxFrame(uint8_t port) for (int idxx=0; idxx < sensors.getDeviceCount(); idxx++) { Temperature = sensors.getTempCByIndex(idxx); - AppData[AppDataSize++] = 100; - AppData[AppDataSize++] = 100 + idxx; - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); - AppData[AppDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); + appData[appDataSize++] = 100; + appData[appDataSize++] = 100 + idxx; + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0) >> 8); + appData[appDataSize++] = (uint8_t)((int)((Temperature + 100.0) * 10.0)); Serial.print(" OW"); if (idxx < 10) { @@ -982,20 +971,16 @@ static void PrepareTxFrame(uint8_t port) digitalWrite(Vext, HIGH); - uint16_t BatteryVoltage = GetBatteryVoltage(); - AppData[AppDataSize++] = (uint8_t)(BatteryVoltage >> 8); - AppData[AppDataSize++] = (uint8_t)BatteryVoltage; + uint16_t batteryVoltage = getBatteryVoltage(); + appData[appDataSize++] = (uint8_t)(batteryVoltage >> 8); + appData[appDataSize++] = (uint8_t)batteryVoltage; Serial.print("BatteryVoltage: "); - Serial.print(BatteryVoltage); + Serial.print(batteryVoltage); Serial.println(); } void setup() { - memcpy(DevEui, myDevEui, sizeof(myDevEui)); - memcpy(AppEui, myAppEui, sizeof(myAppEui)); - memcpy(AppKey, myAppKey, sizeof(myAppKey)); - #if (AUTO_SCAN == 1) for (int xx = 0; xx < 8; xx++) { @@ -1069,24 +1054,24 @@ void setup() // UART_e = true; //#endif - BoardInitMcu(); + boardInitMcu(); Serial.begin(115200); Serial.println("Copyright @ 2019 WASN.eu"); Serial.print("FW-version: "); Serial.println(wasnver); Serial.println(""); -#if (AT_SUPPORT == 1) - Enable_AT(); +#if(AT_SUPPORT) + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); -pinMode(Vext, OUTPUT); -digitalWrite(Vext, LOW); //set vext to high -delay(500); -pinMode(GPIO0, OUTPUT); -digitalWrite(GPIO0, LOW); -Wire.begin(); + pinMode(Vext, OUTPUT); + digitalWrite(Vext, LOW); //set vext to high + delay(500); + pinMode(GPIO0, OUTPUT); + digitalWrite(GPIO0, LOW); + Wire.begin(); #if (AUTO_SCAN == 1) byte error, address; @@ -1257,52 +1242,52 @@ Wire.begin(); void loop() { - switch (DeviceState) - { - case DEVICE_STATE_INIT: - { -#if (AT_SUPPORT == 1) - getDevParam(); + switch( deviceState ) + { + case DEVICE_STATE_INIT: + { +#if(AT_SUPPORT) + getDevParam(); #endif - printDevParam(); - Serial.printf("LoRaWan Class % X start! \r\n", CLASS + 10); - LoRaWAN.Init(CLASS, REGION); - DeviceState = DEVICE_STATE_JOIN; - break; - } - case DEVICE_STATE_JOIN: - { - LoRaWAN.Join(); - break; - } - case DEVICE_STATE_SEND: - { - PrepareTxFrame(AppPort); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; - break; - } - case DEVICE_STATE_CYCLE: - { - // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr(0, APP_TX_DUTYCYCLE_RND); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; - break; - } - case DEVICE_STATE_SLEEP: - { - LoRaWAN.Sleep(); - break; - } - default: - { - DeviceState = DEVICE_STATE_INIT; - break; - } - } + printDevParam(); + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; + break; + } + case DEVICE_STATE_JOIN: + { + LoRaWAN.join(); + break; + } + case DEVICE_STATE_SEND: + { + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; + break; + } + case DEVICE_STATE_CYCLE: + { + // Schedule next packet transmission + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; + break; + } + case DEVICE_STATE_SLEEP: + { + LoRaWAN.sleep(); + break; + } + default: + { + deviceState = DEVICE_STATE_INIT; + break; + } + } } + float CalculateIAQ() { float hum_weighting = 0.25; // so hum effect is 25% of the total air quality score @@ -1353,7 +1338,7 @@ void tcaselect(uint8_t i) Wire.endTransmission(); } -bool AT_user_check(char *cmd, char *content) +bool checkUserAt(char *cmd, char *content) { if (strcmp(cmd, "VER") == 0) { @@ -1368,7 +1353,7 @@ bool AT_user_check(char *cmd, char *content) } //downlink data handle function -void DownLinkDataHandle(McpsIndication_t *mcpsIndication) +void downLinkDataHandle(McpsIndication_t *mcpsIndication) { Serial.printf("+REV DATA:%s,RXSIZE %d,PORT %d\r\n",mcpsIndication->RxSlot?"RXWIN2":"RXWIN1",mcpsIndication->BufferSize,mcpsIndication->Port); Serial.print("+REV DATA:"); @@ -1378,11 +1363,11 @@ void DownLinkDataHandle(McpsIndication_t *mcpsIndication) Serial.println(); for(uint8_t i=0;iBufferSize;i++) { if (mcpsIndication->Buffer[i] == 220) { // DC for APP_TX_DUTYCYCLE; 0D BB A0 for 900000 (15min); 04 93 E0 for 300000 (5min) - APP_TX_DUTYCYCLE = mcpsIndication->Buffer[i++]<<32|mcpsIndication->Buffer[i++]<<16|mcpsIndication->Buffer[i++]<<8|mcpsIndication->Buffer[i++]; + appTxDutyCycle = mcpsIndication->Buffer[i++]<<32|mcpsIndication->Buffer[i++]<<16|mcpsIndication->Buffer[i++]<<8|mcpsIndication->Buffer[i++]; Serial.print(" new DutyCycle received: "); - Serial.print(APP_TX_DUTYCYCLE); + Serial.print(appTxDutyCycle); Serial.println("ms"); - SaveDr(); + saveDr(); } } -} \ No newline at end of file +} diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors_ThirdParty/examples/LoRaWAN_BMP280/LoRaWAN_BMP280.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors_ThirdParty/examples/LoRaWAN_BMP280/LoRaWAN_BMP280.ino index 91c7642a..4dea82df 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors_ThirdParty/examples/LoRaWAN_BMP280/LoRaWAN_BMP280.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors_ThirdParty/examples/LoRaWAN_BMP280/LoRaWAN_BMP280.ino @@ -12,20 +12,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -46,15 +65,9 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; +uint8_t confirmedNbTrials = 8; -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; - -float Temperature, Humidity, Pressure, lux, co2, tvoc; +float temperature, humidity, pressure, lux, co2, tvoc; uint16_t baseline; int count; int maxtry = 50; @@ -65,8 +78,15 @@ BMP280 bmp; \brief Prepares the payload of the frame */ -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ pinMode(Vext, OUTPUT); digitalWrite(Vext, LOW); delay(500); @@ -79,9 +99,9 @@ static void PrepareTxFrame( uint8_t port ) BMP280::FILTER_X16, /* Filtering. */ BMP280::STANDBY_MS_500); /* Standby time. */ float temp = bmp.readTemperature(); - Pressure = (float)bmp.readPressure() / 100.0; + pressure = (float)bmp.readPressure() / 100.0; Wire.end(); - while (Pressure > 1190.0 && count < maxtry) { + while (pressure > 1190.0 && count < maxtry) { bmp.begin(); delay(500); bmp.setSampling(BMP280::MODE_NORMAL, /* Operating Mode. */ @@ -89,69 +109,69 @@ static void PrepareTxFrame( uint8_t port ) BMP280::SAMPLING_X16, /* Pressure oversampling */ BMP280::FILTER_X16, /* Filtering. */ BMP280::STANDBY_MS_500); /* Standby time. */ - Pressure = (float)bmp.readPressure() / 100.0; + pressure = (float)bmp.readPressure() / 100.0; Wire.end(); count++; delay(500); } - if (Pressure > 1190.0) { - Pressure = 0; + if (pressure > 1190.0) { + pressure = 0; Serial.println("BMP ERROR"); } Wire.end(); digitalWrite(Vext, HIGH); - uint16_t BatteryVoltage = GetBatteryVoltage(); + uint16_t batteryVoltage = getBatteryVoltage(); unsigned char *puc; - puc = (unsigned char *)(&Temperature); - AppDataSize = 26;//AppDataSize max value is 64 - AppData[0] = puc[0]; - AppData[1] = puc[1]; - AppData[2] = puc[2]; - AppData[3] = puc[3]; + puc = (unsigned char *)(&temperature); + appDataSize = 26; + appData[0] = puc[0]; + appData[1] = puc[1]; + appData[2] = puc[2]; + appData[3] = puc[3]; - puc = (unsigned char *)(&Humidity); - AppData[4] = puc[0]; - AppData[5] = puc[1]; - AppData[6] = puc[2]; - AppData[7] = puc[3]; + puc = (unsigned char *)(&humidity); + appData[4] = puc[0]; + appData[5] = puc[1]; + appData[6] = puc[2]; + appData[7] = puc[3]; puc = (unsigned char *)(&lux); - AppData[8] = puc[0]; - AppData[9] = puc[1]; - AppData[10] = puc[2]; - AppData[11] = puc[3]; + appData[8] = puc[0]; + appData[9] = puc[1]; + appData[10] = puc[2]; + appData[11] = puc[3]; - puc = (unsigned char *)(&Pressure); - AppData[12] = puc[0]; - AppData[13] = puc[1]; - AppData[14] = puc[2]; - AppData[15] = puc[3]; + puc = (unsigned char *)(&pressure); + appData[12] = puc[0]; + appData[13] = puc[1]; + appData[14] = puc[2]; + appData[15] = puc[3]; puc = (unsigned char *)(&co2); - AppData[16] = puc[0]; - AppData[17] = puc[1]; - AppData[18] = puc[2]; - AppData[19] = puc[3]; + appData[16] = puc[0]; + appData[17] = puc[1]; + appData[18] = puc[2]; + appData[19] = puc[3]; puc = (unsigned char *)(&tvoc); - AppData[20] = puc[0]; - AppData[21] = puc[1]; - AppData[22] = puc[2]; - AppData[23] = puc[3]; + appData[20] = puc[0]; + appData[21] = puc[1]; + appData[22] = puc[2]; + appData[23] = puc[3]; - AppData[24] = (uint8_t)(BatteryVoltage >> 8); - AppData[25] = (uint8_t)BatteryVoltage; + appData[24] = (uint8_t)(batteryVoltage >> 8); + appData[25] = (uint8_t)batteryVoltage; Serial.print("T="); - Serial.print(Temperature); + Serial.print(temperature); Serial.print("C, RH="); - Serial.print(Humidity); + Serial.print(humidity); Serial.print("%, Lux="); Serial.print(lux); Serial.print(" lx, Pressure="); - Serial.print(Pressure); + Serial.print(pressure); Serial.print(" hPA, CO2="); Serial.print(co2); Serial.print(" ppm, TVOC="); @@ -159,61 +179,64 @@ static void PrepareTxFrame( uint8_t port ) Serial.print(" ppb, Baseline: "); Serial.print(baseline); Serial.print(", BatteryVoltage:"); - Serial.println(BatteryVoltage); + Serial.println(batteryVoltage); } void setup() { - BoardInitMcu( ); - Serial.begin(115200); - DeviceState = DEVICE_STATE_INIT; + boardInitMcu(); + Serial.begin(115200); +#if(AT_SUPPORT) + enableAt(); +#endif + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch ( DeviceState ) - { - case DEVICE_STATE_INIT: - { - Serial.printf("LoRaWan Class%X test start! \r\n", CLASS + 10); + switch( deviceState ) + { + case DEVICE_STATE_INIT: + { #if(AT_SUPPORT) - Enable_AT(); - getDevParam(); + getDevParam(); #endif - printDevParam(); - LoRaWAN.Init(CLASS, ACTIVE_REGION); - DeviceState = DEVICE_STATE_JOIN; - break; - } - case DEVICE_STATE_JOIN: - { - LoRaWAN.Join(); - break; - } - case DEVICE_STATE_SEND: - { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; - break; - } - case DEVICE_STATE_CYCLE: - { - // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; - break; - } - case DEVICE_STATE_SLEEP: - { - LoRaWAN.Sleep(); - break; - } - default: - { - DeviceState = DEVICE_STATE_INIT; - break; - } - } -} \ No newline at end of file + printDevParam(); + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; + break; + } + case DEVICE_STATE_JOIN: + { + LoRaWAN.join(); + break; + } + case DEVICE_STATE_SEND: + { + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; + break; + } + case DEVICE_STATE_CYCLE: + { + // Schedule next packet transmission + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; + break; + } + case DEVICE_STATE_SLEEP: + { + LoRaWAN.sleep(); + break; + } + default: + { + deviceState = DEVICE_STATE_INIT; + break; + } + } +} + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWan/LoRaWan.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWan/LoRaWan.ino index 5cd813dc..1986ba8f 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWan/LoRaWan.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWan/LoRaWan.ino @@ -10,19 +10,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; + +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -43,79 +63,79 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { - AppDataSize = 4;//AppDataSize max value is 64 - AppData[0] = 0x00; - AppData[1] = 0x01; - AppData[2] = 0x02; - AppData[3] = 0x03; + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ + appDataSize = 4; + appData[0] = 0x00; + appData[1] = 0x01; + appData[2] = 0x02; + appData[3] = 0x03; } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { #if(AT_SUPPORT) - getDevParam(); + getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWan_downlinkdatahandle/LoRaWan_downlinkdatahandle.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWan_downlinkdatahandle/LoRaWan_downlinkdatahandle.ino index cf4e1744..6a41c79d 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWan_downlinkdatahandle/LoRaWan_downlinkdatahandle.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWan_downlinkdatahandle/LoRaWan_downlinkdatahandle.ino @@ -10,19 +10,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; + +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -43,26 +63,27 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { - AppDataSize = 4;//AppDataSize max value is 64 - AppData[0] = 0x00; - AppData[1] = 0x01; - AppData[2] = 0x02; - AppData[3] = 0x03; + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ + appDataSize = 4; + appData[0] = 0x00; + appData[1] = 0x01; + appData[2] = 0x02; + appData[3] = 0x03; } //downlink data handle function example -void DownLinkDataHandle(McpsIndication_t *mcpsIndication) +void downLinkDataHandle(McpsIndication_t *mcpsIndication) { Serial.printf("+REV DATA:%s,RXSIZE %d,PORT %d\r\n",mcpsIndication->RxSlot?"RXWIN2":"RXWIN1",mcpsIndication->BufferSize,mcpsIndication->Port); Serial.print("+REV DATA:"); @@ -73,65 +94,64 @@ void DownLinkDataHandle(McpsIndication_t *mcpsIndication) Serial.println(); uint32_t color=mcpsIndication->Buffer[0]<<16|mcpsIndication->Buffer[1]<<8|mcpsIndication->Buffer[2]; #if(LoraWan_RGB==1) - RGB_ON(color,5000); - RGB_OFF(); + turnOnRGB(color,5000); + turnOffRGB(); #endif } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { #if(AT_SUPPORT) - getDevParam(); + getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWan_interrupt/LoRaWan_interrupt.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWan_interrupt/LoRaWan_interrupt.ino index 2fe61bf0..01dacd78 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWan_interrupt/LoRaWan_interrupt.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWan_interrupt/LoRaWan_interrupt.ino @@ -1,108 +1,111 @@ #include "LoRaWan_APP.h" -#include #include "Arduino.h" -const char myDevEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -const char myAppEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -const char myAppKey[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; // The interrupt pin is attached to D4/GPIO1 #define INT_PIN GPIO1 +/* Application port */ +#define DEVPORT 2 +#define APPPORT 1 + bool accelWoke = false; -DeviceClass_t CLASS = LORAWAN_CLASS; +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = (24 * 60 * 60 * 1000); // 24h; /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; -/* LoRaWAN Adaptive Data Rate */ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +/*ADR enable*/ +bool loraWanAdr = LORAWAN_ADR; /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; - -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = DEVPORT; /*! - Number of trials to transmit the frame, if the LoRaMAC layer did not - receive an acknowledgment. The MAC performs a datarate adaptation, - according to the LoRaWAN Specification V1.0.2, chapter 18.4, according - to the following table: - - Transmission nb | Data Rate - ----------------|----------- - 1 (first) | DR - 2 | DR - 3 | max(DR-1,0) - 4 | max(DR-1,0) - 5 | max(DR-2,0) - 6 | max(DR-2,0) - 7 | max(DR-3,0) - 8 | max(DR-3,0) - - Note, that if NbTrials is set to 1 or 2, the MAC will not decrease - the datarate, in case the LoRaMAC layer did not receive an acknowledgment +* Number of trials to transmit the frame, if the LoRaMAC layer did not +* receive an acknowledgment. The MAC performs a datarate adaptation, +* according to the LoRaWAN Specification V1.0.2, chapter 18.4, according +* to the following table: +* +* Transmission nb | Data Rate +* ----------------|----------- +* 1 (first) | DR +* 2 | DR +* 3 | max(DR-1,0) +* 4 | max(DR-1,0) +* 5 | max(DR-2,0) +* 6 | max(DR-2,0) +* 7 | max(DR-3,0) +* 8 | max(DR-3,0) +* +* Note, that if NbTrials is set to 1 or 2, the MAC will not decrease +* the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -#define DEVPORT 2 -#define APPPORT 1 -uint8_t AppPort = 1; +uint8_t confirmedNbTrials = 8; -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = (24 * 60 * 60 * 1000); // 24h /* Prepares the payload of the frame */ static bool prepareTxFrame( uint8_t port ) { int head; - AppPort = port; + appPort = port; switch (port) { case 1: // woke up from interrupt Serial.println("Sending data packet"); - AppDataSize = 1;//AppDataSize max value is 64 - AppData[0] = 0xFF; // set to something useful + appDataSize = 1;//AppDataSize max value is 64 + appData[0] = 0xFF; // set to something useful break; case 2: // daily wake up Serial.println("Sending dev status packet"); - AppDataSize = 1;//AppDataSize max value is 64 - AppData[0] = 0xA0; // set to something else useful + appDataSize = 1;//AppDataSize max value is 64 + appData[0] = 0xA0; // set to something else useful break; } return true; } -extern uint8_t DevEui[]; -extern uint8_t AppEui[]; -extern uint8_t AppKey[]; -extern bool IsLoRaMacNetworkJoined; - void accelWakeup() { - accelWoke = true; + delay(10); + if(digitalRead(INT_PIN)==HIGH) + { + accelWoke = true; + } } void setup() { + boardInitMcu(); Serial.begin(115200); +#if(AT_SUPPORT) + enableAt(); +#endif + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); - delay(200); // wait for stable accelWoke = false; - - memcpy(DevEui, myDevEui, sizeof(myDevEui)); - memcpy(AppEui, myAppEui, sizeof(myAppEui)); - memcpy(AppKey, myAppKey, sizeof(myAppKey)); - BoardInitMcu(); - - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); - - pinMode(INT_PIN, INPUT); + PINMODE_INPUT_PULLDOWN(INT_PIN); attachInterrupt(INT_PIN, accelWakeup, RISING); Serial.println("Interrupts attached"); } @@ -114,58 +117,55 @@ void loop() Serial.print(now); Serial.println("accel woke"); } - switch ( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: - { - Serial.printf("LoRaWan Class%X test start! \r\n", CLASS + 10); + { #if(AT_SUPPORT) - Enable_AT(); - getDevParam(); + getDevParam(); #endif - printDevParam(); - LoRaWAN.Init(CLASS, REGION); - DeviceState = DEVICE_STATE_JOIN; - break; - } + printDevParam(); + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; + break; + } case DEVICE_STATE_JOIN: - { - LoRaWAN.Join(); - break; - } - case DEVICE_STATE_SEND: // a send is scheduled to occur, usu. daily status - { - prepareTxFrame( DEVPORT ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; - break; - } + { + LoRaWAN.join(); + break; + } + case DEVICE_STATE_SEND: + { + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; + break; + } case DEVICE_STATE_CYCLE: - { - // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; - break; - } + { + // Schedule next packet transmission + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; + break; + } case DEVICE_STATE_SLEEP: - { - if (accelWoke) { - if (IsLoRaMacNetworkJoined) { - if(prepareTxFrame(APPPORT)) { - LoRaWAN.Send(); - } + { + if (accelWoke) { + if (IsLoRaMacNetworkJoined) { + if(prepareTxFrame(APPPORT)) { + LoRaWAN.send(); } - accelWoke = false; } - LoRaWAN.Sleep(); - Serial.println("LoRaWAN.Sleep() finished"); - break; + accelWoke = false; } + LoRaWAN.sleep(); + break; + } default: - { - DeviceState = DEVICE_STATE_INIT; - break; - } + { + deviceState = DEVICE_STATE_INIT; + break; + } } -} +} \ No newline at end of file diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWan_multicast/LoRaWan_multicast.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWan_multicast/LoRaWan_multicast.ino index 2d37e285..10edf9fd 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWan_multicast/LoRaWan_multicast.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWan_multicast/LoRaWan_multicast.ino @@ -1,7 +1,6 @@ #include "LoRaWan_APP.h" #include "Arduino.h" - /* * set LoraWan_RGB to Active,the RGB active in loraWan * RGB red means sending; @@ -11,20 +10,45 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=CLASS_C; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + + +MulticastParams_t mult1; +uint8_t mulNwkSKey[]={0x5c,0x1d,0xce,0x81,0xd8,0x19,0x40,0xb9,0xe0,0xfb,0x1e,0x07,0xdd,0x4d,0xd3,0x9c}; +uint8_t mulAppSKey[]={0x6b,0x5b,0x47,0x6f,0x73,0xb6,0xc3,0x98,0xc8,0x11,0xa8,0xd0,0xd9,0x9f,0x25,0xc7}; +uint32_t multicastAddress=0x00638f9e; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*only Class C support malticast*/ +DeviceClass_t loraWanClass = CLASS_C; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -45,37 +69,35 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { - AppDataSize = 4;//AppDataSize max value is 64 - AppData[0] = 0x00; - AppData[1] = 0x01; - AppData[2] = 0x02; - AppData[3] = 0x03; + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ + appDataSize = 4; + appData[0] = 0x00; + appData[1] = 0x01; + appData[2] = 0x02; + appData[3] = 0x03; } -MulticastParams_t mult1; -uint8_t mulNwkSKey[]={0x5c,0x1d,0xce,0x81,0xd8,0x19,0x40,0xb9,0xe0,0xfb,0x1e,0x07,0xdd,0x4d,0xd3,0x9c}; -uint8_t mulAppSKey[]={0x6b,0x5b,0x47,0x6f,0x73,0xb6,0xc3,0x98,0xc8,0x11,0xa8,0xd0,0xd9,0x9f,0x25,0xc7}; -uint32_t multicastAddress=0x00638f9e; - void setup() { - BoardInitMcu(); + boardInitMcu(); Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); + + //add multicast mult1.Address=multicastAddress; for(int i=0;i<16;i++) { @@ -87,48 +109,48 @@ void setup() { void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { #if(AT_SUPPORT) - getDevParam(); + getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan mutlcast start! \r\n"); - LoRaWAN.Init(CLASS,ACTIVE_REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } } + diff --git a/libraries/LoRa/examples/LoRaWAN/LoRaWan_user_AT/LoRaWan_user_AT.ino b/libraries/LoRa/examples/LoRaWAN/LoRaWan_user_AT/LoRaWan_user_AT.ino index 1da43dc4..f68ffb3f 100644 --- a/libraries/LoRa/examples/LoRaWAN/LoRaWan_user_AT/LoRaWan_user_AT.ino +++ b/libraries/LoRa/examples/LoRaWAN/LoRaWan_user_AT/LoRaWan_user_AT.ino @@ -10,19 +10,39 @@ * RGB green means received done; */ -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; +/* OTAA para*/ +uint8_t devEui[] = { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02 }; +uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +uint8_t appKey[] = { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 }; + +/* ABP para*/ +uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; +uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; +uint32_t devAddr = ( uint32_t )0x007e6ae1; + +/*LoraWan region, select in arduino IDE tools*/ +LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; + +/*LoraWan Class, Class A and Class C are supported*/ +DeviceClass_t loraWanClass = LORAWAN_CLASS; + +/*the application data transmission duty cycle. value in [ms].*/ +uint32_t appTxDutyCycle = 15000; + /*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; +bool overTheAirActivation = LORAWAN_NETMODE; + /*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; +bool loraWanAdr = LORAWAN_ADR; + /* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; +bool keepNet = LORAWAN_NET_RESERVE; /* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; +bool isTxConfirmed = LORAWAN_UPLINKMODE; + +/* Application port */ +uint8_t appPort = 2; /*! * Number of trials to transmit the frame, if the LoRaMAC layer did not * receive an acknowledgment. The MAC performs a datarate adaptation, @@ -43,22 +63,23 @@ bool IsTxConfirmed = LORAWAN_UPLINKMODE; * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease * the datarate, in case the LoRaMAC layer did not receive an acknowledgment */ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; +uint8_t confirmedNbTrials = 8; /* Prepares the payload of the frame */ -static void PrepareTxFrame( uint8_t port ) +static void prepareTxFrame( uint8_t port ) { - AppDataSize = 4;//AppDataSize max value is 64 - AppData[0] = 0x00; - AppData[1] = 0x01; - AppData[2] = 0x02; - AppData[3] = 0x03; + /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". + *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. + *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. + *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. + *for example, if use REGION_CN470, + *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". + */ + appDataSize = 4; + appData[0] = 0x00; + appData[1] = 0x01; + appData[2] = 0x02; + appData[3] = 0x03; } /* function for user AT command @@ -69,7 +90,7 @@ static void PrepareTxFrame( uint8_t port ) * XXX is the para * cmd and YYYY is the para * content * you can test with 'AT+test=abcd' */ -bool AT_user_check(char * cmd, char * content) +bool checkUserAt(char * cmd, char * content) { if(strcmp(cmd,"test")==0) { @@ -84,59 +105,59 @@ bool AT_user_check(char * cmd, char * content) } void setup() { - BoardInitMcu(); - Serial.begin(115200); + boardInitMcu(); + Serial.begin(115200); #if(AT_SUPPORT) - Enable_AT(); + enableAt(); #endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); + deviceState = DEVICE_STATE_INIT; + LoRaWAN.ifskipjoin(); } void loop() { - switch( DeviceState ) + switch( deviceState ) { case DEVICE_STATE_INIT: { #if(AT_SUPPORT) - getDevParam(); + getDevParam(); #endif printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; + LoRaWAN.init(loraWanClass,loraWanRegion); + deviceState = DEVICE_STATE_JOIN; break; } case DEVICE_STATE_JOIN: { - LoRaWAN.Join(); + LoRaWAN.join(); break; } case DEVICE_STATE_SEND: { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; + prepareTxFrame( appPort ); + LoRaWAN.send(); + deviceState = DEVICE_STATE_CYCLE; break; } case DEVICE_STATE_CYCLE: { // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; + txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND ); + LoRaWAN.cycle(txDutyCycleTime); + deviceState = DEVICE_STATE_SLEEP; break; } case DEVICE_STATE_SLEEP: { - LoRaWAN.Sleep(); + LoRaWAN.sleep(); break; } default: { - DeviceState = DEVICE_STATE_INIT; + deviceState = DEVICE_STATE_INIT; break; } } -} \ No newline at end of file +} + diff --git a/libraries/LoRa/examples/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino b/libraries/LoRa/examples/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino deleted file mode 100644 index 2a041ab3..00000000 --- a/libraries/LoRa/examples/LoRaWAN_Sensors/LoRaWan_HDC1080/LoRaWan_HDC1080.ino +++ /dev/null @@ -1,155 +0,0 @@ -#include "LoRaWan_APP.h" -#include "Arduino.h" -#include -#include "HDC1080.h" - -/* - * set LoraWan_RGB to Active,the RGB active in loraWan - * RGB red means sending; - * RGB purple means joined done; - * RGB blue means RxWindow1; - * RGB yellow means RxWindow2; - * RGB green means received done; - */ - -/*LoraWan Class*/ -DeviceClass_t CLASS=LORAWAN_CLASS; -/*OTAA or ABP*/ -bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE; -/*ADR enable*/ -bool LORAWAN_ADR_ON = LORAWAN_ADR; -/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */ -bool KeepNet = LORAWAN_Net_Reserve; -/*LoraWan REGION*/ -LoRaMacRegion_t REGION = ACTIVE_REGION; - -/* Indicates if the node is sending confirmed or unconfirmed messages */ -bool IsTxConfirmed = LORAWAN_UPLINKMODE; - -/*! -* Number of trials to transmit the frame, if the LoRaMAC layer did not -* receive an acknowledgment. The MAC performs a datarate adaptation, -* according to the LoRaWAN Specification V1.0.2, chapter 18.4, according -* to the following table: -* -* Transmission nb | Data Rate -* ----------------|----------- -* 1 (first) | DR -* 2 | DR -* 3 | max(DR-1,0) -* 4 | max(DR-1,0) -* 5 | max(DR-2,0) -* 6 | max(DR-2,0) -* 7 | max(DR-3,0) -* 8 | max(DR-3,0) -* -* Note, that if NbTrials is set to 1 or 2, the MAC will not decrease -* the datarate, in case the LoRaMAC layer did not receive an acknowledgment -*/ -uint8_t ConfirmedNbTrials = 8; - -/* Application port */ -uint8_t AppPort = 2; - -/*the application data transmission duty cycle. value in [ms].*/ -uint32_t APP_TX_DUTYCYCLE = 15000; - -/*! - * \brief Prepares the payload of the frame - */ -HDC1080 hdc1080; -static void PrepareTxFrame( uint8_t port ) -{ - pinMode(Vext,OUTPUT); - digitalWrite(Vext,LOW); - hdc1080.begin(0x40); - float Temperature = (float)(hdc1080.readTemperature()); - float Humidity = (float)(hdc1080.readHumidity()); - hdc1080.end(); - digitalWrite(Vext,HIGH); - uint16_t BatteryVoltage = GetBatteryVoltage(); - unsigned char *puc; - - puc = (unsigned char *)(&Temperature); - AppDataSize = 10;//AppDataSize max value is 64 - AppData[0] = puc[0]; - AppData[1] = puc[1]; - AppData[2] = puc[2]; - AppData[3] = puc[3]; - - puc = (unsigned char *)(&Humidity); - AppData[4] = puc[0]; - AppData[5] = puc[1]; - AppData[6] = puc[2]; - AppData[7] = puc[3]; - - AppData[8] = (uint8_t)(BatteryVoltage>>8); - AppData[9] = (uint8_t)BatteryVoltage; - - Serial.print("T="); - Serial.print(Temperature); - Serial.print("C, RH="); - Serial.print(Humidity); - Serial.print("%,"); - Serial.print("BatteryVoltage:"); - Serial.println(BatteryVoltage); -} - - -void setup() { - BoardInitMcu(); - Serial.begin(115200); -#if(AT_SUPPORT) - Enable_AT(); -#endif - DeviceState = DEVICE_STATE_INIT; - LoRaWAN.Ifskipjoin(); -} - -void loop() -{ - switch( DeviceState ) - { - case DEVICE_STATE_INIT: - { -#if(AT_SUPPORT) - getDevParam(); -#endif - printDevParam(); - Serial.printf("LoRaWan Class%X start! \r\n",CLASS+10); - LoRaWAN.Init(CLASS,REGION); - DeviceState = DEVICE_STATE_JOIN; - break; - } - case DEVICE_STATE_JOIN: - { - LoRaWAN.Join(); - break; - } - case DEVICE_STATE_SEND: - { - PrepareTxFrame( AppPort ); - LoRaWAN.Send(); - DeviceState = DEVICE_STATE_CYCLE; - break; - } - case DEVICE_STATE_CYCLE: - { - // Schedule next packet transmission - TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND ); - LoRaWAN.Cycle(TxDutyCycleTime); - DeviceState = DEVICE_STATE_SLEEP; - break; - } - case DEVICE_STATE_SLEEP: - { - LoRaWAN.Sleep(); - break; - } - default: - { - DeviceState = DEVICE_STATE_INIT; - break; - } - } -} diff --git a/libraries/LoRa/src/Commissioning.h b/libraries/LoRa/src/Commissioning.h deleted file mode 100644 index da809170..00000000 --- a/libraries/LoRa/src/Commissioning.h +++ /dev/null @@ -1,81 +0,0 @@ -/*! - * \file Commissioning.h - * - * \brief End device commissioning parameters - * - * \copyright Revised BSD License, see section \ref LICENSE. - * - * \code - * ______ _ - * / _____) _ | | - * ( (____ _____ ____ _| |_ _____ ____| |__ - * \____ \| ___ | (_ _) ___ |/ ___) _ \ - * _____) ) ____| | | || |_| ____( (___| | | | - * (______/|_____)_|_|_| \__)_____)\____)_| |_| - * (C)2013-2017 Semtech - * - * \endcode - * - * \author Miguel Luis ( Semtech ) - * - * \author Gregory Cristian ( Semtech ) - */ -#ifndef __LORA_COMMISSIONING_H__ -#define __LORA_COMMISSIONING_H__ - -#include "LoRaMac.h" - -/*! - * User application data buffer size - */ -#define LORAWAN_APP_DATA_MAX_SIZE 64 //if use AT mode, don't modify this value or may run dead - -/*! - * Indicates if the end-device is to be connected to a private or public network - */ -#define LORAWAN_PUBLIC_NETWORK true - -/*! - * Mote device IEEE EUI (big endian) - * - * \remark In this application the value is automatically generated by calling - * BoardGetUniqueId function - */ -#define LORAWAN_DEVICE_EUI { 0x22, 0x32, 0x33, 0x00, 0x00, 0x88, 0x88, 0x02} - -/*! - * Application IEEE EUI (big endian) - */ -#define LORAWAN_APPLICATION_EUI { 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x04 } - -/*! - * AES encryption/decryption cipher application key - */ -#define LORAWAN_APPLICATION_KEY { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x66, 0x01 } - -/*! - * Current network ID - */ -#define LORAWAN_NETWORK_ID ( uint32_t )0 - -/*! - * Device address on the network (big endian) - * - * \remark In this application the value is automatically generated using - * a pseudo random generator seeded with a value derived from - * BoardUniqueId value if LORAWAN_DEVICE_ADDRESS is set to 0 - */ -#define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x007e6ae1 - -/*! - * AES encryption/decryption cipher network session key - */ -#define LORAWAN_NWKSKEY { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 } - -/*! - * AES encryption/decryption cipher application session key - */ -#define LORAWAN_APPSKEY { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 } - - -#endif // __LORA_COMMISSIONING_H__ diff --git a/libraries/LoRa/src/LoRaWan_APP.cpp b/libraries/LoRa/src/LoRaWan_APP.cpp index 6df4d237..fbf333ef 100644 --- a/libraries/LoRa/src/LoRaWan_APP.cpp +++ b/libraries/LoRa/src/LoRaWan_APP.cpp @@ -17,30 +17,21 @@ Adafruit_NeoPixel pixels(1, RGB, NEO_GRB + NEO_KHZ800); */ #define LORAWAN_DEFAULT_DATARATE DR_5 -uint8_t DevEui[] = LORAWAN_DEVICE_EUI; -uint8_t AppEui[] = LORAWAN_APPLICATION_EUI; -uint8_t AppKey[] = LORAWAN_APPLICATION_KEY; - -uint8_t NwkSKey[] = LORAWAN_NWKSKEY; -uint8_t AppSKey[] = LORAWAN_APPSKEY; -uint32_t DevAddr = LORAWAN_DEVICE_ADDRESS; - - /*! * User application data size */ -uint8_t AppDataSize = 4; +uint8_t appDataSize = 4; /*! * User application data */ -uint8_t AppData[LORAWAN_APP_DATA_MAX_SIZE]; +uint8_t appData[LORAWAN_APP_DATA_MAX_SIZE]; /*! * Defines the application data transmission duty cycle */ -uint32_t TxDutyCycleTime ; +uint32_t txDutyCycleTime ; /*! * Timer to handle the application data transmission duty cycle @@ -51,22 +42,21 @@ static TimerEvent_t TxNextPacketTimer; * PassthroughMode mode enable/disable. don't modify it here. * when use PassthroughMode, set it true in app.ino , Reference the example PassthroughMode.ino */ -bool PassthroughMode = false; +bool passthroughMode = false; /*! * when use PassthroughMode, Mode_LoraWan to set use lora or lorawan mode . don't modify it here. * it is used to set mode lora/lorawan in PassthroughMode. */ -bool Mode_LoraWan = true; - +bool modeLoraWan = true; /*! * Indicates if a new packet can be sent */ -static bool NextTx = true; +static bool nextTx = true; -enum eDeviceState_LoraWan DeviceState; +enum eDeviceState_LoraWan deviceState; /*! @@ -79,7 +69,7 @@ bool SendFrame( void ) McpsReq_t mcpsReq; LoRaMacTxInfo_t txInfo; - if( LoRaMacQueryTxPossible( AppDataSize, &txInfo ) != LORAMAC_STATUS_OK ) + if( LoRaMacQueryTxPossible( appDataSize, &txInfo ) != LORAMAC_STATUS_OK ) { // Send empty frame in order to flush MAC commands mcpsReq.Type = MCPS_UNCONFIRMED; @@ -89,23 +79,23 @@ bool SendFrame( void ) } else { - if( IsTxConfirmed == false ) + if( isTxConfirmed == false ) { printf("unconfirmed uplink sending ...\r\n"); mcpsReq.Type = MCPS_UNCONFIRMED; - mcpsReq.Req.Unconfirmed.fPort = AppPort; - mcpsReq.Req.Unconfirmed.fBuffer = AppData; - mcpsReq.Req.Unconfirmed.fBufferSize = AppDataSize; + mcpsReq.Req.Unconfirmed.fPort = appPort; + mcpsReq.Req.Unconfirmed.fBuffer = appData; + mcpsReq.Req.Unconfirmed.fBufferSize = appDataSize; mcpsReq.Req.Unconfirmed.Datarate = LORAWAN_DEFAULT_DATARATE; } else { printf("confirmed uplink sending ...\r\n"); mcpsReq.Type = MCPS_CONFIRMED; - mcpsReq.Req.Confirmed.fPort = AppPort; - mcpsReq.Req.Confirmed.fBuffer = AppData; - mcpsReq.Req.Confirmed.fBufferSize = AppDataSize; - mcpsReq.Req.Confirmed.NbTrials = ConfirmedNbTrials; + mcpsReq.Req.Confirmed.fPort = appPort; + mcpsReq.Req.Confirmed.fBuffer = appData; + mcpsReq.Req.Confirmed.fBufferSize = appDataSize; + mcpsReq.Req.Confirmed.NbTrials = confirmedNbTrials; mcpsReq.Req.Confirmed.Datarate = LORAWAN_DEFAULT_DATARATE; } } @@ -133,25 +123,26 @@ static void OnTxNextPacketTimerEvent( void ) { if( mibReq.Param.IsNetworkJoined == true ) { - DeviceState = DEVICE_STATE_SEND; - NextTx = true; + deviceState = DEVICE_STATE_SEND; + nextTx = true; } else { // Network not joined yet. Try to join again MlmeReq_t mlmeReq; mlmeReq.Type = MLME_JOIN; - mlmeReq.Req.Join.DevEui = DevEui; - mlmeReq.Req.Join.AppEui = AppEui; - mlmeReq.Req.Join.AppKey = AppKey; + mlmeReq.Req.Join.DevEui = devEui; + mlmeReq.Req.Join.AppEui = appEui; + mlmeReq.Req.Join.AppKey = appKey; + mlmeReq.Req.Join.NbTrials = 1; if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK ) { - DeviceState = DEVICE_STATE_SLEEP; + deviceState = DEVICE_STATE_SLEEP; } else { - DeviceState = DEVICE_STATE_CYCLE; + deviceState = DEVICE_STATE_CYCLE; } } } @@ -191,11 +182,11 @@ static void McpsConfirm( McpsConfirm_t *mcpsConfirm ) break; } } - NextTx = true; + nextTx = true; } #if(LoraWan_RGB==1) -void RGB_ON(uint32_t color,uint32_t time) +void turnOnRGB(uint32_t color,uint32_t time) { uint8_t red,green,blue; red=(uint8_t)(color>>16); @@ -214,15 +205,15 @@ void RGB_ON(uint32_t color,uint32_t time) } } -void RGB_OFF(void) +void turnOffRGB(void) { - RGB_ON(0,0); + turnOnRGB(0,0); digitalWrite(Vext,HIGH); } #endif /* get the BatteryVoltage in mV. */ -uint16_t GetBatteryVoltage(void) +uint16_t getBatteryVoltage(void) { pinMode(ADC_CTL,OUTPUT); digitalWrite(ADC_CTL,LOW); @@ -232,7 +223,7 @@ uint16_t GetBatteryVoltage(void) } -void __attribute__((weak)) DownLinkDataHandle(McpsIndication_t *mcpsIndication) +void __attribute__((weak)) downLinkDataHandle(McpsIndication_t *mcpsIndication) { printf("+REV DATA:%s,RXSIZE %d,PORT %d\r\n",mcpsIndication->RxSlot?"RXWIN2":"RXWIN1",mcpsIndication->BufferSize,mcpsIndication->Port); printf("+REV DATA:"); @@ -260,8 +251,8 @@ static void McpsIndication( McpsIndication_t *mcpsIndication ) printf( "receive data: rssi = %d, snr = %d, datarate = %d\r\n", mcpsIndication->Rssi, (int)mcpsIndication->Snr,(int)mcpsIndication->RxDatarate); #if (LoraWan_RGB==1) - RGB_ON(COLOR_RECEIVED, 200); - RGB_OFF(); + turnOnRGB(COLOR_RECEIVED, 200); + turnOffRGB(); #endif switch( mcpsIndication->McpsIndication ) @@ -303,7 +294,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication ) // Check RxSlot if( mcpsIndication->RxData == true ) { - DownLinkDataHandle(mcpsIndication); + downLinkDataHandle(mcpsIndication); } } @@ -323,22 +314,22 @@ static void MlmeConfirm( MlmeConfirm_t *mlmeConfirm ) { #if (LoraWan_RGB==1) - RGB_ON(COLOR_JOINED,500); - RGB_OFF(); + turnOnRGB(COLOR_JOINED,500); + turnOffRGB(); #endif printf("joined\r\n"); //in PassthroughMode,do nothing while joined - if(PassthroughMode == false) + if(passthroughMode == false) { // Status is OK, node has joined the network - DeviceState = DEVICE_STATE_SEND; + deviceState = DEVICE_STATE_SEND; } } else { uint32_t rejoin_delay = 30000; - printf("join failed\r\n"); + printf("join failed, join again at 30s later\r\n"); TimerSetValue( &TxNextPacketTimer, rejoin_delay ); TimerStart( &TxNextPacketTimer ); } @@ -356,7 +347,7 @@ static void MlmeConfirm( MlmeConfirm_t *mlmeConfirm ) default: break; } - NextTx = true; + nextTx = true; } /*! @@ -419,15 +410,50 @@ static void lwan_dev_params_update( void ) uint8_t BoardGetBatteryLevel() { - int8 batlevel = ((GetBatteryVoltage()-3.7)/(4.2-3.7))*100; + int8 batlevel = ((getBatteryVoltage()-3.7)/(4.2-3.7))*100; return batlevel; } LoRaMacPrimitives_t LoRaMacPrimitive; LoRaMacCallback_t LoRaMacCallback; -void LoRaWanClass::Init(DeviceClass_t CLASS,LoRaMacRegion_t REGION) +void LoRaWanClass::init(DeviceClass_t lorawanClass,LoRaMacRegion_t region) { + Serial.print("\r\nLoRaWAN "); + switch(region) + { + case LORAMAC_REGION_AS923: + Serial.print("AS923"); + break; + case LORAMAC_REGION_AU915: + Serial.print("AU915"); + break; + case LORAMAC_REGION_CN470: + Serial.print("CN470"); + break; + case LORAMAC_REGION_CN779: + Serial.print("CN779"); + break; + case LORAMAC_REGION_EU433: + Serial.print("EU433"); + break; + case LORAMAC_REGION_EU868: + Serial.print("EU868"); + break; + case LORAMAC_REGION_KR920: + Serial.print("KR920"); + break; + case LORAMAC_REGION_IN865: + Serial.print("IN865"); + break; + case LORAMAC_REGION_US915: + Serial.print("US915"); + break; + case LORAMAC_REGION_US915_HYBRID: + Serial.print("US915_HYBRID "); + break; + } + Serial.printf(" Class %X start!\r\n\r\n",loraWanClass+10); MibRequestConfirm_t mibReq; @@ -437,46 +463,45 @@ void LoRaWanClass::Init(DeviceClass_t CLASS,LoRaMacRegion_t REGION) LoRaMacPrimitive.MacMlmeIndication = MlmeIndication; LoRaMacCallback.GetBatteryLevel = BoardGetBatteryLevel; LoRaMacCallback.GetTemperatureLevel = NULL; - LoRaMacInitialization( &LoRaMacPrimitive, &LoRaMacCallback,REGION); + LoRaMacInitialization( &LoRaMacPrimitive, &LoRaMacCallback,region); TimerStop( &TxNextPacketTimer ); TimerInit( &TxNextPacketTimer, OnTxNextPacketTimerEvent ); mibReq.Type = MIB_ADR; - mibReq.Param.AdrEnable = LORAWAN_ADR_ON; + mibReq.Param.AdrEnable = loraWanAdr; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_PUBLIC_NETWORK; mibReq.Param.EnablePublicNetwork = LORAWAN_PUBLIC_NETWORK; LoRaMacMibSetRequestConfirm( &mibReq ); - lwan_dev_params_update(); - DeviceState = DEVICE_STATE_JOIN; + deviceState = DEVICE_STATE_JOIN; } -extern "C" void GetNetInfo(void); - -void LoRaWanClass::Join() +void LoRaWanClass::join() { - if( OVER_THE_AIR_ACTIVATION ) + if( overTheAirActivation ) { - Serial.println("joining..."); + Serial.print("joining..."); MlmeReq_t mlmeReq; mlmeReq.Type = MLME_JOIN; - mlmeReq.Req.Join.DevEui = DevEui; - mlmeReq.Req.Join.AppEui = AppEui; - mlmeReq.Req.Join.AppKey = AppKey; + mlmeReq.Req.Join.DevEui = devEui; + mlmeReq.Req.Join.AppEui = appEui; + mlmeReq.Req.Join.AppKey = appKey; + mlmeReq.Req.Join.NbTrials = 1; + if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK ) { - DeviceState = DEVICE_STATE_SLEEP; + deviceState = DEVICE_STATE_SLEEP; } else { - DeviceState = DEVICE_STATE_CYCLE; + deviceState = DEVICE_STATE_CYCLE; } } else @@ -488,74 +513,62 @@ void LoRaWanClass::Join() LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_DEV_ADDR; - mibReq.Param.DevAddr = DevAddr; + mibReq.Param.DevAddr = devAddr; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_NWK_SKEY; - mibReq.Param.NwkSKey = NwkSKey; + mibReq.Param.NwkSKey = nwkSKey; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_APP_SKEY; - mibReq.Param.AppSKey = AppSKey; + mibReq.Param.AppSKey = appSKey; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_NETWORK_JOINED; mibReq.Param.IsNetworkJoined = true; LoRaMacMibSetRequestConfirm( &mibReq ); - DeviceState = DEVICE_STATE_SEND; + deviceState = DEVICE_STATE_SEND; } } -void LoRaWanClass::Send() +void LoRaWanClass::send() { - if( NextTx == true ) + if( nextTx == true ) { MibRequestConfirm_t mibReq; mibReq.Type = MIB_DEVICE_CLASS; LoRaMacMibGetRequestConfirm( &mibReq ); - - if(CLASS == CLASS_C) - { - if( mibReq.Param.Class!= CLASS_C ) - { - mibReq.Param.Class = CLASS_C; - LoRaMacMibSetRequestConfirm( &mibReq ); - } - } - if(CLASS == CLASS_A) + if(loraWanClass != mibReq.Param.Class) { - if( mibReq.Param.Class!= CLASS_A ) - { - mibReq.Param.Class = CLASS_A; - LoRaMacMibSetRequestConfirm( &mibReq ); - } + mibReq.Param.Class = loraWanClass; + LoRaMacMibSetRequestConfirm( &mibReq ); } - NextTx = SendFrame( ); + nextTx = SendFrame( ); } } -void LoRaWanClass::Cycle(uint32_t dutycycle) +void LoRaWanClass::cycle(uint32_t dutyCycle) { - TimerSetValue( &TxNextPacketTimer, dutycycle ); + TimerSetValue( &TxNextPacketTimer, dutyCycle ); TimerStart( &TxNextPacketTimer ); } -void LoRaWanClass::Sleep() +void LoRaWanClass::sleep() { - LowPower_Handler( ); + lowPowerHandler( ); // Process Radio IRQ Radio.IrqProcess( ); } -void LoRaWanClass::Ifskipjoin() +void LoRaWanClass::ifskipjoin() { //if saved net info is OK in lorawan mode, skip join. - if(CheckNetInfo()&&Mode_LoraWan){ + if(checkNetInfo()&&modeLoraWan){ Serial.println(); - if(PassthroughMode==false) + if(passthroughMode==false) { Serial.println("Wait 3s for user key to rejoin network"); uint16_t i=0; @@ -564,7 +577,7 @@ void LoRaWanClass::Ifskipjoin() { if(digitalRead(GPIO7)==LOW)//if user key down, rejoin network; { - NetInfoDisable(); + netInfoDisable(); pinMode(GPIO7,OUTPUT); digitalWrite(GPIO7,HIGH); return; @@ -579,23 +592,23 @@ void LoRaWanClass::Ifskipjoin() getDevParam(); #endif - Init(CLASS,REGION); - GetNetInfo(); - if(PassthroughMode==false){ + init(loraWanClass,loraWanRegion); + getNetInfo(); + if(passthroughMode==false){ Serial.println("User key not detected,Use reserved Net"); } else{ Serial.println("Use reserved Net"); } - if(PassthroughMode==false) + if(passthroughMode==false) { - int32_t temp=randr(0,APP_TX_DUTYCYCLE); + int32_t temp=randr(0,appTxDutyCycle); Serial.println(); Serial.printf("Next packet send %d ms later(random time from 0 to APP_TX_DUTYCYCLE)\r\n",temp); Serial.println(); - Cycle(temp);//send packet in a random time to avoid network congestion. + cycle(temp);//send packet in a random time to avoid network congestion. } - DeviceState = DEVICE_STATE_SLEEP; + deviceState = DEVICE_STATE_SLEEP; } } diff --git a/libraries/LoRa/src/LoRaWan_APP.h b/libraries/LoRa/src/LoRaWan_APP.h index e6a6930d..912a9e07 100644 --- a/libraries/LoRa/src/LoRaWan_APP.h +++ b/libraries/LoRa/src/LoRaWan_APP.h @@ -20,48 +20,52 @@ #include "AT_Command.h" #include - -extern uint8_t AppData[LORAWAN_APP_DATA_MAX_SIZE]; -extern uint8_t AppDataSize; -extern uint8_t AppPort; -extern uint32_t TxDutyCycleTime; -extern bool OVER_THE_AIR_ACTIVATION; -extern LoRaMacRegion_t REGION; -extern bool LORAWAN_ADR_ON; -extern bool IsTxConfirmed; -extern uint32_t APP_TX_DUTYCYCLE; -extern DeviceClass_t CLASS; -extern uint8_t AppPort; -extern bool PassthroughMode; -extern uint8_t ConfirmedNbTrials; -extern bool Mode_LoraWan; -extern bool KeepNet; - +extern uint8_t devEui[]; +extern uint8_t appEui[]; +extern uint8_t appKey[]; +extern uint8_t nwkSKey[]; +extern uint8_t appSKey[]; +extern uint32_t devAddr; +extern uint8_t appData[LORAWAN_APP_DATA_MAX_SIZE]; +extern uint8_t appDataSize; +extern uint8_t appPort; +extern uint32_t txDutyCycleTime; +extern bool overTheAirActivation; +extern LoRaMacRegion_t loraWanRegion; +extern bool loraWanAdr; +extern bool isTxConfirmed; +extern uint32_t appTxDutyCycle; +extern DeviceClass_t loraWanClass; +extern bool passthroughMode; +extern uint8_t confirmedNbTrials; +extern bool modeLoraWan; +extern bool keepNet; +extern bool IsLoRaMacNetworkJoined; /*! * Defines a random delay for application data transmission duty cycle. 1s, * value in [ms]. */ #define APP_TX_DUTYCYCLE_RND 1000 -extern enum eDeviceState_LoraWan DeviceState; +extern enum eDeviceState_LoraWan deviceState; class LoRaWanClass{ public: - void Init(DeviceClass_t CLASS,LoRaMacRegion_t REGION); - void Join(); - void Send(); - void Cycle(uint32_t dutycycle); - void Sleep(); - void Ifskipjoin(); + void init(DeviceClass_t lorawanClass,LoRaMacRegion_t region); + void join(); + void send(); + void cycle(uint32_t dutyCycle); + void sleep(); + void ifskipjoin(); }; extern "C" bool SendFrame( void ); -extern "C" void RGB_ON(uint32_t color,uint32_t time); -extern "C" void RGB_OFF(void); -extern "C" uint16_t GetBatteryVoltage(void); -extern "C" bool AT_user_check(char * cmd, char * content); -extern "C" void DownLinkDataHandle(McpsIndication_t *mcpsIndication); +extern "C" void turnOnRGB(uint32_t color,uint32_t time); +extern "C" void turnOffRGB(void); +extern "C" uint16_t getBatteryVoltage(void); +extern "C" bool checkUserAt(char * cmd, char * content); +extern "C" void downLinkDataHandle(McpsIndication_t *mcpsIndication); diff --git a/libraries/LoRa/src/LoRa_APP.cpp b/libraries/LoRa/src/LoRa_APP.cpp index 197c4e91..2675a7df 100644 --- a/libraries/LoRa/src/LoRa_APP.cpp +++ b/libraries/LoRa/src/LoRa_APP.cpp @@ -1,9 +1,9 @@ #include -enum eDeviceState_Lora DeviceState_lora; -extern uint8_t AppData[LORAWAN_APP_DATA_MAX_SIZE]; -extern uint8_t AppDataSize; +enum eDeviceState_Lora deviceState_lora; +extern uint8_t appData[LORAWAN_APP_DATA_MAX_SIZE]; +extern uint8_t appDataSize; //Tx Power uint8_t Lora_TXPW = 10; @@ -66,7 +66,7 @@ static void OnLoraRxTimeout( void ) } -void LoRaClass::Init(uint32_t freq, uint8_t power,uint32_t datarate) +void LoRaClass::init(uint32_t freq, uint8_t power,uint32_t datarate) { LoraEvents.TxDone = OnLoraTxDone; LoraEvents.TxTimeout = OnLoraTxTimeout; @@ -78,19 +78,19 @@ void LoRaClass::Init(uint32_t freq, uint8_t power,uint32_t datarate) Radio.SetRxConfig( MODEM_LORA, 0, datarate,1, 0, 8,0, false,0, true, 0, 0, false, true ); } -void LoRaClass::Send() +void LoRaClass::send() { - Radio.Send( AppData, AppDataSize ); + Radio.Send( appData, appDataSize ); } -void LoRaClass::Receive() +void LoRaClass::receive() { Radio.Rx(LoraRxTimeout); } -void LoRaClass::LOWPOWER() +void LoRaClass::lowpower() { - LowPower_Handler( ); + lowPowerHandler( ); // Process Radio IRQ Radio.IrqProcess( ); } diff --git a/libraries/LoRa/src/LoRa_APP.h b/libraries/LoRa/src/LoRa_APP.h index c06d112f..dd586cc5 100644 --- a/libraries/LoRa/src/LoRa_APP.h +++ b/libraries/LoRa/src/LoRa_APP.h @@ -19,7 +19,7 @@ #include "AT_Command.h" #include "Arduino.h" -extern enum eDeviceState_Lora DeviceState_lora; +extern enum eDeviceState_Lora deviceState_lora; extern uint8_t Lora_TXPW; extern uint32_t Lora_SF; extern uint32_t Lora_FREQ; @@ -28,10 +28,10 @@ extern bool PrintMode; class LoRaClass{ public: - void Init(uint32_t freq, uint8_t power,uint32_t datarate); - void Send(); - void Receive(); - void LOWPOWER(); + void init(uint32_t freq, uint8_t power,uint32_t datarate); + void send(); + void receive(); + void lowpower(); }; extern LoRaClass LoRa; diff --git a/libraries/SSD1306/examples/SSD1306DrawingDemo_I2C/SSD1306DrawingDemo_I2C.ino b/libraries/SSD1306/examples/SSD1306DrawingDemo_I2C/SSD1306DrawingDemo_I2C.ino index 37227dc9..f0d37a3f 100644 --- a/libraries/SSD1306/examples/SSD1306DrawingDemo_I2C/SSD1306DrawingDemo_I2C.ino +++ b/libraries/SSD1306/examples/SSD1306DrawingDemo_I2C/SSD1306DrawingDemo_I2C.ino @@ -1,5 +1,5 @@ #include -#include "SSD1306Wire.h" +#include "cubecell_SSD1306Wire.h" SSD1306Wire display(0x3c, SDA, SCL); @@ -183,4 +183,4 @@ void setup() { display.clear(); } -void loop() { } \ No newline at end of file +void loop() { } diff --git a/libraries/SSD1306/examples/SSD1306DrawingDemo_SPI/SSD1306DrawingDemo_SPI.ino b/libraries/SSD1306/examples/SSD1306DrawingDemo_SPI/SSD1306DrawingDemo_SPI.ino index 45968095..3e420ea3 100644 --- a/libraries/SSD1306/examples/SSD1306DrawingDemo_SPI/SSD1306DrawingDemo_SPI.ino +++ b/libraries/SSD1306/examples/SSD1306DrawingDemo_SPI/SSD1306DrawingDemo_SPI.ino @@ -1,4 +1,4 @@ -#include "SSD1306Spi.h" +#include "cubecell_SSD1306Spi.h" SSD1306Spi display(GPIO1, GPIO2, GPIO3);//RST,DC,CS @@ -183,4 +183,4 @@ void setup() { display.clear(); } -void loop() { } \ No newline at end of file +void loop() { } diff --git a/libraries/SSD1306/examples/SSD1306SimpleDemo_I2C/SSD1306SimpleDemo_I2C.ino b/libraries/SSD1306/examples/SSD1306SimpleDemo_I2C/SSD1306SimpleDemo_I2C.ino index 736f1c9d..e701db8c 100644 --- a/libraries/SSD1306/examples/SSD1306SimpleDemo_I2C/SSD1306SimpleDemo_I2C.ino +++ b/libraries/SSD1306/examples/SSD1306SimpleDemo_I2C/SSD1306SimpleDemo_I2C.ino @@ -1,6 +1,6 @@ // For a connection via I2C using the Arduino Wire include: #include -#include "SSD1306Wire.h" +#include "cubecell_SSD1306Wire.h" #include "images.h" SSD1306Wire display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL diff --git a/libraries/SSD1306/examples/SSD1306SimpleDemo_SPI/SSD1306SimpleDemo_SPI.ino b/libraries/SSD1306/examples/SSD1306SimpleDemo_SPI/SSD1306SimpleDemo_SPI.ino index ae2b89ca..43cd257e 100644 --- a/libraries/SSD1306/examples/SSD1306SimpleDemo_SPI/SSD1306SimpleDemo_SPI.ino +++ b/libraries/SSD1306/examples/SSD1306SimpleDemo_SPI/SSD1306SimpleDemo_SPI.ino @@ -1,4 +1,4 @@ -#include "SSD1306Spi.h" +#include "cubecell_SSD1306Spi.h" #include "images.h" diff --git a/libraries/SSD1306/examples/SSD1306UiDemo/SSD1306UiDemo.ino b/libraries/SSD1306/examples/SSD1306UiDemo/SSD1306UiDemo.ino index e4302e19..87400df7 100644 --- a/libraries/SSD1306/examples/SSD1306UiDemo/SSD1306UiDemo.ino +++ b/libraries/SSD1306/examples/SSD1306UiDemo/SSD1306UiDemo.ino @@ -1,10 +1,10 @@ -#include "SSD1306Spi.h" -#include "OLEDDisplayUi.h" +#include "cubecell_SSD1306Spi.h" +#include "cubecell_OLEDDisplayUi.h" #include "images.h" SSD1306Spi display(GPIO1, GPIO2, GPIO3);//RST,DC,CS -OLEDDisplayUi ui ( &display ); +OLEDDisplayUi ui( &display ); void msOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) { display->setTextAlignment(TEXT_ALIGN_RIGHT); diff --git a/libraries/SSD1306/examples/SSD1306UiDemo_I2C/SSD1306UiDemo_I2C.ino b/libraries/SSD1306/examples/SSD1306UiDemo_I2C/SSD1306UiDemo_I2C.ino index 59903ac4..8cf7c667 100644 --- a/libraries/SSD1306/examples/SSD1306UiDemo_I2C/SSD1306UiDemo_I2C.ino +++ b/libraries/SSD1306/examples/SSD1306UiDemo_I2C/SSD1306UiDemo_I2C.ino @@ -1,6 +1,6 @@ - #include - #include "SSD1306Wire.h" // legacy include: `#include "SSD1306.h"` -#include "OLEDDisplayUi.h" +#include +#include "cubecell_SSD1306Wire.h" // legacy include: `#include "SSD1306.h"` +#include "cubecell_OLEDDisplayUi.h" #include "images.h" @@ -8,7 +8,7 @@ SSD1306Wire display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL -OLEDDisplayUi ui ( &display ); +OLEDDisplayUi ui( &display ); void msOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) { display->setTextAlignment(TEXT_ALIGN_RIGHT); @@ -141,4 +141,4 @@ void loop() { // time budget. delay(remainingTimeBudget); } -} \ No newline at end of file +} diff --git a/libraries/SSD1306/examples/SSD1306UiDemo_SPI/SSD1306UiDemo_SPI.ino b/libraries/SSD1306/examples/SSD1306UiDemo_SPI/SSD1306UiDemo_SPI.ino index 982ee1b1..dd528845 100644 --- a/libraries/SSD1306/examples/SSD1306UiDemo_SPI/SSD1306UiDemo_SPI.ino +++ b/libraries/SSD1306/examples/SSD1306UiDemo_SPI/SSD1306UiDemo_SPI.ino @@ -1,10 +1,10 @@ -#include "SSD1306Spi.h" -#include "OLEDDisplayUi.h" +#include "cubecell_SSD1306Spi.h" +#include "cubecell_OLEDDisplayUi.h" #include "images.h" SSD1306Spi display(GPIO1, GPIO2, GPIO3);//RST,DC,CS -OLEDDisplayUi ui ( &display ); +OLEDDisplayUi ui( &display ); void msOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) { display->setTextAlignment(TEXT_ALIGN_RIGHT); diff --git a/libraries/SSD1306/src/OLEDDisplay.cpp b/libraries/SSD1306/src/cubecell_OLEDDisplay.cpp similarity index 99% rename from libraries/SSD1306/src/OLEDDisplay.cpp rename to libraries/SSD1306/src/cubecell_OLEDDisplay.cpp index 78d43cee..cbe25a62 100644 --- a/libraries/SSD1306/src/OLEDDisplay.cpp +++ b/libraries/SSD1306/src/cubecell_OLEDDisplay.cpp @@ -1,4 +1,4 @@ -#include "OLEDDisplay.h" +#include OLEDDisplay::OLEDDisplay() { diff --git a/libraries/SSD1306/src/OLEDDisplay.h b/libraries/SSD1306/src/cubecell_OLEDDisplay.h similarity index 99% rename from libraries/SSD1306/src/OLEDDisplay.h rename to libraries/SSD1306/src/cubecell_OLEDDisplay.h index f88f4900..27979c10 100644 --- a/libraries/SSD1306/src/OLEDDisplay.h +++ b/libraries/SSD1306/src/cubecell_OLEDDisplay.h @@ -3,7 +3,7 @@ #include -#include "OLEDDisplayFonts.h" +#include //#define DEBUG_OLEDDISPLAY(...) Serial.printf( __VA_ARGS__ ) //#define DEBUG_OLEDDISPLAY(...) dprintf("%s", __VA_ARGS__ ) diff --git a/libraries/SSD1306/src/OLEDDisplayFonts.h b/libraries/SSD1306/src/cubecell_OLEDDisplayFonts.h similarity index 100% rename from libraries/SSD1306/src/OLEDDisplayFonts.h rename to libraries/SSD1306/src/cubecell_OLEDDisplayFonts.h diff --git a/libraries/SSD1306/src/OLEDDisplayUi.cpp b/libraries/SSD1306/src/cubecell_OLEDDisplayUi.cpp similarity index 99% rename from libraries/SSD1306/src/OLEDDisplayUi.cpp rename to libraries/SSD1306/src/cubecell_OLEDDisplayUi.cpp index f73ffbea..c25ac3f2 100644 --- a/libraries/SSD1306/src/OLEDDisplayUi.cpp +++ b/libraries/SSD1306/src/cubecell_OLEDDisplayUi.cpp @@ -1,4 +1,4 @@ -#include "OLEDDisplayUi.h" +#include void LoadingDrawDefault(OLEDDisplay *display, LoadingStage* stage, uint8_t progress) { display->setTextAlignment(TEXT_ALIGN_CENTER); diff --git a/libraries/SSD1306/src/OLEDDisplayUi.h b/libraries/SSD1306/src/cubecell_OLEDDisplayUi.h similarity index 99% rename from libraries/SSD1306/src/OLEDDisplayUi.h rename to libraries/SSD1306/src/cubecell_OLEDDisplayUi.h index 53d64532..25399f0a 100644 --- a/libraries/SSD1306/src/OLEDDisplayUi.h +++ b/libraries/SSD1306/src/cubecell_OLEDDisplayUi.h @@ -3,7 +3,7 @@ #include -#include "OLEDDisplay.h" +#include //#define DEBUG_OLEDDISPLAYUI(...) Serial.printf( __VA_ARGS__ ) diff --git a/libraries/SSD1306/src/SSD1306Spi.h b/libraries/SSD1306/src/cubecell_SSD1306Spi.h similarity index 98% rename from libraries/SSD1306/src/SSD1306Spi.h rename to libraries/SSD1306/src/cubecell_SSD1306Spi.h index 68a95efa..8d7648f5 100644 --- a/libraries/SSD1306/src/SSD1306Spi.h +++ b/libraries/SSD1306/src/cubecell_SSD1306Spi.h @@ -1,7 +1,7 @@ #ifndef SSD1306Spi_h #define SSD1306Spi_h -#include "OLEDDisplay.h" +#include #include #if F_CPU == 160000000L diff --git a/libraries/SSD1306/src/SSD1306Wire.h b/libraries/SSD1306/src/cubecell_SSD1306Wire.h similarity index 99% rename from libraries/SSD1306/src/SSD1306Wire.h rename to libraries/SSD1306/src/cubecell_SSD1306Wire.h index 4d855be4..69427332 100644 --- a/libraries/SSD1306/src/SSD1306Wire.h +++ b/libraries/SSD1306/src/cubecell_SSD1306Wire.h @@ -1,7 +1,7 @@ #ifndef SSD1306Wire_h #define SSD1306Wire_h -#include "OLEDDisplay.h" +#include #include