Skip to content

Commit

Permalink
Release v3.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mluis1 committed Nov 6, 2015
1 parent 1541487 commit 32a9287
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ not of a bootloader and the radio frequency band to be used.

6. Changelog
-------------
2015-10-06, V3.4.1
* General
1. Bug fixes

* LoRaWAN
1. Corrected downlink counter roll over management when several downlinks were missed.
2. Corrected the Radio maximum payload length management. Radio was filtering received frames with a length bigger than the transmitted one.
3. Applied Pull request #22 solution proposition.

2015-10-30, V3.4
* General
1. Changed all applications in order to have preprocessing definitions on top of the files and added relevant comments
Expand Down
67 changes: 50 additions & 17 deletions src/mac/LoRaMac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ static void LoRaMacProcessMacCommands( uint8_t *payload, uint8_t macIndex, uint8
// Data rate ACK = 0
// Channel mask = 0
AddMacCommand( MOTE_MAC_LINK_ADR_ANS, 0, 0 );
macIndex += 3; // Skip over the remaining bytes of the request
macIndex += 3; // Skip over the remaining bytes of the request
break;
}
chMask = ( uint16_t )payload[macIndex++];
Expand Down Expand Up @@ -1936,24 +1936,21 @@ static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t
if( sequenceCounterDiff < ( 1 << 15 ) )
{
downLinkCounter += sequenceCounterDiff;
LoRaMacComputeMic( payload, size - LORAMAC_MFR_LEN, nwkSKey, address, DOWN_LINK, downLinkCounter, &mic );
if( micRx == mic )
{
isMicOk = true;
}
}

// Normal operation
if( isMicOk == false )
else
{
LoRaMacComputeMic( payload, size - LORAMAC_MFR_LEN, nwkSKey, address, DOWN_LINK, downLinkCounter, &mic );
// check for downlink counter roll-over
uint32_t downLinkCounterTmp = downLinkCounter + 0x10000 + ( int16_t )sequenceCounterDiff;
LoRaMacComputeMic( payload, size - LORAMAC_MFR_LEN, nwkSKey, address, DOWN_LINK, downLinkCounterTmp, &mic );
if( micRx == mic )
{
isMicOk = true;
// Update 32 bits downlink counter
if( LoRaMacEventFlags.Bits.Multicast == 1 )
{
curMulticastParams->DownLinkCounter = downLinkCounter;
}
else
{
DownLinkCounter = downLinkCounter;
}
downLinkCounter = downLinkCounterTmp;
}
}

Expand All @@ -1965,6 +1962,16 @@ static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t
LoRaMacEventInfo.RxBufferSize = 0;
AdrAckCounter = 0;

// Update 32 bits downlink counter
if( LoRaMacEventFlags.Bits.Multicast == 1 )
{
curMulticastParams->DownLinkCounter = downLinkCounter;
}
else
{
DownLinkCounter = downLinkCounter;
}

if( macHdr.Bits.MType == FRAME_TYPE_DATA_CONFIRMED_DOWN )
{
SrvAckRequested = true;
Expand Down Expand Up @@ -2117,21 +2124,36 @@ static void OnRadioRxError( void )
*/
void LoRaMacRxWindowSetup( uint32_t freq, int8_t datarate, uint32_t bandwidth, uint16_t timeout, bool rxContinuous )
{
uint8_t downlinkDatarate = Datarates[datarate];
RadioModems_t modem;

if( Radio.GetStatus( ) == RF_IDLE )
{
Radio.SetChannel( freq );
#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
if( datarate == DR_7 )
{
Radio.SetRxConfig( MODEM_FSK, 50e3, Datarates[datarate] * 1e3, 0, 83.333e3, 5, 0, false, 0, true, 0, 0, false, rxContinuous );
modem = MODEM_FSK;
Radio.SetRxConfig( MODEM_FSK, 50e3, downlinkDatarate * 1e3, 0, 83.333e3, 5, 0, false, 0, true, 0, 0, false, rxContinuous );
}
else
{
Radio.SetRxConfig( MODEM_LORA, bandwidth, Datarates[datarate], 1, 0, 8, timeout, false, 0, false, 0, 0, true, rxContinuous );
modem = MODEM_LORA;
Radio.SetRxConfig( MODEM_LORA, bandwidth, downlinkDatarate, 1, 0, 8, timeout, false, 0, false, 0, 0, true, rxContinuous );
}
#elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
Radio.SetRxConfig( MODEM_LORA, bandwidth, Datarates[datarate], 1, 0, 8, timeout, false, 0, false, 0, 0, true, rxContinuous );
modem = MODEM_LORA;
Radio.SetRxConfig( MODEM_LORA, bandwidth, downlinkDatarate, 1, 0, 8, timeout, false, 0, false, 0, 0, true, rxContinuous );
#endif
if( RepeaterSupport == true )
{
Radio.SetMaxPayloadLength( modem, MaxPayloadOfDatarateRepeater[datarate] );
}
else
{
Radio.SetMaxPayloadLength( modem, MaxPayloadOfDatarate[datarate] );
}

if( rxContinuous == false )
{
Radio.Rx( MaxRxWindow );
Expand Down Expand Up @@ -2284,6 +2306,17 @@ static void OnMacStateCheckTimerEvent( void )
}
}
}
else
{
/*
* For confirmed uplinks, ignore MIC and address errors and keep retrying.
*/
if( ( LoRaMacEventInfo.Status == LORAMAC_EVENT_INFO_STATUS_MIC_FAIL ) ||
( LoRaMacEventInfo.Status == LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL ) )
{
AckTimeoutRetry = true;
}
}

if( LoRaMacEventFlags.Bits.Rx == 1 )
{
Expand Down

0 comments on commit 32a9287

Please sign in to comment.