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

Zigbee: Usage ZB_ZCL_DECLARE_POWER_CONFIG_ATTRIB_LIST macro with single battery

Hi
I have an question about use ZB_ZCL_DECLARE_POWER_CONFIG_ATTRIB_LIST macro in case when only one battery used.

I'm trying to declare Power Configuration like this

/**
 * Power configuration cluster attributes list
 */
typedef struct zb_zcl_power_config_battery_attrs_s
{
    zb_uint8_t voltage;
    zb_uint8_t size;
    zb_uint8_t quantity;
    zb_uint8_t rated_voltage;
    zb_uint8_t alarm_mask;
    zb_uint8_t voltage_min_threshold;
} zb_zcl_power_config_battery_attrs_t;

static zb_zcl_power_config_battery_attrs_t m_power_config_attr_list;

ZB_ZCL_POWER_CONFIG_BATTERY_ATTRIB_LIST(
        power_config_attr_list,
 	&m_power_config_attr_list.voltage,
 	&m_power_config_attr_list.size,
 	&m_power_config_attr_list.quantity,
 	&m_power_config_attr_list.rated_voltage,
 	&m_power_config_attr_list.alarm_mask,
 	&m_power_config_attr_list.voltage_min_threshold 
);

But when build this code I get error from preprocessor

macro "ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID" requires 2 arguments, but only 1 given


When I've investigated what happens when macro expanded I seen that ZB_ZCL_DECLARE_POWER_CONFIG_ATTRIB_LIST uses

ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID, (voltage))

which is expand into

#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID(data_ptr, bat_num) \
{                                                               \
  ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_VOLTAGE_ID,       \
  ZB_ZCL_ATTR_TYPE_U8,                                          \
  ZB_ZCL_ATTR_ACCESS_READ_ONLY,                                 \
  (zb_voidp_t) data_ptr                                         \
} 

So final expression requires battery number but ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID, (voltage)) doesnt suppose battery number.

Anymore if even battery number was assigned in any manner there is no identifier in header file for attribute BatteryVoltage for battery with id 0 or 1...

  /** @brief BatteryVoltage attribute, ZCL spec 3.3.2.2.3.1 */
  ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID               = 0x0020,

  /*! @brief Battery Information 2 attribute set, ZCL spec 3.3.2.2.5 */
  ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_VOLTAGE_ID = 0x0040,

  /*! @brief Battery Information 3 attribute set, ZCL spec 3.3.2.2.7 */
  ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_VOLTAGE_ID = 0x0060,

Parents Reply Children
No Data
Related