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

Handling of errors in access_model_publish()

Hi,

like described in this post I sometimes get an error = 4 (NO_MEMORY) when calling:

error = access_model_publish(m_clients[0].model_handle, &msg);

How should this be handled? (Ignore, retry with delay, etc)

Is there a way to find out, wether the softdevice is still sending a message and therefore is not ready for the next one?

I'm using the mesh SDK 2.0.1 

Regards

Gerry

Parents Reply Children
  • Hi Hung

    I'm publishing unreliable. the following line causes the assert in core_tx_complete_cb_set() :

    NRF_MESH_ASSERT(m_packet.bearer_bitmap == 0);


    I didn't find a way to debug this any further, since it only happens during havy communication but I placed a Log-message in front of this line to get the actual m_packet.bearer_bitmap. This suddenly returns 1 instead of 0 when this happens. I'm not publishing in an interrupt. 

    What could cause this?

    What is the meaning of bearer_bitmap?

  • HI Seger, 

     

    We found that it's an issue with the interrupt priority. If you configure the mesh with NRF_MESH_IRQ_PRIORITY_LOWEST, you should call your mesh API with that priority to avoid the operation being interrupted by other mesh activity. Another option is to set them down to Thread mode. 

    Here is the quote from one of our colleague: 

    The key points are:

    • in mesh_init(), the code set the mesh IRQ priority in “NRF_MESH_IRQ_PRIORITY_LOWEST”
    • which means the mesh internal scheduling is using “level 7”
    • in mesh SDK, we want all the mesh events are in the same level
    • however, if we call the mesh API in the main-context, the interrupt priority will be in “NRF_MESH_IRQ_PRIORITY_THREAD”
    • the level is “15”
    • the priority level is less critical than the “NRF_MESH_IRQ_PRIORITY_LOWEST”
    • which means, the procedure may be “interrupted by other mesh events”, and ruin the mesh stack status

    To solve this issue:

    1. Please config the mesh IRQ priority in “NRF_MESH_IRQ_PRIORITY_THREAD” instead of “NRF_MESH_IRQ_PRIORITY_LOWEST”
    2. So we can make sure all the mesh events have the same priority, and the nest interrupt between mesh events won’t happen
    3. And please modify the busy loop in the main() like this:

     

     for (;;)
     {
         if(m_relay)
         {
              simple_on_off_control_send_state(&m_control);
              m_relay=false;
         }
         bool done = nrf_mesh_process();
         if(done)
         {
             sd_app_evt_wait();
         }
    }

    You can read more about interrupt priority levels here.
  • Thanks for your answer Hung

    when I change the .core.irq_priority in mesh_init from NRF_MESH_IRQ_PRIORITY_LOWEST  to NRF_MESH_IRQ_PRIORITY_THREAD I get a problem initializing.

    My initialisation:

    initialize();
    execution_start(start);
    init_flash();

    .. flash read/write operation

    init_uart();
    key_update();
    provisioner_setup();

    In init_falsh(), the line:

    ret_code = flash_manager_add(&m_flash_manager, &custom_data_manager_config);

    returns 4 (no memory)

    Also I have problems with the code, that needs to be added to the main() loop. 

    simple_on_off_control_send_state() and m_relay are not defined.
  • Hi Seger, 

     

    I'm not 100% sure why you get no memory. You may need to step into the code and check what throw error 4. 

    When you change the priority to Thread mode, you need to update the main loop, please follow the guide here

  • ok, I did that and found out, that status = NRF_ERROR_NO_MEM happens in m_prepare_for_reserve() on line 145 of packet_buffer.c (SDK 2.0.1) . This line is also hit 2 times before my attempt to add a flash manager. Probably when the stack itself tries to add one.

Related