Merge pull request #10154 from itziardelatorre/itziar

Fix for LoRaWAN downlink sequence counter rollover
pull/9904/head
Cruz Monrreal 2019-03-27 00:22:37 -05:00 committed by GitHub
commit eff15804b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 8 deletions

View File

@ -319,8 +319,11 @@ bool LoRaMac::message_integrity_check(const uint8_t *const payload,
sequence_counter_prev = (uint16_t) * downlink_counter;
sequence_counter_diff = sequence_counter - sequence_counter_prev;
*downlink_counter += sequence_counter_diff;
if (sequence_counter < sequence_counter_prev) {
*downlink_counter += 0x10000;
if (sequence_counter_diff >= _lora_phy->get_maximum_frame_counter_gap()) {
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOST;
_mcps_indication.dl_frame_counter = *downlink_counter;
return false;
}
// sizeof nws_skey must be the same as _params.keys.nwk_skey,
@ -334,12 +337,6 @@ bool LoRaMac::message_integrity_check(const uint8_t *const payload,
return false;
}
if (sequence_counter_diff >= _lora_phy->get_maximum_frame_counter_gap()) {
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOST;
_mcps_indication.dl_frame_counter = *downlink_counter;
return false;
}
return true;
}