Skip to content

Commit

Permalink
fixup! swu: dump storage for each notification
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik authored and Danielius1922 committed Jun 22, 2023
1 parent 57fcf51 commit 2ba6e60
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions api/oc_swupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,37 +224,35 @@ swupdate_resource_get(oc_request_t *request, oc_interface_mask_t iface,
oc_send_response_with_callback(request, code, true);
}

static oc_event_callback_retval_t
swupdate_update_async(void *data)
static size_t
swupdate_async_get_device_index(const void *data)
{
oc_swupdate_t *s = (oc_swupdate_t *)data;
size_t device = (size_t)-1;
const oc_swupdate_t *s = (const oc_swupdate_t *)data;
for (size_t i = 0; i < oc_core_get_num_devices(); i++) {
if (s == &g_sw[i]) {
device = i;
break;
return i;
}
}
return (size_t)-1;
}

static oc_event_callback_retval_t
swupdate_update_async(void *data)
{
size_t device = swupdate_async_get_device_index(data);
if (device == (size_t)-1) {
OC_ERR("swupdate: cannot schedule update, device data not found");
return OC_EVENT_DONE;
}
const oc_swupdate_t *s = (const oc_swupdate_t *)data;
oc_swupdate_perform_action(s->swupdateaction, device);
oc_swupdate_dump(device);
return OC_EVENT_DONE;
}

static oc_event_callback_retval_t
swupdate_dump_async(void *data)
{
const oc_swupdate_t *s = (const oc_swupdate_t *)data;
size_t device = (size_t)-1;
for (size_t i = 0; i < oc_core_get_num_devices(); i++) {
if (s == &g_sw[i]) {
device = i;
break;
}
}
size_t device = swupdate_async_get_device_index(data);
if (device == (size_t)-1) {
OC_ERR("swupdate: cannot dump, device data not found");
return OC_EVENT_DONE;
Expand Down

0 comments on commit 2ba6e60

Please sign in to comment.