From c4d4bdc99e0f76b4437a4561e2c83582fb2f401a Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Thu, 3 Sep 2026 15:08:06 +0200 Subject: [PATCH] Refactor OTA command handling and adjust sleep duration Signed-off-by: Niel Nielsen --- client/src/cmdhw.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index 089af1f01..f8f0cbf40 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -2321,11 +2321,10 @@ static int bwm_ota_once(const uint8_t *fw, size_t fwlen) { } size_t sent = 0; while (sent < fwlen) { - // msleep(10); size_t n = MIN(maxchunk, fwlen - sent); buf[0] = BWM_OTA_ACTION_WRITE; memcpy(buf + 1, fw + sent, n); - //clearCommandBuffer(); + clearCommandBuffer(); SendCommandNG(CMD_PM5_BWM_ESP_OTA, buf, (uint16_t)(n + 1)); bool got = WaitForResponseTimeout(CMD_PM5_BWM_ESP_OTA, &resp, 15000); if (!got || resp.status != PM3_SUCCESS) { @@ -2339,10 +2338,9 @@ static int bwm_ota_once(const uint8_t *fw, size_t fwlen) { return PM3_EFAILED; } sent += n; - print_progress(sent, fwlen, STYLE_MIXED); ///// DEBUG TEST FOR USB timeout + print_progress(sent, fwlen, STYLE_MIXED); } free(buf); - printf("\n"); PrintAndLogEx(NORMAL, ""); // END: finalize + set the new boot partition @@ -2440,7 +2438,7 @@ static int CmdBWMUpgrade(const char *Cmd) { // (that is what drops the finalize ack over BLE). Just wait for it to come // back and re-link, then confirm by version. PrintAndLogEx(INFO, "BWM rebooting into the new image (link drops briefly)..."); - msleep(10000); // reboot + re-negotiate baud + re-link + msleep(8000); // reboot + re-negotiate baud + re-link char ver_after[64] = {0}; bool have_after = (bwm_get_version(ver_after, sizeof(ver_after)) == PM3_SUCCESS); @@ -2462,6 +2460,7 @@ static int CmdBWMUpgrade(const char *Cmd) { // Could not re-read the version (link dropped on reboot, common over BLE). // All data was uploaded, so treat as done and let the user confirm. PrintAndLogEx(WARNING, "Could not re-read BWM version after reboot (link dropped?)"); + PrintAndLogEx(HINT, "Reconnect and run " _YELLOW_("hw status") " to confirm the version."); free(fw); return PM3_SUCCESS; }