|
11 | 11 |
|
12 | 12 | #include "hal/zigbee.h" |
13 | 13 | #include "telink_zigbee_hal.h" |
14 | | -#include "zigbee/battery_cluster.h" |
15 | 14 | #include "zigbee/consts.h" |
16 | 15 |
|
17 | 16 | // Storage for Telink endpoint configuration |
@@ -236,8 +235,32 @@ void telink_zigbee_hal_zcl_init(hal_zigbee_endpoint *endpoints, |
236 | 235 | } |
237 | 236 |
|
238 | 237 | void hal_zigbee_notify_attribute_changed(uint8_t endpoint, uint16_t cluster_id, |
239 | | - uint16_t attribute_id) { |
240 | | - report_handler(); // Trigger reporting if needed |
| 238 | + uint16_t attribute_id, bool immediate) { |
| 239 | + if (immediate) { |
| 240 | + // Send report directly to avoid SDK reporting timers |
| 241 | + // (reportingTimerCb ~100ms) which cause extra wake-ups |
| 242 | + // from deep retention. |
| 243 | + hal_zigbee_send_report_attr(endpoint, cluster_id, attribute_id, |
| 244 | + 0, NULL, 0); |
| 245 | + // Sync prevData in the reporting table so report_handler() in |
| 246 | + // the main loop does not see a stale diff and schedule another |
| 247 | + // reporting timer for the same change. |
| 248 | + reportCfgInfo_t *e = zcl_reportCfgInfoEntryFind(endpoint, |
| 249 | + cluster_id, |
| 250 | + attribute_id); |
| 251 | + if (e) { |
| 252 | + zclAttrInfo_t *a = zcl_findAttribute(endpoint, cluster_id, |
| 253 | + attribute_id); |
| 254 | + if (a) { |
| 255 | + u8 len = zcl_getAttrSize(a->type, a->data); |
| 256 | + if (len > REPORTABLE_CHANGE_MAX_ANALOG_SIZE) |
| 257 | + len = REPORTABLE_CHANGE_MAX_ANALOG_SIZE; |
| 258 | + memcpy(e->prevData, a->data, len); |
| 259 | + } |
| 260 | + } |
| 261 | + } else { |
| 262 | + report_handler(); |
| 263 | + } |
241 | 264 | } |
242 | 265 |
|
243 | 266 | hal_zigbee_status_t hal_zigbee_send_cmd_to_bindings(const hal_zigbee_cmd *cmd) { |
|
0 commit comments