summaryrefslogtreecommitdiff
path: root/fw/app
diff options
context:
space:
mode:
Diffstat (limited to 'fw/app')
-rw-r--r--fw/app/src/update.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/fw/app/src/update.c b/fw/app/src/update.c
index 13471d2..9e91380 100644
--- a/fw/app/src/update.c
+++ b/fw/app/src/update.c
@@ -5,9 +5,13 @@
*/
+#include <stdbool.h>
+
+#include <zephyr/dfu/flash_img.h>
#include <zephyr/logging/log.h>
#include <zephyr/net/http/server.h>
#include <zephyr/net/http/service.h>
+#include <zephyr/net/http/status.h>
LOG_MODULE_REGISTER(update);
@@ -19,21 +23,28 @@ static int update_handler(
struct http_response_ctx *response_ctx,
void *user_data
) {
- LOG_DBG("Handling update request");
+ static size_t processed;
+
+ if (status == HTTP_SERVER_DATA_ABORTED) {
+ LOG_WRN("Transaction aborted after %zd bytes.", processed);
+ processed = 0;
+ return 0;
+ }
+
+ processed += request_ctx->data_len;
- response_ctx->body = NULL;
- response_ctx->body_len = 0;
- response_ctx->final_chunk = true;
- response_ctx->status = HTTP_204_NO_CONTENT;
+ if (status == HTTP_SERVER_DATA_FINAL) {
+ LOG_INF("Handled update request receiving %zd octets.", processed);
+ processed = 0;
+ }
- LOG_DBG("Update request handled");
return 0;
}
static struct http_resource_detail_dynamic update_resource_detail = {
.common = {
.type = HTTP_RESOURCE_TYPE_DYNAMIC,
- .bitmask_of_supported_http_methods = BIT(HTTP_GET),
+ .bitmask_of_supported_http_methods = BIT(HTTP_PUT),
},
.cb = update_handler,
.user_data = NULL,