From ffa46b15f33f1a11708c190d2efc0a91e4985191 Mon Sep 17 00:00:00 2001 From: Kimmo Vaisanen Date: Thu, 30 Aug 2018 15:43:54 +0300 Subject: [PATCH] LoRa: Stop processing MAC commands if command id is unknown The length of a MAC command is not explicitly given and must be implicitly known by the MAC implementation. Therefore unknown MAC commands cannot be skipped and the first unknown MAC command terminates the processing of the MAC command sequence. This commit fixes the bug where MAC command processing was not terminated when unknown MAC command was received. --- features/lorawan/lorastack/mac/LoRaMacCommand.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/lorawan/lorastack/mac/LoRaMacCommand.cpp b/features/lorawan/lorastack/mac/LoRaMacCommand.cpp index cde62355b3..2fca7193e2 100644 --- a/features/lorawan/lorastack/mac/LoRaMacCommand.cpp +++ b/features/lorawan/lorastack/mac/LoRaMacCommand.cpp @@ -304,7 +304,8 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui break; default: // Unknown command. ABORT MAC commands processing - ret_value = LORAWAN_STATUS_UNSUPPORTED; + tr_error("Invalid MAC command (0x%X)!", payload[mac_index]); + return LORAWAN_STATUS_UNSUPPORTED; } } return ret_value;