This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF BLE Mesh SDK: Combine provisioner role with the Mesh client (provisionee) role

Hi,

I am working on an application using the nrf52 sdk v15 and nrf Mesh sdk v2.1.1 on nrf52840 PDK. Starting from the nrf5_SDK_for_Mesh_v2.1.1_src\examples\sdk_coexist\ble_app_uart_coexist example, I able to communicate the light switch mesh nodes from my existing BLE Gatt application. The mesh nodes are provisioned by nrf5_SDK_for_Mesh_v2.1.1_src\examples\light_switch\provisioner demo application.

As a next step, I would like to combine the Mesh client role with the Mesh provisioner role. That means, nrf52 application is able to switch between the provisioner and client (privisionee) roles. When in provisional role, it provisions few server nodes and eventually configures itself as client node in the same network and switch (reboot) to client role. Is it supported in the standard (and nrf Mesh SDK) ? Any pointers to some documentation or source code examples are much appreciated.

Parents
  • Hi,

    Yes, it is certainly possible to combine the client role and provisioner role into one application. If you look at the light switch example from Mesh SDK v1.0.x, you will find that the provisioner and the client node were the same. I have attached Mesh SDK v1.0.1, have a look at the light switch client example.

    nrf5_SDK_for_Mesh_v1.0.1_src.zip

  • Hi, Mttrin

    I am doing same thing, to move Provisioner Feature to Proxy_Client node in Mesh_SDK 2.1.1 . I didn;t use soft_device init in Provisioner example. actually, I tried,  conflict with  that of Proxy_client example where softdevice is already started properly.

    See "mesh_init" ,   "initialize" ,  "start" and "debug_output" in the last.

    From the output, I can see "self_provision" is performed during mesh_init, but meet assert problem when start mesh_stack.

    I checked the code of  "nrf_mesh_enable();" looks like  assert came from : 


    void scanner_enable(void)
    {
    NRF_MESH_ASSERT(m_scanner.state != SCANNER_STATE_UNINITIALIZED);

    But I did see any place in Provisoner Example  to set scanner state.  

    Could you give me some advice how to move?

    Thanks

    Brent 

    static void mesh_init(void)
    {
    bool device_provisioned;
    mesh_stack_init_params_t init_params =
    {
    .core.irq_priority = NRF_MESH_IRQ_PRIORITY_LOWEST,
    .core.lfclksrc = DEV_BOARD_LF_CLK_CFG,
    // .core.p_uuid = m_client_node_uuid,
    .models.models_init_cb = models_init_cb,
    .models.config_server_cb = app_config_server_event_cb
    };

    ERROR_CHECK(mesh_stack_init(&init_params, &device_provisioned));

    nrf_mesh_evt_handler_add(&m_mesh_core_event_handler);

    /* Load application configuration, if available */
    m_dev_handles.flash_load_success = app_flash_config_load();

    /* Initialize the provisioner */
    mesh_provisioner_init_params_t m_prov_helper_init_info =
    {
    .p_dev_data = &m_dev_handles,
    .p_nw_data = &m_nw_state,
    .netkey_idx = NETKEY_INDEX,
    .p_data_store_cb = app_data_store_cb,
    .p_prov_success_cb = app_prov_success_cb,
    .p_prov_failed_cb = app_prov_failed_cb
    };
    prov_helper_init(&m_prov_helper_init_info);

    if (!device_provisioned)
    {
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setup defaults: Adding keys, addresses, and bindings \n");

    prov_helper_provision_self();
    app_default_models_bind_setup();
    access_flash_config_store();
    app_data_store_cb();
    }
    else
    {
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Restored: Handles \n");
    prov_helper_device_handles_load();
    }

    node_setup_cb_set(app_config_successful_cb, app_config_failed_cb);
    }

    static void initialize(void)
    {

    __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Light Switch Proxy Client Demo -----\n");


    #if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
    #endif


    ERROR_CHECK(app_timer_init());
    hal_leds_init();

    #if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
    #endif
    uint32_t err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    uint32_t ram_start = 0;
    /* Set the default configuration (as defined through sdk_config.h). */
    err_code = nrf_sdh_ble_default_cfg_set(MESH_SOFTDEVICE_CONN_CFG_TAG, &ram_start);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    gap_params_init();
    conn_params_init();

    mesh_init();

    }

    static void start(void)
    {
    // rtt_input_enable(rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "start mesh stack\n");
    ERROR_CHECK(mesh_stack_start());

    }

    <t: 0>, main.c, 679, ----- BLE Mesh Light Switch Proxy Client Demo -----
    <t: 0>, app_timer.c, 935, ----- app timer inited -----
    <t: 14>, main.c, 633, ----- GAP Init-----
    <t: 18>, main.c, 671, ----- BLE conn_para init-----
    <t: 553>, main.c, 538, Initializing and adding models
    <t: 564>, main.c, 614, Setup defaults: Adding keys, addresses, and bindings
    <t: 726>, provisioner_helper.c, 329, netkey_handle: 0
    <t: 735>, main.c, 506, Model bind
    <t: 737>, main.c, 290, App data store
    <t: 740>, main.c, 727, start mesh stack
    <t: 749>, proxy.c, 836, Proxy Enabled
    <t: 752>, app_error_weak.c, 95, Mesh assert at 0x0002C730 (:0)

  • Can you open a new ticket as this is a different issue?

Reply Children
No Data
Related