<?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>Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44515/mesh-node-self-provisioning</link><description>Hi all, 
 I want to self provision my node. I am using nrf52832 dev board, mesh SDK v 3.1.0, light switch client example. You may wonder why self provisioning, when there is nrf mesh provisioning mobile app, but it is the necessary intermediate step in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Dec 2021 14:37:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44515/mesh-node-self-provisioning" /><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/342958?ContentTypeID=1</link><pubDate>Fri, 10 Dec 2021 14:37:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c64f6fe7-ff51-4f3f-80e2-330a3e882d1b</guid><dc:creator>Pm7</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;      dsm_local_unicast_address_t local_address = {1, ACCESS_ELEMENT_COUNT};
      dsm_handle_t net_handle,dev_handle,app_handle,vendor_handle,handle;

      ERROR_CHECK(dsm_local_unicast_addresses_set(&amp;amp;local_address));
      ERROR_CHECK(dsm_subnet_add(0, KEY.privacy_key, &amp;amp;net_handle));
      ERROR_CHECK(dsm_devkey_add(local_address.address_start, net_handle, KEY.privacy_key, &amp;amp;dev_handle));
      KEY.privacy_key[15]=0xA0;
      ERROR_CHECK(dsm_appkey_add(0, net_handle ,KEY.privacy_key, &amp;amp;app_handle));

      ERROR_CHECK(config_server_bind(dev_handle));
      IsValid = vendor_handle_get(&amp;amp;vendor_handle);
      if(IsValid==0)  while(1); //stay locked
      ERROR_CHECK(access_model_application_bind(vendor_handle, app_handle));

      // Add the address to the DSM as a subscription address:
      i = dsm_address_subscription_add(GROUP_SUB_ADDR, &amp;amp;handle);
      // Add the subscription to the model:
      i = access_model_subscription_add(vendor_handle, handle);

      mesh_stack_device_reset();  //power cycle after self provisioning
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is my version that works with vendor model&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/211587?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 14:52:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b40a629-3ae7-4347-9e47-447b333fb020</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Nishant,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The device key is generated using&amp;nbsp;prov_utils_derive_keys(). My understanding is that&amp;nbsp; it&amp;#39;s calculated on both side the provisioner and provisionee (should have the same result) using that function.&amp;nbsp;So that key is not exchanged between them.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/211286?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 13:22:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cbdcc0b-4777-414e-be65-c4aba80be800</guid><dc:creator>nish</dc:creator><description>&lt;p&gt;Hi Hung, I am trying to do a similar thing as this post, but I need to ask, where does teh device key come from?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/176801?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2019 16:25:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8404e855-f0f2-4efa-9036-599cb90fa2a5</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Patrik,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This code worked for me. There is no model configured but I can see I can receive the message to address 0xC001 on access layer. This is a very minimum code, you would need to add device key, bind the appkey to model etc.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t my_mesh_stack_provisioning_data_store()
{
    dsm_handle_t netkey_handle, devkey_handle;
    dsm_local_unicast_address_t local_address;
    uint8_t netkey[16]={0x79,0xF5,0xF1,0x6A,0x43,0x22,0x17,0xDF,0x1D,0xC1,0x59,0x10,0x13,0x0A,0x31,0x6F};
    uint8_t appkey[16]={0x5B,0xD8,0xDE,0xB4,0x49,0xAB,0x15,0x1B,0x72,0x7F,0xD4,0x56,0xF5,0x49,0x81,0x9B};
    local_address.address_start = 0x99;
    local_address.count = ACCESS_ELEMENT_COUNT;
    uint32_t status;
    dsm_handle_t app_handle;
    /* Store received provisioning data in the DSM */
    status = dsm_local_unicast_addresses_set(&amp;amp;local_address);
    if (status != NRF_SUCCESS)
    {
        return status;
    }
    status = dsm_subnet_add(0, netkey, &amp;amp;netkey_handle);
    if (status != NRF_SUCCESS)
    {
        return status;
    }
    NRF_MESH_ERROR_CHECK(net_state_iv_index_set(0,0));

    dsm_handle_t network_handle = dsm_net_key_index_to_subnet_handle(0);
    status = dsm_appkey_add(0, network_handle, appkey, &amp;amp;app_handle);
    dsm_handle_t subscription_address_handle;
    status = dsm_address_subscription_add(0xC001, &amp;amp;subscription_address_handle);
    return status;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that to print out the &amp;quot;RX:&amp;quot; log in access.c you need to enable logging at level DBG1.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;(Posted this just to find out that you figured it out 20 minutes earlier :) . Good news Patrik. )&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/176794?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2019 16:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eecdf0a9-d6fe-44e7-9aed-c61a3edec4d5</guid><dc:creator>Patrik</dc:creator><description>&lt;p&gt;But there also must be some function, which calculates all those values from the netkey. Dont know so far.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/176793?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2019 16:02:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57587bfd-6053-4cf7-89a5-1c4955a75123</guid><dc:creator>Patrik</dc:creator><description>&lt;p&gt;Resolved !!!&lt;/p&gt;
