NRF Connect SDK: Bluetooth mesh, How to bind an existed appkey to a local model?

Dears all, 

When a bluetooth mesh node is done provisioning and added an appkey, I want to bind that appkey to  local models. 

I could not find any API for that.

Can you help me.

Best regards.

  • Hi.

    You can configure the node using the nRF Mesh application after the device has been provisioned.

    Br,
    Joakim

  • Dears,

    Thank you for your prompt response.

    So, that mean there are no api for binding appkey to a local model?

    Best regards.

  • Hi!

    When a bluetooth mesh node is done provisioning and added an appkey

    How are you provisioning your device?

    binhla said:
    So, that mean there are no api for binding appkey to a local model?

    Configuration Client

    The Configuration Client model is a foundation model defined by the Bluetooth mesh specification. It provides functionality for configuring most parameters of a mesh node, including encryption keys, model configuration and feature enabling.

    bt_mesh_cfg_app_key_add()

    Br, 
    Joakim

  • Dears

    How are you provisioning your device?

    I have implement the provisioner on an ESP32 SOC. I also use the nRF Mesh mobile app.

    The Configuration Client model is a foundation model defined by the Bluetooth mesh specification. It provides functionality for configuring most parameters of a mesh node, including encryption keys, model configuration and feature enabling.

    I think the Configuration Client is for the Provisioner, not for the Nodes. 

    What I want is APIs that can be used by the Nodes themselves.

    If the Configuration Client can be implemented on the Nodes and config locally, please imfrom me.

    Best regarads.

  • Dears,

    I just post this for any one that need.

    struct bt_mesh_comp bm_comp = {
        .cid = CONFIG_BT_COMPANY_ID,
        .elem = bm_elements,
        .elem_count = ARRAY_SIZE(bm_elements),
    };
    
    /*****/
    bt_mesh_init(&bm_prov, &bm_comp);

    void app_bm_local_config(void) {
        for (int e_idx=0; e_idx < bm_comp.elem_count; ++e_idx) {
            struct bt_mesh_elem *element = bm_comp.elem + e_idx;
            for (int m_idx = 0; m_idx < element->model_count; ++m_idx) {
                struct bt_mesh_model *model = element->models + m_idx;
                if (model->id == BT_MESH_MODEL_ID_CFG_SRV || model->id == BT_MESH_MODEL_ID_CFG_CLI || 
                    model->id == BT_MESH_MODEL_ID_HEALTH_SRV || model->id == BT_MESH_MODEL_ID_HEALTH_CLI) 
                    continue;
                if (model->keys[0] == 0xFFFF) {
                    model->keys[0] = 0; /*Appkey index is 0*/
                }
                for (int k_idx=0; k_idx < CONFIG_BT_MESH_MODEL_KEY_COUNT; k_idx++) LREP_RAW("%d ", model->keys[k_idx]);
                if (model->pub) {
                    if (model->pub->addr == 0) {
                        model->pub->addr = 0xC000; /*Publish to group address 0xC000*/
                    }
                }
            }
        }
    }

    It worked with me. But It cannot save the configuration so every time the SOC is restart, the app_bm_local_config() must be call

    Best regards.

Related