fix: Fix-Runde 1 für Task 4 - Reset nur bei akzeptiertem OTA-Image, hängende Downloads/Sessions begrenzen
This commit is contained in:
+7
-3
@@ -336,9 +336,13 @@ static void handle_command(const nl_api_ctx_t *ctx, const nl_http_request_t *req
|
||||
} else if (strcmp(type, "fw_update") == 0) {
|
||||
if (get_string(cmd, "url", 8, 255, &url) != 1 || strncmp(url, "http://", 7) != 0)
|
||||
reply_error(resp, 400, "invalid url");
|
||||
else if (ctx->fw_update(url) != 0)
|
||||
reply_error(resp, 501, "fw_update not available");
|
||||
else
|
||||
else if (ctx->fw_update(url) != 0) {
|
||||
/* fw_update() itself can genuinely fail now (busy, or a rejected URL) - 409 with the
|
||||
* reason, not a blanket "not implemented". */
|
||||
nl_sys_info_t in;
|
||||
ctx->get_info(&in);
|
||||
reply_error(resp, 409, in.last_ota_error ? in.last_ota_error : "fw_update busy or invalid url");
|
||||
} else
|
||||
reply(resp, 202, "{\"status\":\"updating\"}");
|
||||
} else if (strcmp(type, "reboot") == 0) {
|
||||
reply(resp, 200, "{\"ok\":true}");
|
||||
|
||||
Reference in New Issue
Block a user