From f264c7a8f6cbe42ee16d4e553cb4bc0becdc8e3a Mon Sep 17 00:00:00 2001 From: "contact@brokestudio.fr" Date: Mon, 6 Nov 2023 09:50:53 +0100 Subject: [PATCH] rainbow: fixed FILE_SET_CUR command --- src/boards/rainbow_esp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/boards/rainbow_esp.cpp b/src/boards/rainbow_esp.cpp index 58b15df5..c9a560c8 100644 --- a/src/boards/rainbow_esp.cpp +++ b/src/boards/rainbow_esp.cpp @@ -886,14 +886,14 @@ void BrokeStudioFirmware::processBufferedMessage() } case toesp_cmds_t::FILE_SET_CUR: UDBG("[Rainbow] ESP received command FILE_SET_CUR\n"); - if (2 <= message_size && message_size <= 5) + if (message_size >= 2 && message_size <= 5) { if (this->working_file.active) { this->working_file.offset = this->rx_buffer.at(2); - this->working_file.offset += static_cast(message_size >= 3 ? this->rx_buffer.at(3) : 0) << 8; - this->working_file.offset += static_cast(message_size >= 4 ? this->rx_buffer.at(4) : 0) << 16; - this->working_file.offset += static_cast(message_size >= 5 ? this->rx_buffer.at(5) : 0) << 24; + if(message_size == 3) this->working_file.offset += static_cast(message_size >= 3 ? this->rx_buffer.at(3) : 0) << 8; + if(message_size == 4) this->working_file.offset += static_cast(message_size >= 4 ? this->rx_buffer.at(4) : 0) << 16; + if(message_size == 5) this->working_file.offset += static_cast(message_size >= 5 ? this->rx_buffer.at(5) : 0) << 24; } } break;