【已解决】zigbee电量一直不上报
电量一直不上报,请问这是哪里有问题?能否帮我们解决下,谢谢!
tuya-zigbee-sdk-tlsr8258-》tmp_hum_lcd
Code: Select all
"fimwareInfo": {
"name": "tmp_hum_lcd_sensor",
"description": "this is a project",
"version": "1.0.0",
"bv_version": "1.0",
"ic": "TLSR8258F1KET",
"ota_image_type":"0x1602",
"manufacture_id":"0x1002",
"model_id":"TS0201",
"pid": "ncw88jfq",
"manufacture_name": "_TZ3210_",
"module_name":"TL8258"
},
下面是配置函数和上报函数,
/* battery_param parameter config! */
#define BATTERY_REPORT_MINUTE 240
#define BATTERY_MAX_MILLIV 3000
#define BATTERY_MIN_MILLIV 2400
void power_sampler_init(void)
{
battery_cfg_t battery_cfg = {
.cap_first_delay_time = 60,
.cap_waitting_silence_time = 5000,
.cap_max_period_time = BATTERY_REPORT_MINUTE601000,
.cap_max_voltage = BATTERY_MAX_MILLIV,
.cap_min_voltage = BATTERY_MIN_MILLIV,
.adc.adc_type = ADC_TYPE_VDD,
.adc.pos_pin = NULL,
.adc.neg_pin = NULL
};
Code: Select all
battery_table_t battery_table[] = {
BATTERY_DEFAULT_TABLE
};
battery_report_policy_t bat_policy = {
.type = BATTERY_TYPE_DRY_BATTERY,
.level = DEV_BUSY_LEVEL_IDLE,
.report_no_limits_first = TRUE,
.limits = BATTERY_REPORT_DECREASE_LIMITS_20,
.ext_limits = 0
};
hal_battery_config(&battery_cfg, battery_table, get_array_len(battery_table));
hal_battery_report_policy_config(&bat_policy);
dev_config_power_source_type(battery_source); // write power source type
}
/**
@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(
TMP_HUM_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);
}