Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_sched_event_put NULL data pointer is not NULL

Hello,

This behavior within the SDK has bitten me a couple times so I thought it would be a good thing to share. If you call app_sched_event_put(NULL, 0, &my_function), when "my_function" is called, the data pointer is not NULL for the size parameter is zero. Therefore the following will not work.

Caller:

Fullscreen
1
2
3
extern void event_handler(void* data, size_t data_len);
app_sched_event_put(NULL, 0, event_handler);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Callee:

Fullscreen
1
2
3
4
5
6
7
void event_handler(void* data, size_t data_len)
{
// This will not work, check data+len instead
if (data == NULL) {
do_something();
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX