Usage Handler Function Problem


#1

Hy everybody,
I’m having some issue using handler function on legato 16.01.
I want write a simple application that triggers an handler function when the network registration state changes.


static void NetRegStateHandlerFunc(le_mrc_NetRegState_t state, void *contextPtr);

COMPONENT_INIT{
    ... 
    ...
    le_mrc_AddNetRegStateEventHandler((le_mrc_NetRegStateHandlerFunc_t) NetRegStateHandlerFunc, NULL);
   ....
}

static void NetRegStateHandlerFunc(le_mrc_NetRegState_t state, void *contextPtr){
    LE_INFO("INTO HANDLER\n");
}

For some reason even if the registration state changes the handler function is not triggered.
Any hint?
Giorgio


#2

Do you return from your COMPONENT_INIT?

I think that’s the most common cause that I’ve seen for this. People sometimes implement their own while(true) loop or call sleep() in the COMPONENT_INIT, so their Legato event handling loop doesn’t get to run because it runs after all the components’ COMPONENT_INITs return.