&lt;p&gt;It was pain to debug. It was also necessary to set the&amp;nbsp;identical encryption key, privacy key, network id - all members of the structure&amp;nbsp;nrf_mesh_network_secmat_t. Not to acces this structure directly, using device manager function&amp;nbsp;dsm_net_secmat_from_keyindex_get()&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/176492?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 15:37:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:556a3ba7-5b5b-43df-9668-a83e3990a23a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Patrik,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will try to do some tests here. But be aware that appkeys are used in the transport layer to decrypt message before the access layer. You can find in the access.c all messages are already decrypted.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, hardcoded provisioning is not suggested and is not fully following the spec.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/176443?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 14:01:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eec5a935-e841-46b7-bfba-b61c203df092</guid><dc:creator>Patrik</dc:creator><description>&lt;p&gt;checked the iv index, network key, netkey index, iv update, key refresh, subscription and publish address. the same by provisioning the node by external provisioner (nrf mesh app) and by self provisioning. still not working. controlling if receiving messages at the other side at the access layer. can it be problem with some other encryption key? any other idea?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/175621?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2019 12:30:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a7bdd15-01ba-4a57-891d-882a774392c3</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Not Netkey but IV Index you need to set&amp;nbsp;&lt;span&gt;net_state_iv_index_set()&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you try adding a breakpoint in&amp;nbsp;mesh_stack_provisioning_data_store() when you provisioning your client (using a provisioner) to see if there is any difference in the provisioning data compare to what you do on your code ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/175600?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2019 10:34:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7c5e72c-325a-472e-aca4-c1a4dbe8bdd3</guid><dc:creator>Patrik</dc:creator><description>&lt;p&gt;netkey set to zero, but the result is the same&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/175598?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2019 10:28:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:934fb844-9c2c-44e0-ab34-4ccb0089bc8c</guid><dc:creator>Patrik</dc:creator><description>&lt;p&gt;Ouu, yes all the keys are arrays. It is wrong above in the code snippet, but in my code it is ok. I made the mistake by editing to devzone. Double checked the rest of the code above and it is identical with my code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/175555?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2019 08:55:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04bb55a1-abd8-448a-b762-968fa7cf8384</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Patrik,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We spotted that you used the wrong key defines. They should be uint8_t[16] an array, not just an uint8_t.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In addition the IV Index need to be set as well (you can try to set it to 0 ).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We have &lt;a href="https://github.com/NordicSemiconductor/nRF5-SDK-for-Mesh/blob/master/mesh/stack/src/mesh_stack.c#L143"&gt;this function here&lt;/a&gt; that apply provisioning data after received from provisioner that you may want to have a look.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/175222?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 00:58:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccecd783-c234-44fb-9397-e8005154100b</guid><dc:creator>Patrik</dc:creator><description>&lt;p&gt;Thank you for the reply, Hung. I printed the TX and RX info in both of the functions&amp;nbsp;&lt;span&gt;mesh_msg_handle() and&amp;nbsp;packet_tx(). I found out, that the self provisioned client is sending the message on the air. To confirm I am really sending messages on the air, in the access.c&amp;nbsp; in mesh_evt_cb() I added printing functions:&lt;pre class="ui-code" data-mode="text"&gt;static void mesh_evt_cb(const nrf_mesh_evt_t * p_evt)
{
    switch (p_evt-&amp;gt;type)
    {
        case NRF_MESH_EVT_MESSAGE_RECEIVED:
            SEGGER_RTT_printf(0, &amp;quot;%s(): Received message from address 0x%04x\n&amp;quot;, __func__, p_evt-&amp;gt;params.message.src.value);
            mesh_msg_handle(&amp;amp;p_evt-&amp;gt;params.message);
            break;
         case NRF_MESH_EVT_TX_COMPLETE:
            SEGGER_RTT_printf(0, &amp;quot;%s(): Message has been sent on the air with token number %u\n&amp;quot;, __func__, p_evt-&amp;gt;params.tx_complete.token);
            break;
        default:
            /* Ignore */
            break;
    }

}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;On the self provisioned client side: checked the&amp;nbsp;NRF_MESH_EVT_TX_COMPLETE event, because this event happens when the packet is sent on the air. I could also watch in packet_tx() sending to destination address, the source address and the whole message:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint32_t packet_tx(access_model_handle_t handle,
                          const access_message_tx_t * p_tx_message,
                          const access_message_rx_t * p_rx_message,
                          const uint8_t *p_access_payload,
                          uint16_t access_payload_len)
{
    ....
    ....
    ....
    status = nrf_mesh_packet_send(&amp;amp;tx_params, NULL);
    if (status == NRF_SUCCESS)
    {
        __LOG(LOG_SRC_ACCESS, LOG_LEVEL_DBG1, &amp;quot;TX: [aop: 0x%04x] \n&amp;quot;, p_tx_message-&amp;gt;opcode.opcode);
        __LOG_XB(LOG_SRC_ACCESS, LOG_LEVEL_DBG1, &amp;quot;TX: Msg&amp;quot;, p_tx_message-&amp;gt;p_buffer, p_tx_message-&amp;gt;length);
        
        SEGGER_RTT_printf(0, &amp;quot;TX: Sending message to address 0x%04x\n&amp;quot;, tx_params.dst.value);
        SEGGER_RTT_printf(0, &amp;quot;TX: The source address of message: 0x%04x\n&amp;quot;, tx_params.src);
    }
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;On the server side, which I provisioned and configured by nrf mesh app: checked&amp;nbsp;NRF_MESH_EVT_MESSAGE_RECEIVED event, which&amp;nbsp;is triggered when incomming message.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In my case the event&amp;nbsp;NRF_MESH_EVT_TX_COMPLETE&amp;nbsp;occurs every time on the client side, but the event&amp;nbsp;NRF_MESH_EVT_MESSAGE_RECEIVED&amp;nbsp;is not occuring on the server side. I am working with group address, publication group address on the client side and subscription address on the server side set&amp;nbsp;the same, checked many times and confirmed, that on both side set the same netkey, appkey, iv index. Not sure if necessary, but in my case on both sides set the same appkey index and netkey index.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To simulate my case, please try the light switch client example from mesh&amp;nbsp;v1.0.1 on one board and the light switch server example from mesh version&amp;nbsp;3.1.0 on the second board. The server example I provisioned with nrf mesh app. In the client example I commented the following lines (to prevent provisioning of external nodes):&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&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);
//    if (m_configured_devices == 0)
//    {
//        __LOG(LOG_SRC_APP, LOG_LEVEL_WARN, &amp;quot;No devices provisioned\n&amp;quot;);
//        return;
//    }
//    else if (m_configured_devices &amp;lt;= button_number &amp;amp;&amp;amp; button_number != BUTTON_NUMBER_GROUP)
//    {
//        __LOG(LOG_SRC_APP, LOG_LEVEL_WARN, &amp;quot;Device %u not provisioned yet.\n&amp;quot;, button_number);
//        return;
//    }

    uint32_t status = NRF_SUCCESS;
    switch (button_number)
    {
        case 0:
        case 1:
        case 2:
            /* Invert LED. */
            status = simple_on_off_client_set(&amp;amp;m_clients[button_number],
                                              !hal_led_pin_get(BSP_LED_0 + button_number));
            break;
        case 3:
            /* Group message: invert all LEDs. */
            status = simple_on_off_client_set_unreliable(&amp;amp;m_clients[GROUP_CLIENT_INDEX],
                                                         !hal_led_pin_get(BSP_LED_0 + button_number), 3);
            break;
        default:
            break;
    }
    
    ....
    ....
    ....
}

