Skip to content

Commit 7f19188

Browse files
committed
Update LA66 v1.2
1.Add AT+RX1WTO, AT+RX2WTO, AT+DECRYPT, AT+DISFCNTCHECK, AT+DISMACANS commands.
1 parent c6eeec7 commit 7f19188

File tree

7 files changed

+377
-72
lines changed

7 files changed

+377
-72
lines changed

Middlewares/LoRa/LoRaMac-node/LoRaMac.c

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae
2727
#include "LoRaMac.h"
2828
#include "region/Region.h"
2929
#include "LoRaMacCrypto.h"
30-
30+
#include "lora_app.h"
3131
#include "LoRaMacTest.h"
3232
#include "log.h"
3333
#include "lora_config.h"
3434
#include "tremo_gpio.h"
35-
3635
#include "tremo_iwdg.h"
3736
bool jr_flag=0;
3837
uint8_t jr_nb=0;
@@ -46,6 +45,8 @@ extern uint8_t symbtime1_value;
4645
extern uint8_t flag1;
4746
extern uint8_t symbtime2_value;
4847
extern uint8_t flag2;
48+
extern bool down_check;
49+
extern bool mac_response_flag;
4950
extern bool debug_flags;
5051
extern bool rejoin_status;
5152
extern bool MAC_COMMAND_ANS_status;
@@ -849,11 +850,28 @@ static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t
849850
// Size of the regular payload is 12. Plus 1 byte MHDR and 4 bytes MIC
850851
applyCFList.Size = size - 17;
851852

852-
RegionApplyCFList( LoRaMacRegion, &applyCFList );
853+
#if defined( REGION_US915 ) || defined( REGION_AU915 ) || defined( REGION_CN470 )
854+
if(customize_set8channel_get()==0)
855+
{
856+
RegionApplyCFList( LoRaMacRegion, &applyCFList );
857+
}
858+
#else
859+
if(customize_freq1_get()==0)
860+
{
861+
RegionApplyCFList( LoRaMacRegion, &applyCFList );
862+
}
863+
#endif
853864

854865
MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_OK;
855866
IsLoRaMacNetworkJoined = true;
856-
LoRaMacParams.ChannelsDatarate = LoRaMacParamsDefaults.ChannelsDatarate;
867+
if(AdrCtrlOn == true)
868+
{
869+
LoRaMacParams.ChannelsDatarate = LoRaMacParamsDefaults.ChannelsDatarate;
870+
}
871+
else
872+
{
873+
LoRaMacParams.ChannelsDatarate = lora_config_tx_datarate_get() ;
874+
}
857875
}
858876
else
859877
{
@@ -943,6 +961,13 @@ static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t
943961
{
944962
isMicOk = true;
945963
}
964+
else
965+
{
966+
if(down_check==1)
967+
{
968+
DownLinkCounter = 0;
969+
}
970+
}
946971
}
947972
else
948973
{
@@ -954,19 +979,28 @@ static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t
954979
isMicOk = true;
955980
downLinkCounter = downLinkCounterTmp;
956981
}
982+
else
983+
{
984+
if(down_check==1)
985+
{
986+
DownLinkCounter = 0;
987+
}
988+
}
957989
}
958990

959-
// Check for a the maximum allowed counter difference
960-
getPhy.Attribute = PHY_MAX_FCNT_GAP;
961-
phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy );
962-
if( sequenceCounterDiff >= phyParam.Value )
963-
{
964-
McpsIndication.Status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS;
965-
McpsIndication.DownLinkCounter = downLinkCounter;
966-
PrepareRxDoneAbort( );
967-
address_flags=1;
968-
return;
969-
}
991+
if(down_check==0)
992+
{
993+
// Check for a the maximum allowed counter difference
994+
getPhy.Attribute = PHY_MAX_FCNT_GAP;
995+
phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy );
996+
if( sequenceCounterDiff >= phyParam.Value )
997+
{
998+
McpsIndication.Status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS;
999+
McpsIndication.DownLinkCounter = downLinkCounter;
1000+
PrepareRxDoneAbort( );
1001+
return;
1002+
}
1003+
}
9701004

