How to process received Mesh message with scheduler

Hi, team.

**********
environment :
SDK : Mesh v3.2  (w/ SDK v15.3.0)
SoC : nRF52840
IDE : SES
**********


I am challenging to handle each event, such as Mesh receive interrupt and timer interrupt with the scheduler.
I have confirmed that simple GPIO interrupts and timer interrupts can be handled using the scheduler according to the tutorial.

However, I did not know how to process the received Mesh message using the scheduler, so I asked a question...

For example, in the simple light_switch sample, multiple structures are passed to the application as arguments, as shown below.

static void app_generic_onoff_client_status_cb(const generic_onoff_client_t * p_self,
                                               const access_message_rx_meta_t * p_meta,
                                               const generic_onoff_status_params_t * p_in)
{
    // some process...
}


At this time, for example, how can I push all the structures (pointers) received as arguments to the event queue of the scheduler?

I tried declaring the original structure as shown below and trying to copy the argument pointers,
but the parameters I received  in the scheduled function were not the intended values at all.

typedef struct
{
    const generic_onoff_client_t * pp_self;
    const access_message_rx_meta_t * pp_meta;
    const generic_onoff_status_params_t * pp_in;
} my_event_packet_t;



Copy pointer as shown below.

static void app_generic_onoff_client_status_cb(const generic_onoff_client_t * p_self,
                                               const access_message_rx_meta_t * p_meta,
                                               const generic_onoff_status_params_t * p_in)
{
    my_event_packet_t * packet_datas;
    
    packet_datas->pp_self = p_self;
    packet_datas->pp_meta = p_meta;
    packet_datas->pp_in = p_in;

    app_sched_event_put(&packet_datas, sizeof(* packet_datas), scheduled_status_cb);
}



Scheduled function.

static void scheduled_status_cb(void * p_event, uint16_t event_size)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "%s called.\n", __func__);

    my_event_packet_t * check_struct = (my_event_packet_t *) p_event;

    /*
        Various processing such as log output
    */
}



Perhaps it is related to the fact that the structure being communicated is  a pointer, but no good approach could found so far.

Can you tell me if there is any good approach?
Also, if you have any points to be careful about using the scheduler to perform processing related to Bluetooth (Mesh) communication, please also provide a guide.


I hope you will be able to provide the information.

Best regards,
Wataru

Related