Refactor OTA command handling and adjust sleep duration
Signed-off-by: Niel Nielsen <nieldk@gmail.com>
This commit is contained in:
1 parent
b8d31f0a81
commit
c4d4bdc99e
1 file changed
+4
-5
+4
-5
@@ -2321,11 +2321,10 @@ static int bwm_ota_once(const uint8_t *fw, size_t fwlen) {
|
|||||||
}
|
}
|
||||||
size_t sent = 0;
|
size_t sent = 0;
|
||||||
while (sent < fwlen) {
|
while (sent < fwlen) {
|
||||||
// msleep(10);
|
|
||||||
size_t n = MIN(maxchunk, fwlen - sent);
|
size_t n = MIN(maxchunk, fwlen - sent);
|
||||||
buf[0] = BWM_OTA_ACTION_WRITE;
|
buf[0] = BWM_OTA_ACTION_WRITE;
|
||||||
memcpy(buf + 1, fw + sent, n);
|
memcpy(buf + 1, fw + sent, n);
|
||||||
//clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_PM5_BWM_ESP_OTA, buf, (uint16_t)(n + 1));
|
SendCommandNG(CMD_PM5_BWM_ESP_OTA, buf, (uint16_t)(n + 1));
|
||||||
bool got = WaitForResponseTimeout(CMD_PM5_BWM_ESP_OTA, &resp, 15000);
|
bool got = WaitForResponseTimeout(CMD_PM5_BWM_ESP_OTA, &resp, 15000);
|
||||||
if (!got || resp.status != PM3_SUCCESS) {
|
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;
|
return PM3_EFAILED;
|
||||||
}
|
}
|
||||||
sent += n;
|
sent += n;
|
||||||
print_progress(sent, fwlen, STYLE_MIXED); ///// DEBUG TEST FOR USB timeout
|
print_progress(sent, fwlen, STYLE_MIXED);
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
printf("\n");
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
||||||
// END: finalize + set the new boot partition
|
// 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
|
// (that is what drops the finalize ack over BLE). Just wait for it to come
|
||||||
// back and re-link, then confirm by version.
|
// back and re-link, then confirm by version.
|
||||||
PrintAndLogEx(INFO, "BWM rebooting into the new image (link drops briefly)...");
|
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};
|
char ver_after[64] = {0};
|
||||||
bool have_after = (bwm_get_version(ver_after, sizeof(ver_after)) == PM3_SUCCESS);
|
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).
|
// 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.
|
// 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(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);
|
free(fw);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user