I'm trying to send some data to a custom event handler function using app_scheduler. The problem I am having is the data I am sending is not being received.
I expect this is a C syntax issue on my part. Alas my C skills are weak, so any help is much appreciated!
Here are some code snippets to show what I'm doing and the results I am getting:
Defines and event type declaration:
#define SCHED_MAX_EVENT_DATA_SIZE sizeof(app_timer_event_t)
#define SCHED_QUEUE_SIZE 10
typedef struct
{
uint8_t evt_id;
uint8_t value;
} tag_evt_t;
My event handler looks like this:
static void sfst_tag_app_event_handler(void *p_tag_event, uint16_t size)
{
tag_evt_t *tag_evt = (tag_evt_t*)p_tag_event;
RTT_PRINTF("TAG EVT RCV: ID=%x VAL=%x\n", tag_evt->evt_id, tag_evt->value);
}
My code to place the event on the app_handler() queue looks like this:
tag_evt_t *p_tag_evt;
p_tag_evt->evt_id = 0x05;
p_tag_evt->value = 0x22;
RTT_PRINTF("TAG EVT SEND: ID=%x VAL=%x\n", p_tag_evt->evt_id, p_tag_evt->value);
err_code = app_sched_event_put(p_tag_evt, sizeof(tag_evt_t), sfst_tag_app_event_handler);
APP_ERROR_CHECK(err_code);
The output looks like this: