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

Zigbee electrical measurement cluster - sending data

Hello,
I'm trying to send some payload via ELECTRICAL_MEASUREMENT cluster.
The sending is realized in the similar way to the zigbee_light_switch example.

I'm sending data to the broadcast addr:

    zb_uint16_t addr = 0xFFFF;
    uint16_t measured_val = 0xABCD;

    NRF_LOG_INFO("Send el measurement command");

    ZB_CUSTOM_EL_MEASUREMENT_SEND_REQ(bufid,
                           addr,
                           ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                           HA_SMART_PLUG_ENDPOINT, //todo
                           HA_SMART_PLUG_ENDPOINT,
                           ZB_AF_HA_PROFILE_ID,
                           ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                           NULL,
                           measured_val);


Where the macro is:
#define ZB_CUSTOM_EL_MEASUREMENT_SEND_REQ(                                                                                                    \
    buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, def_resp, cb, measured_val)                                                             \
{                                                                                                                                             \
  zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer)                                                                                           \
  ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp)                                                                          \
  ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_MEASUREMENT_PROFILE_RESPONSE_COMMAND); \
  ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (measured_val));                                                                                          \
  ZB_ZCL_FINISH_PACKET(buffer, ptr)                                                                                                           \
  ZB_ZCL_SEND_COMMAND_SHORT(                                                                                                                  \
      buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT, cb);                                        \
}


After that I'm trying to find those data in the sniffer.



Cluster ID is correct, Cmd ID is also correct and the measured_val (0xABCD) is visible.

Unfortunatelly the packet seems to be malformed. Any idea what am I doing wrong and how to fix it ?

BR,
Jakub

Parents
  • Hello Jakub,
    Your packet is malformed, because it sends non-manufacturer specific command and the payload is not formatted according to the ZCL specification.

    Please describe which command you would like to send, find it inside the ZCL specification and append all required fields to the packet.

    The command "Get Measurement Profile Response" requires at least 5 fields and there is a macro to construct it correctly: ZB_ZCL_ELECTRICAL_MEASUREMENT_SEND_GET_MEASUREMENT_PROFILE_INFO_RESP.

    BR,
    Tomchy

Reply
  • Hello Jakub,
    Your packet is malformed, because it sends non-manufacturer specific command and the payload is not formatted according to the ZCL specification.

    Please describe which command you would like to send, find it inside the ZCL specification and append all required fields to the packet.

    The command "Get Measurement Profile Response" requires at least 5 fields and there is a macro to construct it correctly: ZB_ZCL_ELECTRICAL_MEASUREMENT_SEND_GET_MEASUREMENT_PROFILE_INFO_RESP.

    BR,
    Tomchy

Children
No Data
Related