feat(vd960DBN): offlog TIME_ANCHOR 严格用平台下发 unix_ts

offlog_time_anchor 原丢弃传参内部重取 dev_time_now() (毫秒级误差),
改为 offlog_evt_ts() 直接写入平台下发值, 锚点事件与平台 ts 严格一致。
新增单测 test_time_anchor_exact, 7 例 ALL PASS
This commit is contained in:
wangfq
2026-08-04 18:10:18 +08:00
parent 2b1e888a73
commit 90755bf465
3 changed files with 30 additions and 4 deletions
@@ -212,11 +212,11 @@ static void offlog_write_raw(const OfflogEvt *e)
if (_count < OFFLOG_MAX_RECORDS) _count++;
}
void offlog_evt(uint8_t type, const uint8_t *payload, uint8_t len)
/* 内部: 支持外部指定 unix_ts (TIME_ANCHOR 用平台下发值, 严格一致) */
static void offlog_evt_ts(uint8_t type, const uint8_t *payload, uint8_t len, uint32_t unix_ts)
{
OfflogEvt e;
uint32_t now = mstick();
uint32_t unix_ts = dev_time_now();
if (!_ready) return;
@@ -237,6 +237,11 @@ void offlog_evt(uint8_t type, const uint8_t *payload, uint8_t len)
offlog_write_raw(&e);
}
void offlog_evt(uint8_t type, const uint8_t *payload, uint8_t len)
{
offlog_evt_ts(type, payload, len, dev_time_now());
}
/*===========================================================================
* 便捷事件包装
*===========================================================================*/
@@ -310,8 +315,7 @@ void offlog_coil(uint8_t sub, uint8_t ch, uint32_t value)
void offlog_time_anchor(uint32_t unix_ts)
{
(void)unix_ts; /* 值已过合法性门槛; offlog_evt 内经 dev_time_now() 重新取一致值 */
offlog_evt(OFFLOG_EVT_TIME_ANCHOR, NULL, 0);
offlog_evt_ts(OFFLOG_EVT_TIME_ANCHOR, NULL, 0, unix_ts); /* 严格用平台下发值 */
}
/*===========================================================================