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

  • Hi Petter, I'm on client's project, assuming my server is OK. Do I need to change provisioner.c code to access 2 elements in a same node. In main.c access_setup seems ok to me without any change. I try this with 2 devkits, 1 clients(devkitA) controlling 2 servers in the same node(devkitB). I got the first LED working with button0 from devkitA, but I got APP_ERROR code 7 on ERROR_CHECK(status) at the end of button_event_handler when I try button1 to control the second LED (second element in the node). I suspect provisioning not binding the 2 elements to the clients model. I'm almost at a point to try adding a second led in the simpleOnOffModel, with more opcode and callback of opcode to control the other led, but I would prefer to understand adding a element with the same model before customising simpleOnOff model. Thank you

  • Hi ms, Sorry for late response.

    It doesn't seem the current provisioner in the lighting example check for the number of elements (num_components or num_elements) in the capability sent by the provisionee. The number of element is reported back to the provisioner in NRF_MESH_EVT_PROV_CAPS_RECEIVED event (event.params.prov_oob_caps_received.oob_caps.num_elements = p_pdu->num_components;) but doesn't seem this value is used by the provisioner. Also the provisioner doesn't seems to assign the application key to the second server. I will report this issue internally.

  • Hi, thank you for your answer. I finally added more opcode and callback to simple_on_off_model to control more than just an output. It's working fine, but I would like to have to ability to add elements in a node in a near future. I understand the Mesh specification is new and some features still need to be implemented in Nordic Mesh SDK.

  • 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

  • Thank you for this information. It will help for sure.

Related