Remote provisioning of Dimming Server Example

Hi there.

Setup:

NRF SDK 17.1.0, MESH SDK 5.0.0, Segger Studio

DK1 PCA10056 pb_remote_client (for starting the remote provisioning)

DK2 PCA10056 Dimming Server example running, added parts from pb_remote_server for remote provisioning.

Issue:

DK 1 works as expected, wait for beacon, start provisioning

Log:

<t:   11576009>, main.c,  175, Local provisioning link established
<t:   11577812>, main.c,  219, Using static authentication
<t:   11591144>, main.c,  229, Static authentication data provided
<t:   11737090>, main.c,  184, Provisioned device addr: 0x1347 net_key_handle: 0
<t:   11737093>, main.c,  186, Dev Key: 9B749E470FDA945657016CD32BD0D229
<t:   11737103>, main.c,  194, Provisioning complete! Added 0x1347 as handle 1
<t:   11743125>, main.c,  179, Local provisioning link closed

but on DK2

Log:

<t:      18835>, app_level.c,  295, SET: Level: 0  delay: 0  tt: 0  req-delta: 0  trans-type: 0
<t:      18840>, main.c,  773, Transition time: 0, Target level: 0, Transition type: 0
<t:      18844>, app_level.c,  239, Transition completed: Present-L: 0  Target-L: 0
<t:      88095>, main.c, 1405, Mesh device identification started.
<t:     184843>, app_error_weak.c,  115, Mesh error 7 at 0x00000000 (:0)

To pin down the Mesh error 7 seems to come from the SD140 while changing the state from "device identification started cb" to "Provisioning completed"

Question:

pb_remote server model should be running byside of app level and scene server.

According to the Communication handshaking provisioning should be confimed by the server.

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v5.0.0%2Fmd_doc_user_guide_modules_provisioning_pb_remote.html

How has the PB Remote Server to be integrated in the service model(s) on the Mesh side?