9711005
if( isMicOk == true )
9721006
{
@@ -2060,7 +2094,14 @@ static void ProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8_t comm
20602094
chParam.Rx1Frequency = 0;
20612095
chParam.DrRange.Value = payload[macIndex++];
20622096

2063-
status = RegionNewChannelReq( LoRaMacRegion, &newChannelReq );
2097+
if(customize_freq1_get()==0)
2098+
{
2099+
status = RegionNewChannelReq( LoRaMacRegion, &newChannelReq );
2100+
}
2101+
else
2102+
{
2103+
status = 0x03;
2104+
}
20642105

20652106
AddMacCommand( MOTE_MAC_NEW_CHANNEL_ANS, status, 0 );
20662107
}
@@ -2885,7 +2926,16 @@ LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t* txInfo )
28852926
// Verify if the fOpts and the payload fit into the maximum payload
28862927
if( ValidatePayloadLength( size, datarate, fOptLen ) == false )
28872928
{
2929+
if(mac_response_flag==1)
2930+
{
2931+
fOptLen = 0;
2932+
MacCommandsBufferIndex = 0;
2933+
MacCommandsBufferToRepeatIndex = 0;
2934+
}
2935+
else
2936+
{
28882937
return LORAMAC_STATUS_LENGTH_ERROR;
2938+
}
28892939
}
28902940
return LORAMAC_STATUS_OK;
28912941
}

Middlewares/LoRa/LoRaMac-node/LoRaMacCrypto.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae
2626

2727
#include "LoRaMacCrypto.h"
2828

29+
extern uint8_t decrypt_flag;
30+
2931
/*!
3032
* CMAC/AES Message Integrity Code (MIC) Block B0 size
3133
*/
@@ -107,6 +109,15 @@ void LoRaMacComputeMic( const uint8_t *buffer, uint16_t size, const uint8_t *key
107109

108110
void LoRaMacPayloadEncrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *encBuffer )
109111
{
112+
if(decrypt_flag==1)
113+
{
114+
for(uint8_t lens=0;lens<size;lens++)
115+
{
116+
encBuffer[lens]=buffer[lens];
117+
}
118+
}
119+
else
120+
{
110121
uint16_t i;
111122
uint8_t bufferIndex = 0;
112123
uint16_t ctr = 1;
@@ -148,6 +159,7 @@ void LoRaMacPayloadEncrypt( const uint8_t *buffer, uint16_t size, const uint8_t
148159
encBuffer[bufferIndex + i] = buffer[bufferIndex + i] ^ sBlock[i];
149160
}
150161
}
162+
}
151163
}
152164

153165
void LoRaMacPayloadDecrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *decBuffer )

Projects/Applications/DRAGINO-LRWAN-AT/inc/command.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
#define AT_PORT "+PORT"
6262
#define AT_CHS "+CHS"
6363
#define AT_CHE "+CHE"
64+
#define AT_RX1WTO "+RX1WTO"
65+
#define AT_RX2WTO "+RX2WTO"
66+
#define AT_DECRYPT "+DECRYPT"
6467
#define AT_SLEEP "+SLEEP"
6568
#define AT_CFG "+CFG"
6669
#define AT_BAT "+BAT"
@@ -74,6 +77,8 @@
7477
#define AT_SYNCTDC "+SYNCTDC"
7578
#define AT_DDETECT "+DDETECT"
7679
#define AT_SETMAXNBTRANS "+SETMAXNBTRANS"
80+
#define AT_DISFCNTCHECK "+DISFCNTCHECK"
81+
#define AT_DISMACANS "+DISMACANS"
7782
#define AT_DEVICETIMEREQ "+DEVICETIMEREQ"
7883
#define AT_CHSIGNALDETECT "+GETCHANSTAT"
7984

Projects/Applications/DRAGINO-LRWAN-AT/inc/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Maintainer: Miguel Luis, Gregory Cristian and Wael Guibene
6868

6969
/* Includes ------------------------------------------------------------------*/
7070

71-
#define AT_VERSION_STRING "v1.1"
71+
#define AT_VERSION_STRING "v1.2"
7272
#define AT_LoRaWan_VERSION_STRING "DR-LWS-007"
7373

7474
/* Exported types ------------------------------------------------------------*/

0 commit comments

Comments
 (0)