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

is there a zigbee zb_zcl_set_attr_val for 32 bit bitmasks?

Hi, I'd like to set the alarm state of a minimal power configuration cluster that only has the attributes "remaining battery percentage" and "battery alarm id".

However the function I'd normally use zb_zcl_set_attr_val is only working on uint8_t datatypes, the alarm state is uint32_t.

I'd prefer to not use the threshold registers since the evaluation of battery low is done in another part of the system and I'd like the reports to be consistent, triggering at the same time.

Here is my power config cluster definition, I have put it as a part of the door lock cluster list.

#define ZB_ZCL_POWER_CONFIG_BATTERY_ATTRIB_LIST_MIN(bat_num,   \
    remaining, alarm_state)                                    \
  ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_REMAINING_ID(remaining, bat_num), \
  ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_STATE_ID(alarm_state, bat_num), \

#define ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_MIN(attr_list,   \
    remaining, alarm_state)                                              \
  ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list)                            \
  ZB_ZCL_POWER_CONFIG_BATTERY_ATTRIB_LIST_MIN(,                          \
    remaining, alarm_state)                                              \
  ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST

Parents
  • Hello,

    Is there a way for me to reproduce this?

    Do you have a project with a Zigbee node that has the Battery cluster?

    Have you tried to write to it using the Zigbee Cluster?

  • Hi, thanks for looking into this.

    Is there a way for me to reproduce this?

    Not easily, I'd prefer if we could pingpong a few basic questions first.

    My project is based on the multiprotocol doorlock example in sdk 4.0.0 and I am using SDK 16.0 to fill in the gaps to make it compile. Changes that I have meade includes moving the application out of the sdk-directory structure and I am using make and gcc to build it.

    Have you tried to write to it using the Zigbee Cluster?

    That is the question I guess, I do not know how to do this properly.

    Here is the code I am using today for the remaining percentage which works:

    ...
    
    typedef struct
    {
        uint8_t percentage_remaining_x2;
        uint32_t alarm_state;
    } power_config_state_t;
    
    ...
    
    typedef struct door_lock_ctx_s
    {
        door_lock_configuration_t         configuration;
        zb_zcl_basic_attrs_ext_t          basic_attr;
        zb_zcl_identify_attrs_t           identify_attr;
        zb_zcl_scenes_attrs_t             scenes_attr;
        zb_zcl_groups_attrs_t             groups_attr;
        zb_zcl_door_lock_attrs_extended_t door_lock_attr;
        power_config_state_t              battery;
    } door_lock_ctx_t;
    
    static door_lock_ctx_t m_dev_ctx;
    
    ...
    
    void radio_iic_cb_battery_status(radio_iic_percentage_t percent, bool battery_is_low)
    {
        NRF_LOG_INFO("main got battery status from radio_iic %d%%, %s", percent, battery_is_low ? "LOW":"ok");
    
        m_dev_ctx.battery.percentage_remaining_x2 = percent * 2;
        m_dev_ctx.battery.alarm_state = battery_is_low ? ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE1_MIN_THRESHOLD : 0;
    
        UNUSED_RETURN_VALUE(zb_zcl_set_attr_val(DOOR_LOCK_ENDPOINT,
                                                ZB_ZCL_CLUSTER_ID_POWER_CONFIG,
                                                ZB_ZCL_CLUSTER_SERVER_ROLE,
                                                ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_REMAINING_ID,
                                                &m_dev_ctx.battery.percentage_remaining_x2,
                                                ZB_FALSE));
    
        // UNUSED_RETURN_VALUE(zb_zcl_set_attr_val(DOOR_LOCK_ENDPOINT,
        //                                         ZB_ZCL_CLUSTER_ID_POWER_CONFIG,
        //                                         ZB_ZCL_CLUSTER_SERVER_ROLE,
        //                                         ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_STATE_ID,
        //                                         &m_dev_ctx.battery.alarm_state,
        //                                         ZB_FALSE));
    }

    Note that the commented row at the end is how I expected it to work with the alarm_state but that line does not compile because of the datatype of alarm_state. So my question is what to do instead to notify the stack that the new value should be reported.

  • Hello,

    I agree, but we don't have a ton of examples, so I don't know if we have anything that would match the issue that you describe, with a cluster containing a 32bit value. I can't tell from the snippets that you have included whether it is set up correctly or not. What does zb_zcl_set_attr_val() return inside radio_iic_cb_battery_status? Is the value updated? How do you check whether the value is updated or not?

    BR,

    Edvin

Reply
  • Hello,

    I agree, but we don't have a ton of examples, so I don't know if we have anything that would match the issue that you describe, with a cluster containing a 32bit value. I can't tell from the snippets that you have included whether it is set up correctly or not. What does zb_zcl_set_attr_val() return inside radio_iic_cb_battery_status? Is the value updated? How do you check whether the value is updated or not?

    BR,

    Edvin

Children
Related