mirror of
https://dev.iopsys.eu/system/sysmngr.git
synced 2025-12-10 00:06:19 +01:00
Refresh fwbank dump on sysupgrade event
This commit is contained in:
parent
0d0cef8a18
commit
42b1290590
3 changed files with 51 additions and 0 deletions
38
src/fwbank.c
38
src/fwbank.c
|
|
@ -796,3 +796,41 @@ int sysmngr_clean_fwbank_dump(struct ubus_context *ubus_ctx)
|
|||
free_global_fwbank_dump(&g_fwbank_dump.output);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SYSMNGR_FWBANK_UBUS_SUPPORT
|
||||
static void schedule_fwbank_dump_refresh(struct uloop_timeout *timeout);
|
||||
struct uloop_timeout upgrade_event_timer = { .cb = schedule_fwbank_dump_refresh };
|
||||
|
||||
void schedule_fwbank_dump_refresh(struct uloop_timeout *tm __attribute__((unused)))
|
||||
{
|
||||
init_global_fwbank_dump();
|
||||
}
|
||||
|
||||
void sysmngr_process_sysupgrade(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
||||
const char *type, struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *cur = NULL;
|
||||
int rem;
|
||||
|
||||
if (!msg || !ev)
|
||||
return;
|
||||
|
||||
BBFDM_INFO("Received sysupgrade event");
|
||||
blobmsg_for_each_attr(cur, msg, rem) {
|
||||
if (DM_STRCMP("status", blobmsg_name(cur)) == 0) {
|
||||
char *attr_val = (char *)blobmsg_data(cur);
|
||||
|
||||
if (DM_STRCMP(attr_val, "Available") != 0) {
|
||||
BBFDM_DEBUG("Sysupgrade status not Available. Refresh fwbank dump after 10sec.");
|
||||
uloop_timeout_set(&upgrade_event_timer, 10 * 1000);
|
||||
break;
|
||||
} else {
|
||||
init_global_fwbank_dump();
|
||||
uloop_timeout_cancel(&upgrade_event_timer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,4 +26,8 @@ int sysmngr_unregister_fwbank(struct ubus_context *ubus_ctx);
|
|||
int sysmngr_init_fwbank_dump(struct ubus_context *ubus_ctx);
|
||||
int sysmngr_clean_fwbank_dump(struct ubus_context *ubus_ctx);
|
||||
|
||||
#ifdef SYSMNGR_FWBANK_UBUS_SUPPORT
|
||||
void sysmngr_process_sysupgrade(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
||||
const char *type, struct blob_attr *msg);
|
||||
#endif
|
||||
#endif //__FWBANK_H
|
||||
|
|
|
|||
|
|
@ -137,6 +137,15 @@ int main(int argc, char **argv)
|
|||
if (ubus_register_event_handler(bbfdm_ctx.ubus_ctx, &ev, "sysmngr.reload"))
|
||||
goto out;
|
||||
|
||||
#ifdef SYSMNGR_FWBANK_UBUS_SUPPORT
|
||||
struct ubus_event_handler sysupgrade_ev = {
|
||||
.cb = sysmngr_process_sysupgrade,
|
||||
};
|
||||
|
||||
if (ubus_register_event_handler(bbfdm_ctx.ubus_ctx, &sysupgrade_ev, "sysupgrade"))
|
||||
goto out;
|
||||
#endif
|
||||
|
||||
uloop_run();
|
||||
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue