Files
KeyBoard_QT/inc/time_sync_protocol.h

34 lines
1013 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef TIME_SYNC_PROTOCOL_H__
#define TIME_SYNC_PROTOCOL_H__
#include <stdint.h>
#include <zephyr/sys/util.h>
/*
* 统一定义时间同步协议帧格式,方便 BLE/USB 两条链路共享:
*
* byte 0 : version
* byte 1 : flags
* byte 2-3 : timezone_min (little-endian, int16)
* byte 4-11: utc_ms (little-endian, uint64)
* byte 12-15: accuracy_ms (little-endian, uint32)
*/
#define TIME_SYNC_PROTOCOL_VERSION 1U
#define TIME_SYNC_PROTOCOL_PAYLOAD_SIZE 16U
#define TIME_SYNC_PROTOCOL_OFFSET_VERSION 0U
#define TIME_SYNC_PROTOCOL_OFFSET_FLAGS 1U
#define TIME_SYNC_PROTOCOL_OFFSET_TIMEZONE 2U
#define TIME_SYNC_PROTOCOL_OFFSET_UTC_MS 4U
#define TIME_SYNC_PROTOCOL_OFFSET_ACCURACY_MS 12U
/*
* 预留 flags 字段:
* - 当前版本只要求时区字段有效;
* - 后续如果要加 DST、闰秒或来源质量扩展可以继续复用这个字节。
*/
#define TIME_SYNC_PROTOCOL_FLAG_TIMEZONE_VALID BIT(0)
#endif /* TIME_SYNC_PROTOCOL_H__ */