Fix battery quantity/size reporting

The API for reporting information requires a pointer to the data value,
and cannot deal with a constant directly.  The current quantity/size
returned by the device are random values from memory.

Instead move these values into the prst_batt_attrs_t struct and
set their values in prst_zb_attrs_init.
This commit is contained in:
Matthew Dawson 2023-01-30 10:42:39 -05:00
parent 424b471eb8
commit d3bcc13749
No known key found for this signature in database
GPG key ID: 404D7F645F682028
3 changed files with 9 additions and 2 deletions

View file

@ -67,8 +67,8 @@ ZB_ZCL_DECLARE_REL_HUMIDITY_MEASUREMENT_ATTRIB_LIST(
ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(
batt_attr_list,
&dev_ctx.batt_attrs.voltage,
/*battery_size=*/ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_OTHER,
/*battery_quantity=*/1,
/*battery_size=*/&dev_ctx.batt_attrs.size,
/*battery_quantity=*/&dev_ctx.batt_attrs.quantity,
/*battery_rated_voltage=*/NULL,
/*battery_alarm_mask=*/NULL,
/*battery_voltage_min_threshold=*/NULL,

View file

@ -24,6 +24,9 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) {
dev_ctx->basic_attr.hw_version = CONFIG_PRST_ZB_HARDWARE_VERSION;
dev_ctx->batt_attrs.quantity = 1;
dev_ctx->batt_attrs.size = ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_OTHER;
dev_ctx->identify_attr.identify_time =
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;
}

View file

@ -19,6 +19,10 @@ typedef struct {
zb_uint8_t voltage;
// Units of 0.5%. 0x00 (0%) - 0xc8 (100%) (optional, reportable).
zb_uint8_t percentage;
// Whole number of battery cells used to power device
zb_uint8_t quantity;
// Enumeration of battery size
enum zb_zcl_power_config_battery_size_e size;
} prst_batt_attrs_t;
// Soil moisture cluster.