How to address 2 different elements of the same Node at the same time ?

Hi,

I am trying to create 2 elements with the same vendor model implemented.

My vendor model enables to switch on a pwm_led at a particular power during a given time. I have defined 2 pwm led on my dev kit (nrf52840 devkit) and I defined a vendor model for each of them.

struct led_ctx led_ctx[2] = {
	{
		.led_id = 0,
		.operating_mode = &operating_mode[0],
		.model_srv = BT_MESH_FORCED_WORKING_SRV_INIT(0, &forced_working_state[0])
	},
	{
		.led_id = 1,
		.operating_mode = &operating_mode[1],
		.model_srv = BT_MESH_FORCED_WORKING_SRV_INIT(1, &forced_working_state[1])
	}
};

BT_MESH_MODEL_PUB_DEFINE(forced_working_srv_pub1, NULL, 0);
BT_MESH_MODEL_PUB_DEFINE(forced_working_srv_pub2, NULL, 0);

static struct bt_mesh_elem elements[] = {
	BT_MESH_ELEM(
			1,
		    BT_MESH_MODEL_LIST(
			    BT_MESH_MODEL_CFG_SRV,
			    BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub)),
			BT_MESH_MODEL_LIST(
				BT_MESH_FORCED_WORKING_SRV(&led_ctx[0], &forced_working_srv_pub1))),
	BT_MESH_ELEM(
			2,
		    BT_MESH_MODEL_NONE,
			BT_MESH_MODEL_LIST(
				BT_MESH_FORCED_WORKING_SRV(&led_ctx[1], &forced_working_srv_pub2))),
};

static const struct bt_mesh_comp comp = {
	.cid = VENDOR_ID,
	.elem = elements,
	.elem_count = ARRAY_SIZE(elements),
};

It works fine : when I provision my node I see the 2 elements and each element have an instance of my model. When I send a BT mesh "SET" message to an element I succeed to power on the corresponding LED. But when I try to send a message to "all Nodes" only one of the 2 LED is powered on ... What can I do to address my two elements in the same time ?

I'm sorry if this question has already been asked.

Maureen

  • Hello Elfving,

    thank you for your reply !
    here is what i tried and the results :

    • Using the unicast address of the node : the two elements receive the message
    • Using a group address to which both elements are subscribed : only the primary element receive the message
    • Using a group address to which only one element is subscribed : the corresponding element receive the message (it works for the two elements)

    So I don't understand why my second element doesn't receive the message when I use the same group address for the 2 elements as you say it's managed by the stack...

    I wonder where I can define the element address ? I don't see anything in the nrf mesh app to do this, I can only configure the node address...

    Regards

    Maureen

  • Hello again Maureen,

    This is odd. So at this point you have completely removed all the extra loops and functionality and that you mentioned to make sure the message arrives in the right element, right? All of that is handled by the stack.

    lalum said:
    Using the unicast address of the node : the two elements receive the message

    I believe you mentioned earlier that both of the elements are able to be turned on individually using their unicast addresses. But now it seems that when you send a message to just the primary element of the node (the same as the unicast address of the node) its recieved by both elements? Then somethings changed. Did this change happen after you removed that extra functionality you added?

    lalum said:
    Using a group address to which both elements are subscribed : only the primary element receive the message

    Could you tell me what this group address is? Is it the same as the 'all nodes' group?

    Regards,

    Elfving

Related