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
  • Hi Manju_rn,

    You can find the "former" solution based on Zigbee Multi Sensor Example. It provides the following two features with corresponding codes:

    1. bind configuration from the server.
      void bind_req(zb_bufid_t bufid) {
        zb_ieee_addr_t src_nwk_addr;
        zb_ieee_addr_t dst_nwk_addr[8] = {0x3f, 0x50, 0x87, 0x65, 0x15, 0x36, 0xce, 0xf4};
      
        NRF_LOG_INFO("Bind request configuration");
        zb_osif_get_ieee_eui64(src_nwk_addr);
      
        bufid = zb_buf_get_out();
        zb_apsme_binding_req_t *req;
        req = ZB_BUF_GET_PARAM(bufid, zb_apsme_binding_req_t);
        ZB_MEMCPY(&req->src_addr, src_nwk_addr, sizeof(zb_ieee_addr_t));
        req->src_endpoint = MULTI_SENSOR_ENDPOINT;
        req->clusterid = ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
        req->addr_mode = ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
        ZB_MEMCPY(&req->dst_addr.addr_long, &dst_nwk_addr, sizeof(zb_ieee_addr_t));
        req->dst_endpoint = 64;
        zb_apsme_bind_request(bufid);
      }
    2. report configuration from the server. 
      void configure_reporting_locally(void)
      {
        zb_zcl_reporting_info_t rep_info;
        memset(&rep_info, 0, sizeof(rep_info));
      
        rep_info.direction      = ZB_ZCL_CONFIGURE_REPORTING_SEND_REPORT;
        rep_info.ep             = MULTI_SENSOR_ENDPOINT;
        rep_info.cluster_id     = ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
        rep_info.cluster_role   = ZB_ZCL_CLUSTER_SERVER_ROLE;
        rep_info.attr_id        = ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID;
      
        rep_info.u.send_info.min_interval = 1;
        rep_info.u.send_info.max_interval = 0;
        rep_info.u.send_info.delta.u8     = 1;
         
         rep_info.dst.short_addr = 0x0000 ; //Hex 
        rep_info.dst.endpoint   = 64 ;     //Decimal 
        rep_info.dst.profile_id = ZB_AF_HA_PROFILE_ID ;
      
        zb_zcl_put_reporting_info(&rep_info,ZB_TRUE);
      
      } 

    multi_sensor_server_self_bind_report_config.zip

    Best regards,

    Charlie

Reply
  • Hi Manju_rn,

    You can find the "former" solution based on Zigbee Multi Sensor Example. It provides the following two features with corresponding codes:

    1. bind configuration from the server.
      void bind_req(zb_bufid_t bufid) {
        zb_ieee_addr_t src_nwk_addr;
        zb_ieee_addr_t dst_nwk_addr[8] = {0x3f, 0x50, 0x87, 0x65, 0x15, 0x36, 0xce, 0xf4};
      
        NRF_LOG_INFO("Bind request configuration");
        zb_osif_get_ieee_eui64(src_nwk_addr);
      
        bufid = zb_buf_get_out();
        zb_apsme_binding_req_t *req;
        req = ZB_BUF_GET_PARAM(bufid, zb_apsme_binding_req_t);
        ZB_MEMCPY(&req->src_addr, src_nwk_addr, sizeof(zb_ieee_addr_t));
        req->src_endpoint = MULTI_SENSOR_ENDPOINT;
        req->clusterid = ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
        req->addr_mode = ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
        ZB_MEMCPY(&req->dst_addr.addr_long, &dst_nwk_addr, sizeof(zb_ieee_addr_t));
        req->dst_endpoint = 64;
        zb_apsme_bind_request(bufid);
      }
    2. report configuration from the server. 
      void configure_reporting_locally(void)
      {
        zb_zcl_reporting_info_t rep_info;
        memset(&rep_info, 0, sizeof(rep_info));
      
        rep_info.direction      = ZB_ZCL_CONFIGURE_REPORTING_SEND_REPORT;
        rep_info.ep             = MULTI_SENSOR_ENDPOINT;
        rep_info.cluster_id     = ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
        rep_info.cluster_role   = ZB_ZCL_CLUSTER_SERVER_ROLE;
        rep_info.attr_id        = ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID;
      
        rep_info.u.send_info.min_interval = 1;
        rep_info.u.send_info.max_interval = 0;
        rep_info.u.send_info.delta.u8     = 1;
         
         rep_info.dst.short_addr = 0x0000 ; //Hex 
        rep_info.dst.endpoint   = 64 ;     //Decimal 
        rep_info.dst.profile_id = ZB_AF_HA_PROFILE_ID ;
      
        zb_zcl_put_reporting_info(&rep_info,ZB_TRUE);
      
      } 

    multi_sensor_server_self_bind_report_config.zip

    Best regards,

    Charlie

Children
No Data
Related