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

adding second element to a light control server node mesh example

Hi, I'm trying to add another element with a simple onoff model to control a second LED on the same server node. I get APP_ERROR. I try declaring m_server0, m_server1, generic_get0_cb, generic_get1_cb, etc.. but in that way I would have to call simple_on_off_server_init(&m_server0, 0) and simple_on_off_server_init(&m_server1, 1) in configuration_setup(), but in header function of simple_on_off_server_init its written we should only call it once. What am I missing to add another element with the same simple on off model into it. thanks a lot. Also changed ACCESS_ELEMENT_COUNT

Parents
  • Hi ms3412amo,

    The light control client example is unfortunately not made as a general purpose provisioner as you've discovered. It's assuming that the node it's provisioning is a light control server with only one element and one simple on off server model. In other words, multiple elements and models is supported, it's just not integrated into the provisioner example.

    To make it work for multiple elements and multiple models, there are as Hung pointed out a couple of changes to be made:

    • When the provisioner receives the NRF_MESH_EVT_PROV_CAPS_RECEIVED event, it needs to inspect the num_element variable and store it for the device currently being provisioned. As you may know, when being provisioned a device is assigned a range of unicast addresses: [unicast_start, ..., unicast_start + num_elements - 1]. The provisioner needs to store the a publication address for each of the elements in the newly provisioned node to talk to them.

    • When configuring the device, in the config_client_event_cb(), the CONFIG_OPCODE_COMPOSITION_DATA_STATUS event gives the composition data of the node. It details the structure of the elements and models of the node. This can be used to know what models are present and configure the correct keys and publication state for them.

    I understand that this is a lot to take in, the mesh provisioner can get quite complex. I would advise you to read the How to build a network guide on the infocenter for an introduction to the provisioning and configuration process in Bluetooth Mesh. Otherwise the official Bluetooth Mesh profile specification is not a terrible read.

    Hope this helps,
    Thomas

Reply
  • Hi ms3412amo,

    The light control client example is unfortunately not made as a general purpose provisioner as you've discovered. It's assuming that the node it's provisioning is a light control server with only one element and one simple on off server model. In other words, multiple elements and models is supported, it's just not integrated into the provisioner example.

    To make it work for multiple elements and multiple models, there are as Hung pointed out a couple of changes to be made:

    • When the provisioner receives the NRF_MESH_EVT_PROV_CAPS_RECEIVED event, it needs to inspect the num_element variable and store it for the device currently being provisioned. As you may know, when being provisioned a device is assigned a range of unicast addresses: [unicast_start, ..., unicast_start + num_elements - 1]. The provisioner needs to store the a publication address for each of the elements in the newly provisioned node to talk to them.

    • When configuring the device, in the config_client_event_cb(), the CONFIG_OPCODE_COMPOSITION_DATA_STATUS event gives the composition data of the node. It details the structure of the elements and models of the node. This can be used to know what models are present and configure the correct keys and publication state for them.

    I understand that this is a lot to take in, the mesh provisioner can get quite complex. I would advise you to read the How to build a network guide on the infocenter for an introduction to the provisioning and configuration process in Bluetooth Mesh. Otherwise the official Bluetooth Mesh profile specification is not a terrible read.

    Hope this helps,
    Thomas

Children
Related