Hi
I faced problems when handling messages from the callback function of the mesh (generic_set_cb() in my case)
we are using generic SDK 15.2 and mesh SDK 3.1
Here what I do:
- directly inside the callback function generic_set_cb() I analyze the message and send an answer back to the sender.
Normally this works well.
A problem occurs, when I access the SPI interface from this callback function.
- the callback from the SPI is never being handled if the message comes from the mesh.
- if I do the same thing but triggered from the UART-interface, access to SPI works without any problem.
As I read in other posts, this is a priority problem. => therefore I tried to increase the priority of the SPI => no improvement
Next step:
- in the callback function generic_set_cb() I store the message and set a flag. Then I leave the callback.
- in the main() loop I test this flag
- if set: handle the received message (and reset the flag)
- access SPI
- send an answer back to the sender over the mesh
Result:
- SPI handling works fine
- mesh assert when sending the answer
with the help of the Call Stack I tried to find the root cause of the assert.
As a hint to you where my problem is:
THIS UGLY HACK (in bearer_event.c) WOULD SOLVE MY ISSUE:
=> if I comment the interrupt prioriry test and fix return a 1, my program works fine!!
bool bearer_event_in_correct_irq_priority(void)
{
volatile IRQn_Type active_irq = hal_irq_active_get();
if (active_irq == HAL_IRQn_NONE)
{
// return (m_irq_priority == NRF_MESH_IRQ_PRIORITY_THREAD || !hal_irq_is_enabled(EVENT_IRQn));
return 1; //HACK!!! not testing irq
}
else
{
volatile uint32_t prio = NVIC_GetPriority(active_irq);
return (prio == m_irq_priority || (prio > m_irq_priority && !hal_irq_is_enabled(EVENT_IRQn)));
}
}
Questions:
- What am I doing wrong?
- Is there any example how this has to be done?
- the explanation in this link
https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v3.2.0/md_doc_introduction_mesh_interrupt_priorities.html#irq_levels_changes_main_loop
where "Run application and mesh event handling in main loop" did not help me. - I was running into similar problems when trying to do this. Even worse: there was an assert immediately.
- The changes to be done were not clear: What has to be changed in sdk_config.h? What other changes are required?
- the explanation in this link
- is there an easy solution for my problem?
kind regards
Thomas