Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/mios/ota.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ struct stream *ota_get_stream(void);
*/
error_t ota_prohibit_upgrade(void);

/*
* Optionally implemented by application to receive OTA progress updates.
* Called once per flash sector (4 kB) during the write phase.
* current_bytes: bytes written so far, total_bytes: total image size.
*/
void ota_progress(uint32_t current_bytes, uint32_t total_bytes);


/*
* Write out a binary stream to spiflash and generate upgrade headers, etc
Expand Down
7 changes: 7 additions & 0 deletions src/net/service/svc_ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include <mios/task.h>
#include <mios/eventlog.h>
#include <mios/block.h>
#include <mios/ota.h>

__attribute__((weak)) void
ota_progress(uint32_t current_bytes, uint32_t total_bytes)
{
}

#include "net/pbuf.h"

Expand Down Expand Up @@ -141,6 +147,7 @@ ota_perform(svc_ota_t *sa)
return err;
}
erased_sector = sector;
ota_progress(current_byte, total_bytes);
}

void *buf = pbuf_data(pb, 0);
Expand Down