<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to process received Mesh message with scheduler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55016/how-to-process-received-mesh-message-with-scheduler</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Dec 2019 23:51:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55016/how-to-process-received-mesh-message-with-scheduler" /><item><title>RE: How to process received Mesh message with scheduler</title><link>https://devzone.nordicsemi.com/thread/226865?ContentTypeID=1</link><pubDate>Thu, 26 Dec 2019 23:51:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1d7e0cc-b5b3-4134-88a5-37fe73a883a7</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks for sharing the solution.&lt;/p&gt;
&lt;p&gt;You are very welcome to open a new ticket if you have any questions in the future.&lt;/p&gt;
&lt;p&gt;Best regards, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process received Mesh message with scheduler</title><link>https://devzone.nordicsemi.com/thread/226820?ContentTypeID=1</link><pubDate>Wed, 25 Dec 2019 08:23:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b36785ce-7af6-4ace-84b5-46dea576bb71</guid><dc:creator>wataru_m</dc:creator><description>&lt;p&gt;### Update ###&lt;br /&gt;&lt;br /&gt;It seems that the cause was not calling nrf_mesh_process () function.&lt;br /&gt;&lt;br /&gt;I couldn&amp;#39;t spend much time analyzing this problem, so I hoped that the support team could solve it if possible...&lt;br /&gt;But fortunately I was able to solve the problem.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If I get stuck in future developments, please let me consult again.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Wataru&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process received Mesh message with scheduler</title><link>https://devzone.nordicsemi.com/thread/223460?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 03:04:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:faec4d3b-e1c6-4f15-bb39-a2ceeefcdc4d</guid><dc:creator>wataru_m</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;span&gt;Joakim&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Thank you for your reply.&lt;br /&gt;I will continue this question assuming that there was no fatal problem with the way I handled the data received in Mesh messages.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I&amp;#39;m sorry for the lack of information about asserts.&lt;br /&gt;Now I will supplement.&lt;br /&gt;&lt;br /&gt;As a premise, core.irq_priority of init_params is set to NRF_MESH_IRQ_PRIORITY_LOWEST in mesh_init function.&lt;br /&gt;&lt;br /&gt;I tried to send a message to the Server as shown below in the function that processes the message received from the Server using the method shown in this thread.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void scheduled_status_cb(void * p_event, uint16_t event_size)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;src : %X, RSSI : %d, dst : %X, onoff : %d.\n&amp;quot;,
          check_struct-&amp;gt;src_addr,
          check_struct-&amp;gt;rssi,
          check_struct-&amp;gt;dst_addr,
          check_struct-&amp;gt;pp_in.present_on_off);

    // Send message to Server after LOG output
    // packet send test &amp;lt;--
    uint32_t status = NRF_SUCCESS;
    generic_onoff_set_params_t set_params;
    model_transition_t transition_params;
    static uint8_t tid = 0;

    set_params.on_off = APP_STATE_ON;
    set_params.on_off = APP_STATE_OFF;
    set_params.tid = tid++;

    transition_params.delay_ms = APP_CONFIG_ONOFF_DELAY_MS;
    transition_params.transition_time_ms = APP_CONFIG_ONOFF_TRANSITION_TIME_MS;
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Sending msg: ONOFF SET %d\n&amp;quot;, set_params.on_off);

    /* Demonstrate acknowledged transaction, using 1st client model instance */
    /* In this examples, users will not be blocked if the model is busy */
    (void)access_model_reliable_cancel(m_clients[0].model_handle);
    status = generic_onoff_client_set(&amp;amp;m_clients[0], &amp;amp;set_params, &amp;amp;transition_params);
    hal_led_pin_set(BSP_LED_0, set_params.on_off);

    switch (status)
    {
        case NRF_SUCCESS:
            break;

        case NRF_ERROR_NO_MEM:
        case NRF_ERROR_BUSY:
        case NRF_ERROR_INVALID_STATE:
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Client %u cannot send\n&amp;quot;, set_params.on_off);
            hal_led_blink_ms(LEDS_MASK, LED_BLINK_SHORT_INTERVAL_MS, LED_BLINK_CNT_NO_REPLY);
            break;

        case NRF_ERROR_INVALID_PARAM:
            /* Publication not enabled for this client. One (or more) of the following is wrong:
             * - An application key is missing, or there is no application key bound to the model
             * - The client does not have its publication state set
             *
             * It is the provisioner that adds an application key, binds it to the model and sets
             * the model&amp;#39;s publication state.
             */
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Publication not configured for client %u\n&amp;quot;, set_params.on_off);
            break;

        default:
            ERROR_CHECK(status);
            break;
    }
    // packet send test --&amp;gt;
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Paste the LOG after receiving the message from Server.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;t:          0&amp;gt;, main.c,  505, ----- BLE Mesh Light Switch Client Demo -----
&amp;lt;t:      12630&amp;gt;, main.c,  473, Initializing and adding models
&amp;lt;t:      12668&amp;gt;, mesh_app_utils.c,   65, Device UUID (raw): 895C84CA03636D46B2C2043C2899D709
&amp;lt;t:      12671&amp;gt;, mesh_app_utils.c,   70, Device UUID : CA845C89-6303-466D-B2C2-043C2899D709
&amp;lt;t:      86589&amp;gt;, main.c,  311, app_generic_onoff_client_status_cb called.
&amp;lt;t:      86592&amp;gt;, main.c,  349, src : 22, rssi : -24, dst : C005.
&amp;lt;t:      86599&amp;gt;, main.c,  196, scheduled_status_cb called.
&amp;lt;t:      86602&amp;gt;, main.c,  227, src : 22, RSSI : -24, dst : C005, onoff : 1.
&amp;lt;t:      86605&amp;gt;, main.c,  244, Sending msg: ONOFF SET 0
&amp;lt;t:      86615&amp;gt;, app_error_weak.c,  108, Mesh assert at 0x0002AC62 (:0)
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Breaking the debug and confirmed asserted part.&lt;br /&gt;It caused by &amp;quot;NRF_MESH_ASSERT_DEBUG (bearer_event_in_correct_irq_priority ());&amp;quot; on line 214 of timer_scheduler.c. .&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, I changed the core_irq_priority of init_params from NRF_MESH_IRQ_PRIORITY_LOWEST to NRF_MESH_IRQ_PRIORITY_THREAD in the mesh_init function of main.c.&lt;br /&gt;Then I can no longer receive messages from Server.&lt;br /&gt;Perhaps it is receiving as a device, but it does not seem to reach the application layer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Can you tell me an approach to solve this problem?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Wataru&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process received Mesh message with scheduler</title><link>https://devzone.nordicsemi.com/thread/223330?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 12:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:140a9003-dcb3-4b08-8cd7-abf5d623eb72</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Thanks for sharing you solution.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;At first look, I couldn&amp;#39;t find anything to put my finger on in the code. But I will take a closer look to make sure.&amp;nbsp;&lt;/p&gt;
[quote user="wataru_m"]If I call the send function, mesh assert will occur.[/quote]
&lt;p&gt;&amp;nbsp;Do you have any more specific information about the assert? Where the assert is originating from? Error codes etc?&lt;/p&gt;
&lt;p&gt;Br,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process received Mesh message with scheduler</title><link>https://devzone.nordicsemi.com/thread/223195?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 06:12:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4d8745d-b3b3-415a-ba6f-d9493e0a3dd4</guid><dc:creator>wataru_m</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;You might have been trying to give me some guide, but I seem to have solved it myself.&lt;br /&gt;However, since I am not confident about whether this method is safe, I would be grateful if you could comment.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I modified the structure to extract only the data needed for the application:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;typedef struct
{
    uint16_t src_addr;
    uint16_t dst_addr;
    int8_t rssi;
    generic_onoff_status_params_t pp_in;
} my_event_packet_t;
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the callback function called in the interrupt handler mode, only necessary information is copied and pushed to the event queue as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;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)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;%s called.\n&amp;quot;, __func__);

    my_event_packet_t packet_datas = {0};

    packet_datas.src_addr = p_meta-&amp;gt;src.value;
    packet_datas.dst_addr = p_meta-&amp;gt;dst.value;
    packet_datas.rssi = p_meta-&amp;gt;p_core_metadata-&amp;gt;params.scanner.rssi;
    memcpy(&amp;amp;packet_datas.pp_in, p_in, sizeof(generic_onoff_status_params_t));

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;src : %X, rssi : %d, dst : %X.\n&amp;quot;,
          p_meta-&amp;gt;src.value, p_meta-&amp;gt;p_core_metadata-&amp;gt;params.scanner.rssi, p_meta-&amp;gt;dst.value);

    app_sched_event_put((void *)&amp;amp;packet_datas, sizeof(packet_datas), scheduled_status_cb);
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The function executed by the scheduler gets the data as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void scheduled_status_cb(void * p_event, uint16_t event_size)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;%s called.\n&amp;quot;, __func__);

    my_event_packet_t * check_struct = (my_event_packet_t *) p_event;
    
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;src : %X, RSSI : %d, dst : %X, onoff : %d.\n&amp;quot;,
          check_struct-&amp;gt;src_addr,
          check_struct-&amp;gt;rssi,
          check_struct-&amp;gt;dst_addr,
          check_struct-&amp;gt;pp_in.present_on_off);
    
    /*
        some process...
    */
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Paste the run time log below.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;t:     478980&amp;gt;, main.c,  250, app_generic_onoff_client_status_cb called.
&amp;lt;t:     478983&amp;gt;, main.c,  288, src : 18, rssi : -29, dst : C005.
&amp;lt;t:     478991&amp;gt;, main.c,  196, scheduled_status_cb called.
&amp;lt;t:     478993&amp;gt;, main.c,  227, src : 18, RSSI : -29, dst : C005, onoff : 1.
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this way, it seems that I could handled the same data between the callback function when receiving a message and the function executed by the scheduler.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Can you find any fatal drawbacks to the above methods?&lt;br /&gt;If you feel that there are no shortcomings, my next goal is to send a message from a function that is executed from the scheduler.&lt;/p&gt;
&lt;p&gt;If I call the send function, mesh assert will occur. . .&lt;br /&gt;Can you tell me how to send a message with a function executed from the scheduler?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I hope you will be able to provide the information.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Wataru&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>