Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cordep eventcbs #12996

Closed
Closed
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
23 changes: 15 additions & 8 deletions sys/net/application_layer/cord/ep/cord_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,14 @@ int cord_ep_register(const sock_udp_ep_t *remote, const char *regif)
if (retval != CORD_EP_OK) {
_rd_loc[0] = '\0';
}
mutex_unlock(&_mutex);

#ifdef MODULE_CORD_EP_STANDALONE
else {
if (retval == CORD_EP_OK) {
cord_ep_standalone_signal(true);
}
#endif

mutex_unlock(&_mutex);
return retval;
}

Expand All @@ -318,12 +319,16 @@ int cord_ep_update(void)
int res = _update_remove(COAP_METHOD_POST, _on_update);
if (res != CORD_EP_OK) {
/* in case we are not able to reach the RD, we drop the association */
#ifdef MODULE_CORD_EP_STANDALONE
cord_ep_standalone_signal(false);
#endif
_rd_loc[0] = '\0';
}
mutex_unlock(&_mutex);

#ifdef MODULE_CORD_EP_STANDALONE
if (res != CORD_EP_OK) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To only signal the standalone module when updating has been failed seems rather unwanted behavior, since you would have to handle the success case yourself. Furthermore triggering an update from the shell does not trigger the callback, which seems inconsistent.

Maybe you could signal the success case too in here and remove triggering the callback on success in the standalone module (see https://github.com/RIOT-OS/RIOT/pull/12996/files#diff-aa4a4d29f6ba7d1ecd4374a7eb15d331R77).

cord_ep_standalone_signal(false);
}
#endif

return res;
}

Expand All @@ -334,14 +339,16 @@ int cord_ep_remove(void)
mutex_unlock(&_mutex);
return CORD_EP_NORD;
}
#ifdef MODULE_CORD_EP_STANDALONE
cord_ep_standalone_signal(false);
#endif
_update_remove(COAP_METHOD_DELETE, _on_remove);
/* we actually do not care about the result, we drop the RD local RD entry
* in any case */
_rd_loc[0] = '\0';
mutex_unlock(&_mutex);

#ifdef MODULE_CORD_EP_STANDALONE
cord_ep_standalone_signal(false);
#endif

return CORD_EP_OK;
}

Expand Down
3 changes: 0 additions & 3 deletions sys/net/application_layer/cord/ep/cord_ep_standalone.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ static void *_reg_runner(void *arg)
_set_timer();
_notify(CORD_EP_UPDATED);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove _notify, since it should be triggered in ep_cord.c

}
else {
_notify(CORD_EP_DEREGISTERED);
}
}
}

Expand Down