Parents
  • Hi. 

    DK2 PCA10056 Dimming Server example running, added parts from pb_remote_server for remote provisioning.

    Maybe you could also add some information about how, where and what you have added to your code. 

    Br, 
    Joakim

  • Hi Joakim

    Of course:

    According the Dokumentation on:

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v5.0.0%2Fmd_doc_user_guide_modules_provisioning_pb_remote.html

    at the end of the Page.

    main.c

    // Include remote Provisioning
    #include "pb_remote_server.h"
    #include "nrf_mesh_prov_bearer_adv.h"
    //create struct for Server same with
    static pb_remote_server_t         m_remote_server;
    static nrf_mesh_prov_bearer_adv_t m_prov_bearer_adv;
    static dsm_handle_t               m_netkey_handle;
    static dsm_handle_t               m_appkey_handle;
    static dsm_handle_t               m_provisioner_address_handle;

    ..

    pb_remote_server_init():

    static void models_init_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
        //Init all models for Dimming server
        app_model_init();
        // For Remote Provisioner done in app_model_init as well
        

    static void app_model_init(void)
    {
        // add remote Provisioning
        ERROR_CHECK(pb_remote_server_init(&m_remote_server, REMOTE_SERVER_ELEMENT_INDEX));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "remote Level server handle: %d\n",
              m_remote_server.model_handle)
    
        /* Instantiate level server on element index APP_LEVEL_ELEMENT_INDEX */
        ERROR_CHECK(app_level_init(&m_level_server_0, APP_LEVEL_ELEMENT_INDEX));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "App Level Model handle: %d\n",
              m_level_server_0.server.model_handle)
    
        /*Instantiate level client on element index APP_LEVEL_ELEMENT_INDEX*/
        for (uint32_t i = 0; i < 1; ++i)//for (uint32_t i = 0; i < CLIENT_MODEL_INSTANCE_COUNT; ++i)
        {

    pb_remote_server_enable()

    pb_remote_server_prov_bearer_set():

    static void provisioning_complete_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Successfully provisioned\n");
    
    //Remote Provisioning Stuff------------------------------------------------------------------
        unicast_address_print();
        //hal_led_blink_stop();
        //hal_led_mask_set(HAL_LED_MASK, LED_MASK_STATE_OFF);
        //hal_led_blink_ms(HAL_LED_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_PROV);
        /* TODO: This should be handled by the configuration server model. */
        mesh_key_index_t net_key_index;
        uint32_t count = 1;
        ERROR_CHECK(dsm_subnet_get_all(&net_key_index, &count));
        m_netkey_handle = dsm_net_key_index_to_subnet_handle(net_key_index);
    
        uint8_t appkey[NRF_MESH_KEY_SIZE] = {0};
        ERROR_CHECK(dsm_appkey_add(0, m_netkey_handle, appkey, &m_appkey_handle));
        ERROR_CHECK(dsm_address_publish_add(PROVISIONER_ADDRESS, &m_provisioner_address_handle));
        ERROR_CHECK(access_model_application_bind(m_remote_server.model_handle, m_appkey_handle));
        ERROR_CHECK(access_model_publish_address_set(m_remote_server.model_handle, m_provisioner_address_handle));
        ERROR_CHECK(access_model_publish_application_set(m_remote_server.model_handle, m_appkey_handle));
        ERROR_CHECK(access_model_publish_ttl_set(m_remote_server.model_handle, 6));
        ERROR_CHECK(pb_remote_server_enable(&m_remote_server));
        ERROR_CHECK(pb_remote_server_prov_bearer_set(&m_remote_server, nrf_mesh_prov_bearer_adv_interface_get(&m_prov_bearer_adv)));
    
    // End of Remote Provisioning Stuff---------------------------------------------------------------

    and

    static void start(void)
    {
        rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    
        if (!m_device_provisioned)
        {
            static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
            mesh_provisionee_start_params_t prov_start_params =
            {
                .p_static_data    = static_auth_data,
                .prov_sd_ble_opt_set_cb = NULL,
                .prov_complete_cb = provisioning_complete_cb,
                .prov_device_identification_start_cb =device_identification_start_cb,// NULL, // blink led for User Feedback in pb remote example
                .prov_device_identification_stop_cb = NULL,
                .prov_abort_cb = NULL, // Stop blink Led when aborted
                .p_device_uri = EX_URI_DM_SERVER
            };
            ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
        }
        else
        {
            unicast_address_print();
            // add here remote Provisioning code
            ERROR_CHECK(pb_remote_server_enable(&m_remote_server));
            ERROR_CHECK(pb_remote_server_prov_bearer_set(&m_remote_server, nrf_mesh_prov_bearer_adv_interface_get(&m_prov_bearer_adv)));
            // End remote Provisioning
        }
    

    according to the Breakpoint on pb_remote_server_enable() provisioning_complete_cb() is not called due the Mesh error.

    first run -> error after Provisioning complete

    reboot -> device has  device adress 0x1337 and "m_device_provisioned" is true

    but since pb_remote_server is not properly set up, so i guess,  there is still no function

    first run ( erase mcu done before):

    <t:      11464>, main.c, 1397, Initializing and adding models
    <t:      11468>, main.c,  791, remote Level server handle: 2
    <t:      11472>, main.c,  796, App Level Model handle: 3
    <t:      11476>, main.c,  814, App DTT Model handle: 5
    <t:      11480>, main.c,  821, App Scene Model handle: 7, Element index: 0
    <t:      11528>, main.c, 1439, Data in the persistent memory was corrupted. Device starts as unprovisioned.
    <t:      11532>, main.c, 1440, Reboot device before starting of the provisioning process.
    <t:      16737>, mesh_app_utils.c,   66, Device UUID (raw): 4814A81088874AA89A89EC236FE7D867
    <t:      16741>, mesh_app_utils.c,   67, Device UUID : 4814A810-8887-4AA8-9A89-EC236FE7D867
    <t:      16752>, main.c, 1605, 
    		-------------------------------------------------------------
    		 RTT 1) The brightness of the LED 1 decresses in large steps.
    		 RTT 2) The brightness of the LED 1 incresses in large steps.
    		 RTT 4) Clear all the states to reset the node.
    		-------------------------------------------------------------
    <t:      36884>, app_level.c,  295, SET: Level: 0  delay: 0  tt: 0  req-delta: 0  trans-type: 0
    <t:      36889>, main.c,  773, Transition time: 0, Target level: 0, Transition type: 0
    <t:      36893>, app_level.c,  239, Transition completed: Present-L: 0  Target-L: 0
    <t:    1237849>, main.c, 1407, Mesh device identification started.
    <t:    1268197>, app_error_weak.c,  115, Mesh error 7 at 0x00000000 (:0)

    subseqent runs:

    <t:      11071>, main.c, 1397, Initializing and adding models
    <t:      11074>, main.c,  791, remote Level server handle: 2
    <t:      11078>, main.c,  796, App Level Model handle: 3
    <t:      11082>, main.c,  814, App DTT Model handle: 5
    <t:      11087>, main.c,  821, App Scene Model handle: 7, Element index: 0
    <t:      11140>, main.c, 1316, Node Address: 0x1337 
    <t:      11143>, mesh_app_utils.c,   66, Device UUID (raw): 4814A81088874AA89A89EC236FE7D867
    <t:      11146>, mesh_app_utils.c,   67, Device UUID : 4814A810-8887-4AA8-9A89-EC236FE7D867
    <t:      11173>, main.c, 1605, 
    		-------------------------------------------------------------
    		 RTT 1) The brightness of the LED 1 decresses in large steps.
    		 RTT 2) The brightness of the LED 1 incresses in large steps.
    		 RTT 4) Clear all the states to reset the node.
    		-------------------------------------------------------------
    <t:      11488>, app_level.c,  295, SET: Level: 0  delay: 0  tt: 0  req-delta: 0  trans-type: 0
    <t:      11493>, main.c,  773, Transition time: 0, Target level: 0, Transition type: 0
    <t:      11497>, app_level.c,  239, Transition completed: Present-L: 0  Target-L: 0

