【已解决】zigbee 电池电量上报问题
能否帮我看看下面电量上报函数是否有问题?我测试app收不到上报的电量值。不知道是哪有问题?谢谢!
tuya-zigbee-sdk-tlsr8258 ->app->switch->
#define EP_BV 1
zig_report_battery_voltage(EP_BV);(主动上报)
/**
@description: report battery voltage
@param {in} ep: endpoind
@return: none
*/
void zig_report_battery_voltage(uint8_t ep)
{
uint8_t battery_percent;dev_zigbee_read_attribute(
ep,
CLUSTER_POWER_CONFIG_CLUSTER_ID,
ATTR_BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE_ID,
&battery_percent,
sizeof(battery_percent)
);
dev_send_data_t ret_data;
attr_key_value_t *ret_attr = ret_data.data.zg.attr;memset(&ret_data, 0, sizeof(ret_data));
/* Don't care
ret_data.delay_time
ret_data.random_time
ret_data.zcl_id
ret_data.command_type
ret_data.addr.mode
*/
ret_data.command_id = CMD_REPORT_ATTRIBUTES_COMMAND_ID;
ret_data.direction = ZCL_DATA_DIRECTION_SERVER_TO_CLIENT;
ret_data.qos = QOS_0;ret_data.addr.type.gw.src_ep = ep;
ret_data.addr.type.gw.cluster_id = CLUSTER_POWER_CONFIG_CLUSTER_ID;
ret_attr[0].attr_id = ATTR_BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE_ID;
ret_attr[0].type = ATTR_INT8U_ATTRIBUTE_TYPE;
ret_attr[0].value_size = 1;
ret_attr[0].value[0] = battery_percent;
ret_data.data.zg.attr_sum++;
dev_zigbee_send_data(&ret_data, NULL, 2000);app_print("battery_percent= %d", battery_percent);
}