<?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>nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40090/nrf5-sdk-for-mesh-v2-2-0-light-switch-demo---where-next</link><description>So I have successfully built &amp;amp; deployed the Light Switch Demo - and it works. 
 
 But where do we go next? 
 The documentation seems far too close-in focussed on the microscopic details of functions, types, etc - I can&amp;#39;t see anything which gives a macroscopic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Mar 2019 10:12:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40090/nrf5-sdk-for-mesh-v2-2-0-light-switch-demo---where-next" /><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/176367?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 10:12:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7026201-cda0-41be-91cf-a357fed663f0</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Thanks - I will have to find some time to look at it again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/176340?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 08:27:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:880e1ce0-a588-474e-a031-fd2995fb369c</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;I realize this is 4 months too late, but better late than never. I have created an example showing how you can create two generic on off server models with one element each. That way, it is possible to provision &amp;amp; configure the server example from the nRF Mesh smartphone app &amp;amp; control the LEDs 1 &amp;amp; 2 from the app itself. Unfortunately, there is a bug at the moment in the iOS app, which means that the state set message only gets sent to the first on off server unicast address &amp;amp; never to the second one.&lt;/p&gt;
&lt;p&gt;However, this works fine with the Android nRF Mesh app.&lt;/p&gt;
&lt;p&gt;I made a copy of the generic on off server light switch example from mesh sdk v3.1.0. The main changes were the following:&lt;/p&gt;
&lt;p&gt;- increased the ACCESS_MODEL_COUNT &amp;amp; ACCESS_ELEMENT_COUNT by one since I have added an extra element. The ACCESS_SUBSCRIPTION_LIST_COUNT has also been increased by one. All of these defines are found in nrf_mesh_config_app.h.&lt;/p&gt;
&lt;p&gt;- in main.c, I added another&amp;nbsp;APP_ONOFF_SERVER_DEF() for the second on off server model&lt;/p&gt;
&lt;p&gt;- also changed the&amp;nbsp;app_onoff_server_set_cb() to either change the LED state of LED 0 or LED 1 depending on which server model state is changed&lt;/p&gt;
&lt;p&gt;- app_model_init() has also been updated to initialize two generic on off models instead of one.&lt;/p&gt;
&lt;p&gt;I have added a comment //added by BK behind each line I have changed, so it should be easy to make search for the different changes.&lt;/p&gt;
&lt;p&gt;In nRF Mesh, just provision &amp;amp; configure the node similar to &lt;a href="https://www.youtube.com/watch?v=XthbU9NP0Yg&amp;amp;t=157s"&gt;this Youtube video&lt;/a&gt;, find the first server model, bind the app key &amp;amp; then change the state at the bottom of the same window. The same procedure applies for the second on off server model.&lt;/p&gt;
&lt;p&gt;I would recommend to run a debug session by pressing F5 to get additional logging info in SES.&lt;/p&gt;
&lt;p&gt;Unfortunately, I was unable to upload the zip file to DevZone, but &lt;a href="https://drive.google.com/file/d/1RW1ZPHH_ufpadbYxpLWevTXx1901sKlh/view?usp=sharing"&gt;I found a workaround&lt;/a&gt;. I have only tested on a 52832 DK.&lt;/p&gt;
&lt;p&gt;Just unzip the folder like this:&amp;nbsp;nrf5_SDK_for_Mesh_v3.1.0_src\examples\light_switch\server_4_generic_on_off&lt;/p&gt;
&lt;p&gt;It should then look similar to this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-3987648b494046f184e54b1801a359c8/pastedimage1552639988090v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/156609?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 09:10:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:637b8a34-223c-44ab-b27b-c96a4dee31c6</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;Yes, an element is essentially a controllable part of the device. So each LED would be a different element.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/156545?ContentTypeID=1</link><pubDate>Thu, 08 Nov 2018 20:02:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff4eed45-aced-4fbf-bbd3-e1606d63527e</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Thanks for all that&lt;/p&gt;
[quote userid="25682" url="~/f/nordic-q-a/40090/nrf5-sdk-for-mesh-v2-2-0-light-switch-demo---where-next/156538"]I am working on an example that will be able to use multiple LEDs on a server. [/quote]
&lt;p&gt;am I on the right lines of these being separate &amp;quot;Elements&amp;quot; in the BT Mesh lingo?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/156538?ContentTypeID=1</link><pubDate>Thu, 08 Nov 2018 17:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:000f3776-a06e-47e2-8678-20c5b9a67a68</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;Sorry for the delayed response. As it seems you have gone through the light switch demo with a provisioner, a client &amp;amp; a server &amp;amp; read the&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v2.2.0/md_doc_getting_started_getting_started.html?cp=4_1_0_1"&gt;documentation&lt;/a&gt;, I would recommend the following:&lt;/p&gt;
&lt;p&gt;Take a look at the light switch proxy client &amp;amp; proxy server examples &amp;amp; use the video in next link to get acquainted with the &lt;a href="https://www.nordicsemi.com/eng/Products/Nordic-mobile-Apps/nRF-Mesh"&gt;nRF Mesh application&lt;/a&gt; (iOS &amp;amp; Android).&lt;/p&gt;
&lt;p&gt;Essentially, all you need to do in the app is to bind the appkey to the generic on/off models &amp;amp; set the publish &amp;amp; subscription addresses. This is, in my opinion, the easiest way to get started.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then, I would make a few changes to the proxy client example. I believe the button_event_handler function should look like this out of the box (please correct me if I am wrong, as I may have made changes to this function):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void button_event_handler(uint32_t button_number)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Button %u pressed\n&amp;quot;, button_number);

    uint32_t status = NRF_SUCCESS;
    generic_onoff_set_params_t set_params;
    model_transition_t transition_params;
    static uint8_t tid = 0;

    /* Button 1: ON, Button 2: Off, Client[0]
     * Button 2: ON, Button 3: Off, Client[1]
     */

    switch(button_number)
    {
        case 0:
        case 2:
            set_params.on_off = APP_STATE_ON;
            break;

        case 1:
        case 3:
            set_params.on_off = APP_STATE_OFF;
            break;
    }

    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);

    switch (button_number)
    {
        case 0:
        case 1:
            /* 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);
            break;

        case 2:
        case 3:
            /* Demonstrate un-acknowledged transaction, using 2nd client model instance */
            status = generic_onoff_client_set_unack(&amp;amp;m_clients[1], &amp;amp;set_params,
                                                    &amp;amp;transition_params, APP_UNACK_MSG_REPEAT_COUNT);
            hal_led_pin_set(BSP_LED_1, set_params.on_off);
            break;
      }

    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;, button_number);
            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;, button_number);
            break;

        default:
            ERROR_CHECK(status);
            break;
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As the documentation states, buttons 1 &amp;amp; 3 are used to turn the app state on, whereas buttons 2 &amp;amp; 4 turn the app state off.&amp;nbsp;Buttons 1 &amp;amp; 2 then send an acknowledged message to the servers, whereas 3&amp;amp;4 send an un-acknowledged message. I would recommend taking a look at the button_event_handler function from mesh sdk v2.1.1 if you want to send group messages to a specific group:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void button_event_handler(uint32_t button_number)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Button %u pressed\n&amp;quot;, button_number);

    uint32_t status = NRF_SUCCESS;
    switch (button_number)
    {
        case 0:
        case 1:
            /* send unicast message, with inverted GPIO pin value */
            status = simple_on_off_client_set(&amp;amp;m_clients[button_number],
                                              !hal_led_pin_get(BSP_LED_0 + button_number));
            break;

        case 2:
        case 3:
            /* send a group message to the ODD group, with inverted GPIO pin value */
            status = simple_on_off_client_set_unreliable(&amp;amp;m_clients[button_number],
                                                         !hal_led_pin_get(BSP_LED_0 + button_number),
                                                         GROUP_MSG_REPEAT_COUNT);
            if (status == NRF_SUCCESS)
            {
                hal_led_pin_set(BSP_LED_0 + button_number, !hal_led_pin_get(BSP_LED_0 + button_number));
            }
            break;
        default:
            break;
    }

    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;Cannot send - client %u is busy\n&amp;quot;, button_number);
            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;, button_number);
            break;

        default:
            ERROR_CHECK(status);
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39629/how-to-send-data-to-all-node-over-mesh"&gt;another case here&lt;/a&gt; which could be interesting to see.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]&lt;p&gt;&lt;/p&gt;&lt;p&gt;How would&amp;nbsp;we expand that to give independent control of all 4 LEDs?&lt;/p&gt;&lt;p&gt;In BT Mesh terminology, I think that would mean making each LED an &amp;quot;Element&amp;quot; ?&lt;/p&gt;&lt;p&gt;So how would we instantiate these - as instances of the Generic On/Off model?&lt;/p&gt;&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am working on an example that will be able to use multiple LEDs on a server. Currently, I still have a few issues that I am trying to iron out, but I will let you know when I am done.&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/155945?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 12:33:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c871b824-9c4c-4003-a204-5b6386744983</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;No,&amp;nbsp; solutions are not much help - they are just &amp;quot;&lt;a href="https://en.wiktionary.org/wiki/give_a_man_a_fish_and_you_feed_him_for_a_day;_teach_a_man_to_fish_and_you_feed_him_for_a_lifetime#Proverb" rel="noopener noreferrer" target="_blank"&gt;&lt;em&gt;giving a man a fish&lt;/em&gt;&lt;/a&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;What we need is proper fishing lessons!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/155943?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 12:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d70e553-0726-41c0-935c-79c1cf3647e6</guid><dc:creator>turki</dc:creator><description>&lt;p&gt;so we just need to wait for solutions&amp;nbsp; ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK for Mesh v2.2.0: Light Switch Demo - Where Next?</title><link>https://devzone.nordicsemi.com/thread/155928?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 11:50:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f75502b8-168b-4b4d-8c4a-7c7336f9ac70</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Another example &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/40163/implementing-simple_on_off_client-server-too-instead-of-generic_onoff_client-server" rel="noopener noreferrer" target="_blank"&gt;here&lt;/a&gt;: how to actually use the Simple On/Off example model.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/40163/implementing-simple_on_off_client-server-too-instead-of-generic_onoff_client-server"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/40163/implementing-simple_on_off_client-server-too-instead-of-generic_onoff_client-server&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>