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

Message received event, Bluetooth Mesh

Hello,

I am using nRF SDK for Mesh 3.1 and nRF52940 SoC. I have two nodes in my network which both act as a client and a server. Both of them subscribes and publishes to same group address. That is, if I publish a message on one of the devices, both receive that message. However, if I, upon receiving the message, triggers an event that takes some time, i.e. a for/while loop or similar, I noticed that this event needs to finish on the device that sent the message before the other device receives it. Why is that?

For example, if I call access_model_publish on one of my devices and perform a loop in the opcode handler, this has to finish on the sending device before the other device receives the message. I want them to receive the message at approximately the same time.

Parents
  • Hello,

    This is probably because the interrupt handler for the event is blocking the device from actually transmitting the message. I suggest that you try to leave the interrupt handler as soon as possible. You can e.g. set a flag in the interrupt handler, and then use the main context to check if that flag is set. If it is, then perform whatever tasks that you need to handle from main(). 

    So your main() can look something like this:

    volatile bool m_my_flag = false;
    
    static void my_interrupt_handler(void)
    {
        m_my_flag = true;   // leave the interrupt handler quickly, so that the radio can transmit the message
    }
    
    
    int main(void)
    {
        initialize();
        start();
    
        for (;;)
        {
            if (m_my_flag)
            {
                m_my_flag = false;
                do_stuff(); // handle interrupt from main context, so that the radio has the priority.
            }
            (void)sd_app_evt_wait();
        }
    }

    Best regards,

    Edvin

Reply
  • Hello,

    This is probably because the interrupt handler for the event is blocking the device from actually transmitting the message. I suggest that you try to leave the interrupt handler as soon as possible. You can e.g. set a flag in the interrupt handler, and then use the main context to check if that flag is set. If it is, then perform whatever tasks that you need to handle from main(). 

    So your main() can look something like this:

    volatile bool m_my_flag = false;
    
    static void my_interrupt_handler(void)
    {
        m_my_flag = true;   // leave the interrupt handler quickly, so that the radio can transmit the message
    }
    
    
    int main(void)
    {
        initialize();
        start();
    
        for (;;)
        {
            if (m_my_flag)
            {
                m_my_flag = false;
                do_stuff(); // handle interrupt from main context, so that the radio has the priority.
            }
            (void)sd_app_evt_wait();
        }
    }

    Best regards,

    Edvin

Children
No Data
Related