<?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>Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44994/sending-messages-to-unicast-addresses</link><description>In the latest Mesh SDK, nodes are subscribed to a GROUP address. In previous versions - 2.0.0 I believe - you could also send to a predetermined node. 
 I am trying to figure out how to send a message to any one node via its unicast address. I have created</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Jun 2019 09:49:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44994/sending-messages-to-unicast-addresses" /><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/192879?ContentTypeID=1</link><pubDate>Fri, 14 Jun 2019 09:49:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b96ae6d4-5d1c-486d-b7b6-d99e709fdec5</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;Solved!&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint32_t set_model_publish_address(uint16_t publish_address, access_model_handle_t model_handle) 
{  
    uint32_t status = NRF_SUCCESS;
    dsm_handle_t publish_address_handle = DSM_HANDLE_INVALID;
    access_model_publish_address_get(model_handle, &amp;amp;publish_address_handle);
    NRF_MESH_ASSERT(dsm_address_publish_remove(publish_address_handle) == NRF_SUCCESS);
    status = dsm_address_publish_add(publish_address, &amp;amp;publish_address_handle); 
    if (status != NRF_SUCCESS) {
        return status;
    } 
    else {
        return access_model_publish_address_set(model_handle, publish_address_handle);
    }
} &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I call this function like so:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;set_model_publish_address(UNI_ADDR, m_clients[2].model_handle);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Credit: Hung Bui (&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/35931/multiple-server-on-one-client---light-switch-demo"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/35931/multiple-server-on-one-client---light-switch-demo&lt;/a&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/188777?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 09:37:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d70669f-52a1-45d7-8d88-32585d5d42e7</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Hey, I haven&amp;#39;t actually tried it yet, as i first need to implement functionality before optimizing thing =] Didn&amp;#39;t see that it takes a handle. I&amp;#39;d also say you need to call &lt;em&gt;dsm_address_publish_add()&lt;/em&gt; for each unicast address then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/188747?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 08:44:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea141dcd-a048-41d5-a2c1-1ad1bd2dec53</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;Hi Bart, any luck on this? I tried using &lt;em&gt;access_model_publish_address_set()&lt;/em&gt;, but it takes in a handle not an actual address. From my exploration of the code it appears that handles are determined at the configuration stage by the provisioner. There is also &lt;em&gt;dsm_address_publish_add()&lt;/em&gt; which takes in a raw address, but I haven&amp;#39;t had any luck with that either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/187425?ContentTypeID=1</link><pubDate>Thu, 16 May 2019 07:45:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d665284-46c1-4f01-a54f-3a47855093e4</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Hi Bj&amp;oslash;rn,&lt;br /&gt;&lt;br /&gt;I was also looking into sending unicast messages. It seems very silly to me to have a model instance for every possible node in the network, so I was wondering:&lt;br /&gt;&lt;br /&gt;Is it out of spec if a node sends messages to unicast addresses it was not specifically told to publish to by a provisioner?&lt;br /&gt;&lt;br /&gt;Can you call &lt;em&gt;access_model_publish_address_set()&lt;/em&gt; before publishing a message, maybe multiple times per second. Or does that break some mesh code? Is this maybe different for reliable and unreliable messages?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/178329?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2019 12:19:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e89ea9b5-804f-474d-8875-abcc4b2e0993</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;I&amp;#39;ve got it working now, though the code is not ideal, I have NODE_SETUP_CONFIG_APPKEY_BIND_ONOFF_CLIENT listed 31 (!) times in client_config_steps and NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT&lt;em&gt;&lt;/em&gt;2 listed 30 (!) times. Many thanks for the help.&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/178306?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2019 11:26:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b644f335-fed7-4a3f-a3a1-79631196a4e7</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;Hi Bj&amp;oslash;rn, thanks for the detailed response. I have implemented your suggestions in the provisioner. However, I have used a for loop inside NODE_SETUP_CONFIG_APPKEY_BIND_ONOFF_CLIENT rather than having it listed many times in the config steps. But, I am getting an NRF_BUSY_ERROR after the first time the loop is run. It&amp;#39;s caused by client_in_wrong_state() in config_client.c : &lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static bool client_in_wrong_state(uint32_t * p_status)
{
    if (m_client.state == CONFIG_CLIENT_STATE_NONE)
    {        
        *p_status = NRF_ERROR_INVALID_STATE;
        return true;
    }
    else if (m_client.state == CONFIG_CLIENT_STATE_WAIT_REPLY)
    {
        *p_status = NRF_ERROR_BUSY;
        return true;
    }
    return false;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;which is called by app_bind_unbind_send() which is in turn called by config_client_model_app_bind(). I cannot work out why this is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/178241?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2019 08:07:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a34a2b1b-a900-479c-a1b0-8560339cb5bf</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>[quote user="jonappleseed"]Do I need to have a model for each server?[/quote]
&lt;p&gt;&amp;nbsp;No, you do not need to have a generic on off client model for each server. You could for example publish from one client to multiple servers via a group address. If you however want to publish messages via a unicast address from the client to one server &amp;amp; do this for multiple servers, I would suggest having one client model for each server model. Let&amp;#39;s say you had 4 server nodes for example. You could then have four generic on off client models &amp;amp; each client model would publish to the unicast address of one of the server models. You could then use the four buttons on the DK to publish to each of the four server nodes.&lt;/p&gt;
[quote user="jonappleseed"]If I need a model for each server, how can I do this without having to write a separate&amp;nbsp;NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT&lt;em&gt;x&lt;/em&gt; for each of them?[/quote]
&lt;p&gt;&amp;nbsp;You could have one NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT case &amp;amp; then based on the&amp;nbsp;m_current_node_addr, you know which client you are setting the publish address for. You could then have an if or switch statement &amp;amp; then set the publish address to the corresponding server unicast address (similar to how it is done with the if else statement in NODE_SETUP_CONFIG_SUBSCRIPTION_ONOFF_SERVER). In client_config_steps[], remember to&amp;nbsp;have the same amount of&amp;nbsp;NODE_SETUP_CONFIG_APPKEY_BIND_ONOFF_CLIENT calls&amp;nbsp;as there are client models. In addition, you would need to call&amp;nbsp;&lt;span&gt;NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT&amp;nbsp;the same amount of times as the client models.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/178044?ContentTypeID=1</link><pubDate>Mon, 25 Mar 2019 10:10:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74773a86-1586-471c-b50e-fa2703c0e70c</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;Do I need to have a model for each server? When I use access_model_publish_address_set it just changes the publish address, which means that when I call generic_onoff_client_set it returns NRF_ERROR_BUSY because it&amp;#39;s trying to run the same model. If I need a model for each server, how can I do this without having to write a separate&amp;nbsp;NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT&lt;em&gt;x&lt;/em&gt; for each of them?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/177782?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2019 09:48:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e8005f3-b590-4d39-8364-b378499eaf2f</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;I can send to just the first server, but I want to be able to send to all nodes individually. That&amp;#39;s what my second bit of code is trying to achieve, but getting the error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/177728?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2019 07:37:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9ed3e7e-f65e-4710-aee9-f56fbd4abf07</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;If you want to provision via the provisioner light switch example,&amp;nbsp;the only changes you would need to make are in the node_setup.c file like you mention above. Assuming you want the first client to publish to the first server address, you would need to find the element address of the server.&lt;/p&gt;
&lt;p&gt;In the latest mesh sdk (i.e. v3.1.0), the check_network_state() function will configure the different nodes. The&amp;nbsp;node_setup_start() function is then called, which then calls&amp;nbsp;setup_select_steps(). This function will then go through the client configuration steps first before going through the server configuration steps. config_step_execute() then goes through all of the steps in order to configure the node.&lt;/p&gt;
&lt;p&gt;If I were you, I would keep track of the element_address in each step. The steps are essentially hardcoded at the moment. If you go through the whole process, add a bit more logging info to the element address, you can predict the unicast element address of the server. That way, you can set the correct unicast publication address for the case&amp;nbsp;NODE_SETUP_CONFIG_PUBLICATION_ONOFF_CLIENT1. The setup for setting the publication unicast address should be similar to the case&amp;nbsp;NODE_SETUP_CONFIG_PUBLICATION_ONOFF_SERVER.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/177571?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2019 12:28:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd7d9767-6387-402e-9bba-b4b8fcf69242</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;I tried to use access_model_publish_address_set() to change the address the model uses:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;         case 1:
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;-- Acknowledged unicast\n&amp;quot;);
            (void)access_model_reliable_cancel(m_clients[0].model_handle);
            dsm_handle_t handle;
            (void)access_model_publish_address_get(m_clients[0].model_handle, &amp;amp;handle);
            for (int i = 0; i &amp;lt; SERVER_NODE_COUNT; i++) {
              status = access_model_publish_address_set(m_clients[0].model_handle, handle+i);
              __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;%u\n&amp;quot;, status);
              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;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This causes the following to be true:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;access_model_publish_address_set(...) {
...
else if (DSM_ADDR_MAX &amp;lt;= address_handle)
{
    return NRF_ERROR_INVALID_PARAM;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So I increased ACCESS_MODEL_COUNT to remove this error, and now I get the following when pressing button 1:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;app_error_weak.c,&amp;nbsp; 108, Mesh assert at 0x000340B6 (:0)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/177287?ContentTypeID=1</link><pubDate>Wed, 20 Mar 2019 10:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa62bb94-e659-4834-9aa6-d5cf60e00ca6</guid><dc:creator>jonappleseed</dc:creator><description>&lt;p&gt;Thanks, but I would like to do this without the app. I have a version of the very old SDK (alpha) in which the client could send to any individual board because m_clients was an array of the individual boards. In the new SDK however, there are only two models - one to send to even the other to odd. I would like to use one of the models for unicast sending but I cannot figure out how to.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to unicast addresses</title><link>https://devzone.nordicsemi.com/thread/177257?ContentTypeID=1</link><pubDate>Wed, 20 Mar 2019 09:17:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16318225-e8f3-4d7a-b9e6-dc44d56e3eec</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;You can easily do this using the nRF Mesh smartphone app. The procedure is similar to the Youtube video &lt;a href="https://www.youtube.com/watch?v=XthbU9NP0Yg&amp;amp;t=157s"&gt;shown here&lt;/a&gt;. What you will need to do is have one standard light switch client &amp;amp; one standard light switch server board. I tested with the mesh sdk v3.1.0. Then, provision both boards. On the client board in nRF Mesh, add the application key (under appkey binding, choose the first one) &amp;amp;&amp;nbsp; set the publication address of the first generic on off client model to be the unicast address of the server board. If you click on the server board in nRF Mesh, you can see that the generic on off server is under element 0 with a unicast address (e.g. element 0. UNICAST: 0004). On the server board, you need to bind the same appkey to the generic on off server model. This way, both nodes will be able to communicate with each other over the access layer in the mesh sdk. Then, when you press button 1 &amp;amp; 2 on the client board, you will send an acknowledged set message to turn the server board either on or off. The procedure should be similar if you want to add multiple server boards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>