This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Mesh assert error in m_packet.bearer_bitmap events

Hello,

I'm using mesh 2.0.1 to test message sending between 2 nRF52840 DK boards.

I'm using a task from FreeRTOS kernel to send messages from the node to the provisionner.

I get an assert because of m_packet.bearer_bitmap is set after sending few messages ( 70, 111 or 200...etc). messages are sent each 2 seconds

I have setup the mesh irq priority to NRF_MESH_IRQ_PRIORITY_LOWEST.

I'm using uint32_t access_model_publish(access_model_handle_t handle, const access_message_tx_t * p_message) to send the messages.

The stack shows that the core_tx_packet_alloc() when the assert happens is call from the QDEC_IRQHandler

I tried to check m_packet.bearer_bitmap before sending data but this didn't help ?

 

Is there a solution to avoid this kind of issue ?

Thank you

Parents
  • Hi, 

    We haven't tested Mesh with FreeRTOS so we don't know what could be wrong. 

    But if you use NRF_MESH_IRQ_PRIORITY_LOWEST, you should only call the mesh API from an interrupt handler with NRF_MESH_IRQ_PRIORITY_LOWEST, not from main loop. Please have a look here. This most likely the reason why you receive m_packet.bearer_bitmap issue. 

     

     

     

     

  • Thank you for the feedback. I have already looked in the link you mentioned above and I have few questions:  

    from the link :

    The less time-critical parts should run in the same IRQ priority as the user application's low priority code. This can be any priority lower than the SoftDevice API call priority, but it should be the same as the SoftDevice event IRQ handler.

    SoftDevice event IRQ handler priority is set in 

    sd_nvic_SetPriority(SD_EVT_IRQn, NRF_MESH_IRQ_PRIORITY_LOWEST)

    But I can't find the priority level of the SoftDevice API call ?

    When using the nRF5 SDK, this will normally be NRF_MESH_IRQ_PRIORITY_LOWEST (APP_IRQ_PRIORITY_LOWEST). However, if you use the nRF5 SDK's app_scheduler module to run the application from the main loop, the low priority parts of the mesh stack should also run from the main loop.

    In the light switch example, there is only sd_app_evt_wait() in the main loop which only handle BLE event if my understanding is correct. All the mesh events are handled in the EVENT_IRQHandler() interrupt ?

    If I want to handle all mesh events in the main loop, How can this be achieved ?

    Thank you 

    Chaabane

  • I'm trying to do handle everything thing in the main loop as suggested.

    The APP_SCHED_INIT() function requires the event size and the queue size.

    For the queue size I put 10 as I can see the BEARER_EVENT_FLAG_COUNT is 8.

    For the event size I put sizeof(nrf_mesh_evt_handler_t), not sure if it's enough to cover all the mesh events ?

    Is this correct ?

    Also, I'm having hardfault error in the provisioner and noticed that there is app_mesh_core_event_cb() tha thandle flash  events, should this be handled int the nrf_mesh_process() aswell ?

  • Hi, 

    Please let us know, if you simply use a default example, and use NRF_MESH_IRQ_PRIORITY_THREAD and modify the mainloop as suggested in the guide. Do you have any problem with the example ? 
    I have tried here and has no problem with flash. 

  • Hi Hang,

    I have a custom application that I customized from the light switch example and yes, I use NRF_MESH_IRQ_PRIORITY_THREAD.

    I have merged the provisioner, server and client in the same project and seems that I did something wrong yet it works fine with a timer and in interrupt mode using NRF_MESH_IRQ_PRIORITY_LOWEST.

    I'll try to make the changes in the example directly.

  • Hi hang,

    I modified the provisioner project in mesh v2.0.1 but the I seems that the provisioning is failing each time.

    Below is the modification that I did on the main.c

    #include "app_scheduler.h"
    .
    .
    .
    
    #define SCHED_MAX_EVENT_DATA_SIZE       sizeof(nrf_mesh_evt_handler_t)
    #define SCHED_QUEUE_SIZE                8
    .
    .
    .
    static void mesh_init(void)
    {
        bool device_provisioned;
        mesh_stack_init_params_t init_params =
        {
     
            .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_THREAD,
            .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
            .models.models_init_cb   = models_init_cb,
            .models.config_server_cb = app_config_server_event_cb
        };
        
    .
    .
    .
    int main(void)
    {
        initialize();
    
        execution_start(start);
        APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
    
        while(true)
        {
          app_sched_execute();
          bool done = nrf_mesh_process();
          {
            (void)sd_app_evt_wait();
          }
        }
    }

    And the logs are

    <t: 0>, main.c, 566, ----- BLE Mesh Light Switch Provisioner Demo -----
    <t: 0>, mesh_softdevice_init.c, 112, Initializing SoftDevice...
    <t: 0>, mesh_softdevice_init.c, 77, Enabling BLE...
    <t: 2>, mesh_softdevice_init.c, 88, Ram base: 0x200032C8
    <t: 560>, main.c, 500, Initializing and adding models
    <t: 570>, main.c, 547, Setup defaults: Adding keys, addresses, and bindings
    <t: 720>, provisioner_helper.c, 329, netkey_handle: 0
    <t: 732>, main.c, 594, <start>
    <t: 27205>, main.c, 129, Flash write complete
    <t: 27208>, main.c, 581, Starting application ...
    <t: 27210>, main.c, 583, Provisoned Nodes: 0, Configured Nodes: 0 Next Address: 0x0100
    <t: 27214>, main.c, 584, Dev key : 35A036F769E2896240ED2DFAE216F5A8
    <t: 27217>, main.c, 585, Net key : FC5B3D636BE4A960B567DA161EB85C7C
    <t: 27220>, main.c, 586, App key : 79731ACEAF43B9AC4896DED172E41468
    <t: 27222>, main.c, 587, Press Button 1 to start provisioning and configuration process.
    <t: 459089>, main.c, 460, Button 1 pressed
    <t: 459091>, main.c, 373, Waiting for Client node to be provisioned ...
    <t: 463852>, provisioner_helper.c, 282, Scanning For Unprovisioned Devices
    <t: 466038>, provisioner_helper.c, 144, UUID seen: 0059ABCDEFABCDEFACCDEFABCDEFABCD
    <t: 466041>, provisioner_helper.c, 95, UUID filter matched
    <t: 485700>, provisioner_helper.c, 259, Provisioning link established
    <t: 1457139>, provisioner_helper.c, 254, Static authentication data provided
    <t: 3536410>, provisioner_helper.c, 155, Local provisioning link closed: prov_state: 3 remaining retries: 2
    <t: 3536414>, provisioner_helper.c, 160, Provisioning failed. Retrying...
    <t: 3546240>, provisioner_helper.c, 144, UUID seen: 0059FFFF000000003BB9C2FB51AFB723
    <t: 3605223>, provisioner_helper.c, 144, UUID seen: 0059ABCDEFABCDEFACCDEFABCDEFABCD
    <t: 3605226>, provisioner_helper.c, 95, UUID filter matched
    <t: 3631437>, provisioner_helper.c, 259, Provisioning link established
    <t: 4992820>, provisioner_helper.c, 254, Static authentication data provided
    <t: 7068812>, provisioner_helper.c, 155, Local provisioning link closed: prov_state: 3 remaining retries: 1
    <t: 7068816>, provisioner_helper.c, 160, Provisioning failed. Retrying...
    <t: 7288357>, provisioner_helper.c, 144, UUID seen: 0059FFFF000000003BB9C2FB51AFB723
    <t: 8644957>, provisioner_helper.c, 144, UUID seen: 0059ABCDEFABCDEFACCDEFABCDEFABCD
    <t: 8644960>, provisioner_helper.c, 95, UUID filter matched
    <t: 8674448>, provisioner_helper.c, 259, Provisioning link established
    <t: 9983396>, provisioner_helper.c, 254, Static authentication data provided
    <t: 11000985>, provisioner_helper.c, 155, Local provisioning link closed: prov_state: 3 remaining retries: 0
    <t: 11000989>, provisioner_helper.c, 167, Provisioning Failed. Code: 1, Could not assign node addr: 0x0100
    <t: 11000993>, main.c, 302, Provisioning failed. Press Button 1 to retry.

    Can you please check the modification I did and tell me if I'm missing something ?

    Thank you

    Chaabane

  • Hi Chaabane,

    Sorry for the delayed response. It seems the failure code you are receiving is due to an invalid provisioning PDU (protocol data unit). See nrf_mesh_prov_types.h for more info: NRF_MESH_PROV_FAILURE_CODE_INVALID_PDU.

    What happens if you add the if loop like shown at this link here:

        if (done)
        {
            sd_app_evt_wait();
        }

    Kind Regards,

    Bjørn

Reply Children
No Data
Related