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

Why is the data type of attr_value field in Read attribute response structure set to uint8_t?

Hello Nordic support,

I have a question regarding the Read Attribute response received after sending Read Attribute request. In the read attribute response structure, I see that the attribute value is an array with one element with data type of uint8_t. 

I am using the read attribute request to get the attribute value of PIROccupiedToUnoccupiedDelay attribute(Attribute Id: 0x0010) in Occupancy sensing cluster (Cluster Id: 0x0406). This attribute value's data type is uint16_t but in the read attribute response structure, the attribute value is uint8_t type. So, when I parse the read attribute response,  even though the cluster Id is the expected value (0x0010), the attribute value that I receive is 0 but I expect a value of 0xF0. 

Below is how I am sending the read attribute request and parsing the response:

void APP_zigbeeGetDelay(uint16_t short_addr, uint16_t ep)
{
  zb_uint8_t * p_cmd_buf;
  zb_bufid_t bufid;
  bufid = zb_buf_get_out();

  ZB_ZCL_GENERAL_INIT_READ_ATTR_REQ(bufid, p_cmd_buf, ZB_ZCL_ENABLE_DEFAULT_RESPONSE);
  ZB_ZCL_GENERAL_ADD_ID_READ_ATTR_REQ(p_cmd_buf, 0x0010);
  ZB_ZCL_GENERAL_SEND_READ_ATTR_REQ(bufid, p_cmd_buf, short_addr,
                                      ZB_APS_ADDR_MODE_16_ENDP_PRESENT, ep,
                                      HA_DEVICE_ENDPOINT, ZB_AF_HA_PROFILE_ID,
                                      ZB_ZCL_CLUSTER_ID_OCCUPANCY_SENSING, read_frame_acked_cb);

}

static zb_void_t read_frame_acked_cb(zb_bufid_t bufid)
{
    zb_zcl_read_attr_res_t * read_attr_resp;
    ZB_ZCL_GENERAL_GET_NEXT_READ_ATTR_RES(bufid, read_attr_resp);

    if (read_attr_resp != NULL)
    {
        if ((read_attr_resp)->status == ZB_ZCL_STATUS_SUCCESS)
        {
            eventPayload_t payload;
            payload.clusterCDinfo.data[0] = (read_attr_resp)->attr_id;
            payload.clusterCDinfo.data[1] = (read_attr_resp)->attr_value[0];
        }
    }
}

Could you please guide me on how I can read uint16_t data type attribute value?

Regards,

Anusha

Related