Skip to content

Commit

Permalink
interface: add error-recovery for beacon update
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Feb 5, 2024
1 parent 44ec585 commit 44f9e94
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,28 @@ static void gluon_diagnostic_interface_handle_remove(struct ubus_context *ctx,
int gluon_diagnostic_interface_update(struct ubus_context *ctx, char *vendor_elements)
{
struct gluon_diagnostic_interface *iface;

blob_buf_init(&b, 0);
blobmsg_add_string(&b, "vendor_elements", vendor_elements);
int ret;

list_for_each_entry(iface, &gluon_diagnostic_interfaces, list) {
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "vendor_elements", vendor_elements);

log_debug("Sending vendor elements to id=%d name=%s", iface->ubus.id, iface->ubus.name);
ubus_invoke(ctx, iface->ubus.id, "set_vendor_elements", b.head, NULL, NULL, 1000);
ret = ubus_invoke(ctx, iface->ubus.id, "set_vendor_elements", b.head, NULL, NULL, 1000);
if (ret) {
log_error("Failed to send vendor elements to id=%d name=%s code=%d", iface->ubus.id, iface->ubus.name, ret);

/* Delete element */
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "vendor_elements", "");
ret = ubus_invoke(ctx, iface->ubus.id, "set_vendor_elements", b.head, NULL, NULL, 1000);
if (ret) {
log_error("Failed to reset vendor elements for id=%d name=%s code=%d", iface->ubus.id, iface->ubus.name, ret);
}
}
}

return 0;
}

int gluon_diagnostic_interface_remove(struct ubus_context *ctx,
Expand Down

0 comments on commit 44f9e94

Please sign in to comment.