This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Update the BULB_LED (DK_LED4) status in Zigbee Network

I am using the NRF52840-DK and using the Zigbee light bulb example.

1. The DK board successfully connects to the zigbee network - Z2M in this case.

2. I have added an external zigbee button which invokes the DK via Z2M and toggles the BULB_LED (DK_LED4) on the DK successfully.

3. I now want to operate this LED4 also with the onboard DK button - say Button 3.  I have defined this as

   

#define TOGGLE_SWITCH					DK_BTN3_MSK

   and in this function, recognize the button, retrieve the LED setting from context and call the on_off method with inverse value

  

static void button_changed(uint32_t button_state, uint32_t has_changed)
{
    ....
    ....
 	else if (buttons & TOGGLE_SWITCH)
	{
		LOG_INF("Current LED setting is %d", dev_ctx.on_off_attr.on_off);

		if(dev_ctx.on_off_attr.on_off)
		{
			on_off_set_value(0U);
		}
		else
		{
			on_off_set_value(1U);
		}

		LOG_INF("Toggling Completed");
	}
}

4. So the above code successfully toggles the LED4 when the Button 3 on the DK board is pressed.  But that state is not propagated/reported to Zigbee network. I see no activity on the network and no messages received in Z2M. Hence, my external button when pressed again, does not not toggle properly as it has not received the state change event from DK when the button 3 was pressed.

5. I was under the impression that the following code (ZB_ZCL_SET_ATTRIBUTE..) in the on_off_set_value method  should send the updated status to Zigbee network? if it does not, how to specifically send the updated LED status?

static void on_off_set_value(zb_bool_t on)
{
	LOG_INF("Set ON/OFF value: %i", on);

	ZB_ZCL_SET_ATTRIBUTE(
		HA_DIMMABLE_LIGHT_ENDPOINT,
		ZB_ZCL_CLUSTER_ID_ON_OFF,
		ZB_ZCL_CLUSTER_SERVER_ROLE,
		ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
		(zb_uint8_t *)&on,
		ZB_FALSE);

	if (on) {
		level_control_set_value(
			dev_ctx.level_control_attr.current_level);
	} else {
		light_bulb_set_brightness(0U);
	}
}

Parents Reply Children
  • Thanks.  but the example in given link talks about configuring a light switch i.e., "latter" in the below highlighted statement from that conversation.  Is there an example showing the "former" - i.e., configure it on the device that is to report and taking the LightBulb example?

    "you can either configure it on the device that is to report, such as the light bulb, or you can configure it on the device that wants to subscribe to reports from a reporting device. For the latter, you can for example do something like the following:"

Related