From 41d633bfd84aec023922a7f34611a3715a6dd1cd Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 27 Jun 2024 18:43:08 -0700 Subject: [PATCH] fix the build - would loop forever if there were no files to send (#4188) --- src/mesh/PhoneAPI.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 57a42651a..399715f61 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -354,15 +354,14 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) case STATE_SEND_FILEMANIFEST: { LOG_INFO("getFromRadio=STATE_SEND_FILEMANIFEST\n"); - fromRadioScratch.which_payload_variant = meshtastic_FromRadio_fileInfo_tag; - if (config_state < filesManifest.size()) { + // last element + if (config_state == filesManifest.size()) { // also handles an empty filesManifest + state = STATE_SEND_COMPLETE_ID; + config_state = 0; + } else { + fromRadioScratch.which_payload_variant = meshtastic_FromRadio_fileInfo_tag; fromRadioScratch.fileInfo = filesManifest.at(config_state); config_state++; - // last element - if (config_state == filesManifest.size()) { - state = STATE_SEND_COMPLETE_ID; - config_state = 0; - } } break; }