refactor: 重构 token 管理,新增 NATS adapter 和多示例

按照 TOKEN_REFACTOR.md / FIX_CONFIG.md 方案重构核心层:
- miot: Init() 优先读 storage token,新增 RefreshAuthInfo() 和刷新回调
- xiaomi: Config 改用 AuthInfo 结构体(含 UUID/UID/DataDir/OnTokenRefreshed)
- xiaomi: NewClient(ctx, Config) 新签名,新增 RefreshToken(),后台自动刷新
- xiaomi/devices: 设备控制接口重构
- 新增示例 12_ac_subscribe,其余示例适配新 Config
This commit is contained in:
2026-06-30 12:16:49 +08:00
parent a3d94c4b9f
commit 8ffc9e4e44
33 changed files with 1019 additions and 593 deletions
+3 -1
View File
@@ -33,7 +33,9 @@ const (
MIHOME_HTTP_API_TIMEOUT = 30
MIHOME_MQTT_KEEPALIVE = 60
// seconds, 3 days
MIHOME_CERT_EXPIRE_MARGIN = 3600 * 24 * 3
MIHOME_CERT_EXPIRE_MARGIN = 3600 * 24 * 3
// seconds, 1 hour — token 过期前刷新(比 Python 60s 更保守)
MIHOME_REFRESH_THRESHOLD = 3600 * 6
NETWORK_REFRESH_INTERVAL = 30
// seconds, 14 days
SPEC_STD_LIB_EFFECTIVE_TIME = 3600 * 24 * 14