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

ZigBee dimmable light on/off attribute reporting

Hi,

I am trying to implement the attribute reporting for a zigbee dimmable light device, reporting to the coordinator.

The code is based on the zigbee\light_control example and I am using the function light_switch_send_on_off() in the light_switch example to send commands to the bulb. I have declared dimmable light attributes and clusters in the same way as light_bulb example.

I am using these two function to start the reporting for the on/off attribute and to check if it is working:

zb_err_code = zb_zcl_start_attr_reporting(HA_DIMMABLE_LIGHT_ENDPOINT, ZB_ZCL_CLUSTER_ID_ON_OFF, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID);

attr_reporting = zcl_is_attr_reported(HA_DIMMABLE_LIGHT_ENDPOINT, ZB_ZCL_CLUSTER_ID_ON_OFF, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID);

but the first function returns an error code while the second returns 0. How can I solve this?

Maybe the reason is that I have not configured the report. In that case, can you explained me how to do? I have read this page but I couldn't understand how can I do:

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.thread_zigbee.v1.0.0%2Fgroup__cfg__reporting__cmd.html

Thank you in advance.

Laura

  • Hi Laura,

    You are correct in that you must configure attribute reporting first. 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:

    typedef struct {
        zb_uint16_t profile_id;
        zb_uint16_t cluster_id;
        zb_uint16_t attr_id;
        zb_uint8_t  attr_type;
        zb_uint16_t interval_min;
        zb_uint16_t interval_max;
        zb_addr_u   remote_node;
        addr_type_t remote_addr_mode;
        zb_uint8_t  remote_ep;
    } configure_reporting_req_t;
    
    
    
    static void configure_attr_reporting(light_switch_ctx_t m_device_ctx){
        zb_bufid_t                  bufid;
        configure_reporting_req_t   req;
        zb_uint8_t                * cmd_ptr;
        
        req.profile_id = ZB_AF_HA_PROFILE_ID;
        req.cluster_id = ZB_ZCL_CLUSTER_ID_ON_OFF;
        req.attr_id = ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID;
        req.attr_type = ZB_ZCL_ATTR_TYPE_BOOL;
    
        req.interval_min = 1;
        req.interval_max = 60;
    
        req.remote_node.addr_short = m_device_ctx.bulb_params.short_addr;
        req.remote_addr_mode = ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
        req.remote_ep = m_device_ctx.bulb_params.endpoint;
        
        bufid = zb_buf_get_out();
    
        ZB_ZCL_GENERAL_INIT_CONFIGURE_REPORTING_SRV_REQ(bufid,
                                                        cmd_ptr,
                                                        ZB_ZCL_ENABLE_DEFAULT_RESPONSE);
        ZB_ZCL_GENERAL_ADD_SEND_REPORT_CONFIGURE_REPORTING_REQ(cmd_ptr,
                                                               req.attr_id,
                                                               req.attr_type,
                                                               req.interval_min,
                                                               req.interval_max,
                                                               NULL);
        ZB_ZCL_GENERAL_SEND_CONFIGURE_REPORTING_REQ(bufid,
                                                    cmd_ptr,
                                                    req.remote_node,
                                                    req.remote_addr_mode,
                                                    req.remote_ep,
                                                    LIGHT_SWITCH_ENDPOINT,
                                                    req.profile_id,
                                                    req.cluster_id,
                                                    NULL);
    }

    This is implemented on the light switch, so I could get the short address and endpoint of the light bulb using the device context of the light bulb from when the light switch discovers the light bulb, in find_light_bulb(). You can also set the short address directly, or use the long address. If you are using the long address, you must change address mode to ZB_APS_ADDR_MODE_64_ENDP_PRESENT instead.

    Best regards,

    Marte

Related