Reply
  • Hi Joakim

    Of course:

    According the Dokumentation on:

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v5.0.0%2Fmd_doc_user_guide_modules_provisioning_pb_remote.html

    at the end of the Page.

    main.c

    // Include remote Provisioning
    #include "pb_remote_server.h"
    #include "nrf_mesh_prov_bearer_adv.h"
    //create struct for Server same with
    static pb_remote_server_t         m_remote_server;
    static nrf_mesh_prov_bearer_adv_t m_prov_bearer_adv;
    static dsm_handle_t               m_netkey_handle;
    static dsm_handle_t               m_appkey_handle;
    static dsm_handle_t               m_provisioner_address_handle;

    ..

    pb_remote_server_init():

    static void models_init_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
        //Init all models for Dimming server
        app_model_init();
        // For Remote Provisioner done in app_model_init as well
        

    static void app_model_init(void)
    {
        // add remote Provisioning
        ERROR_CHECK(pb_remote_server_init(&m_remote_server, REMOTE_SERVER_ELEMENT_INDEX));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "remote Level server handle: %d\n",
              m_remote_server.model_handle)
    
        /* Instantiate level server on element index APP_LEVEL_ELEMENT_INDEX */
        ERROR_CHECK(app_level_init(&m_level_server_0, APP_LEVEL_ELEMENT_INDEX));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "App Level Model handle: %d\n",
              m_level_server_0.server.model_handle)
    
        /*Instantiate level client on element index APP_LEVEL_ELEMENT_INDEX*/
        for (uint32_t i = 0; i < 1; ++i)//for (uint32_t i = 0; i < CLIENT_MODEL_INSTANCE_COUNT; ++i)
        {

    pb_remote_server_enable()

    pb_remote_server_prov_bearer_set():

    static void provisioning_complete_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Successfully provisioned\n");
    
    //Remote Provisioning Stuff------------------------------------------------------------------
        unicast_address_print();
        //hal_led_blink_stop();
        //hal_led_mask_set(HAL_LED_MASK, LED_MASK_STATE_OFF);
        //hal_led_blink_ms(HAL_LED_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_PROV);
        /* TODO: This should be handled by the configuration server model. */
        mesh_key_index_t net_key_index;
        uint32_t count = 1;
        ERROR_CHECK(dsm_subnet_get_all(&net_key_index, &count));
        m_netkey_handle = dsm_net_key_index_to_subnet_handle(net_key_index);
    
        uint8_t appkey[NRF_MESH_KEY_SIZE] = {0};
        ERROR_CHECK(dsm_appkey_add(0, m_netkey_handle, appkey, &m_appkey_handle));
        ERROR_CHECK(dsm_address_publish_add(PROVISIONER_ADDRESS, &m_provisioner_address_handle));
        ERROR_CHECK(access_model_application_bind(m_remote_server.model_handle, m_appkey_handle));
        ERROR_CHECK(access_model_publish_address_set(m_remote_server.model_handle, m_provisioner_address_handle));
        ERROR_CHECK(access_model_publish_application_set(m_remote_server.model_handle, m_appkey_handle));
        ERROR_CHECK(access_model_publish_ttl_set(m_remote_server.model_handle, 6));
        ERROR_CHECK(pb_remote_server_enable(&m_remote_server));
        ERROR_CHECK(pb_remote_server_prov_bearer_set(&m_remote_server, nrf_mesh_prov_bearer_adv_interface_get(&m_prov_bearer_adv)));
    
    // End of Remote Provisioning Stuff---------------------------------------------------------------

    and

    static void start(void)
    {
        rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    
        if (!m_device_provisioned)
        {
            static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
            mesh_provisionee_start_params_t prov_start_params =
            {
                .p_static_data    = static_auth_data,
                .prov_sd_ble_opt_set_cb = NULL,
                .prov_complete_cb = provisioning_complete_cb,
                .prov_device_identification_start_cb =device_identification_start_cb,// NULL, // blink led for User Feedback in pb remote example
                .prov_device_identification_stop_cb = NULL,
                .prov_abort_cb = NULL, // Stop blink Led when aborted
                .p_device_uri = EX_URI_DM_SERVER
            };
            ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
        }
        else
        {
            unicast_address_print();
            // add here remote Provisioning code
            ERROR_CHECK(pb_remote_server_enable(&m_remote_server));
            ERROR_CHECK(pb_remote_server_prov_bearer_set(&m_remote_server, nrf_mesh_prov_bearer_adv_interface_get(&m_prov_bearer_adv)));
            // End remote Provisioning
        }
    

    according to the Breakpoint on pb_remote_server_enable() provisioning_complete_cb() is not called due the Mesh error.

    first run -> error after Provisioning complete

    reboot -> device has  device adress 0x1337 and "m_device_provisioned" is true

    but since pb_remote_server is not properly set up, so i guess,  there is still no function

    first run ( erase mcu done before):

    <t:      11464>, main.c, 1397, Initializing and adding models
    <t:      11468>, main.c,  791, remote Level server handle: 2
    <t:      11472>, main.c,  796, App Level Model handle: 3
    <t:      11476>, main.c,  814, App DTT Model handle: 5
    <t:      11480>, main.c,  821, App Scene Model handle: 7, Element index: 0
    <t:      11528>, main.c, 1439, Data in the persistent memory was corrupted. Device starts as unprovisioned.
    <t:      11532>, main.c, 1440, Reboot device before starting of the provisioning process.
    <t:      16737>, mesh_app_utils.c,   66, Device UUID (raw): 4814A81088874AA89A89EC236FE7D867
    <t:      16741>, mesh_app_utils.c,   67, Device UUID : 4814A810-8887-4AA8-9A89-EC236FE7D867
    <t:      16752>, main.c, 1605, 
    		-------------------------------------------------------------
    		 RTT 1) The brightness of the LED 1 decresses in large steps.
    		 RTT 2) The brightness of the LED 1 incresses in large steps.
    		 RTT 4) Clear all the states to reset the node.
    		-------------------------------------------------------------
    <t:      36884>, app_level.c,  295, SET: Level: 0  delay: 0  tt: 0  req-delta: 0  trans-type: 0
    <t:      36889>, main.c,  773, Transition time: 0, Target level: 0, Transition type: 0
    <t:      36893>, app_level.c,  239, Transition completed: Present-L: 0  Target-L: 0
    <t:    1237849>, main.c, 1407, Mesh device identification started.
    <t:    1268197>, app_error_weak.c,  115, Mesh error 7 at 0x00000000 (:0)

    subseqent runs:

    <t:      11071>, main.c, 1397, Initializing and adding models
    <t:      11074>, main.c,  791, remote Level server handle: 2
    <t:      11078>, main.c,  796, App Level Model handle: 3
    <t:      11082>, main.c,  814, App DTT Model handle: 5
    <t:      11087>, main.c,  821, App Scene Model handle: 7, Element index: 0
    <t:      11140>, main.c, 1316, Node Address: 0x1337 
    <t:      11143>, mesh_app_utils.c,   66, Device UUID (raw): 4814A81088874AA89A89EC236FE7D867
    <t:      11146>, mesh_app_utils.c,   67, Device UUID : 4814A810-8887-4AA8-9A89-EC236FE7D867
    <t:      11173>, main.c, 1605, 
    		-------------------------------------------------------------
    		 RTT 1) The brightness of the LED 1 decresses in large steps.
    		 RTT 2) The brightness of the LED 1 incresses in large steps.
    		 RTT 4) Clear all the states to reset the node.
    		-------------------------------------------------------------
    <t:      11488>, app_level.c,  295, SET: Level: 0  delay: 0  tt: 0  req-delta: 0  trans-type: 0
    <t:      11493>, main.c,  773, Transition time: 0, Target level: 0, Transition type: 0
    <t:      11497>, app_level.c,  239, Transition completed: Present-L: 0  Target-L: 0

Children
Related