static void access_setup(void)
{
    ....
    ....
    ....
    
//    provisioner_init();
//    if (m_configured_devices &amp;lt; m_provisioned_devices)
//    {
//        provisioner_configure(UNPROV_START_ADDRESS + m_configured_devices);
//    }
//    else if (m_provisioned_devices &amp;lt; SERVER_COUNT)
//    {
//        provisioner_wait_for_unprov(UNPROV_START_ADDRESS + m_provisioned_devices);
//    }

}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I know that the server example contains the generic on off client model and the server example contains the simple on off server model, two different models, but up to the access layer the message should be processed even if not the same appkeys but the publication group address on the client side and subscription address on the server side set the same, network key set the same on both sides, iv index the same on both sides, not sure for appkey index and network index but in my case set the same on both sides.&amp;nbsp; -- &amp;gt; in this case NRF_MESH_EVT_MESSAGE_RECEIVED&amp;nbsp; event should occur on the server side when sending messages from client node. I tried it, but this event is not triggered. Dont know why ... Please, try to simulate that case :)&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh node self provisioning</title><link>https://devzone.nordicsemi.com/thread/174855?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 15:27:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:702af8d5-2eb8-4d39-8a6d-ffdb6bd72635</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Patrik,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;A good source of reference is to have a look at our Mesh SDK v1.0.1&amp;#39;s light switch example. In that example we have the provisioner and the client combined. And we actually have hardcoded provisioning in that example.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;It looks pretty good in your code, I don&amp;#39;t think there is any thing missing.&amp;nbsp;I would suggest to debug on access layer , if you look at the code you can find where we printout &amp;quot;TX:&amp;quot; and &amp;quot;RX:&amp;quot; in access.c (Inside&amp;nbsp;mesh_msg_handle() and&amp;nbsp;packet_tx().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to printout the message&amp;nbsp; data and meta data on the client when you press the button (check TX) and on the server when there is any message arrives (check RX)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would also suggest to double check the netkey and app key received on the server after you provision the node using the phone, just to double check if they are identical to what you have on the client.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>