Fork of Semtech LoRaWAN stack

Fork of LoRaWAN-lib by canuck lehead

Branch:
v4.2.0
Revision:
26:4627985dc5be
Parent:
25:8d0a79bd607b
Child:
27:cda377b2a41f
Child:
28:307e6c4831ad
diff -r 8d0a79bd607b -r 4627985dc5be LoRaMac.cpp
--- a/LoRaMac.cpp	Fri Oct 21 18:55:54 2016 +0000
+++ b/LoRaMac.cpp	Wed Nov 09 06:05:41 2016 +0000
@@ -1536,6 +1536,12 @@
                 if( ( AckTimeoutRetriesCounter % 2 ) == 1 )
                 {
                     ChannelsDatarate = MAX( ChannelsDatarate - 1, LORAMAC_TX_MIN_DATARATE );
+                    // Check if new datarate is valid for the Payload length
+					if( ValidatePayloadLength( LoRaMacBufferPktLen - 13, ChannelsDatarate, 0 ) == false )
+					{							
+						// If invalid payload length, then revert to previous datarate
+						ChannelsDatarate++;
+					}
                 }
                 LoRaMacFlags.Bits.MacDone = 0;
                 // Sends the same frame again