That’s what the builtin mJS API provides.
You can do something more verbose in C:
#include "mgos.h"
#include "mgos_ota.h"
static void ota_status_cb(int ev, void *ev_data, void *userdata) {
const struct mgos_ota_status *status =
(const struct mgos_ota_status *) ev_data;
LOG(LL_INFO, ("is_committed=%d, commit_timeout=%d, partition=%d, msg: "
"\"%s\", progress_percent=%d%",
status->is_committed, status->commit_timeout, status->partition,
status->msg, status->progress_percent));
(void) ev;
(void) userdata;
}
enum mgos_app_init_result mgos_app_init(void) {
mgos_event_add_handler(MGOS_EVENT_OTA_STATUS, ota_status_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}