# 第二轮任务提示词 > 子文档在 `go-miot/migration/R2-*.md` ## H1 — spec_parser: eval_expr / value_format / value_precision ``` 目标文件:D:\miot\go-miot\spec_parser.go 详细说明:D:\miot\go-miot\migration\R2-01-spec-properties.md 在 MIoTSpecProperty 上添加 3 个方法: - EvalExpr(srcValue interface{}) — expr 非空且值为 "src_value * 2" 之类简单表达式时求值,否则返回原值 - ValueFormat(value interface{}) — 根据 Format 字段将字符串转为 int/float/bool - ValuePrecision(value interface{}) — 浮点数 round 到 precision 位,int 按 step 对齐 ``` ## H2 — spec_parser: ValueList 查询方法 ``` 目标文件:D:\miot\go-miot\spec_parser.go 详细说明:D:\miot\go-miot\migration\R2-02-spec-valuelist.md 在 MIoTSpecValueList 上添加 5 个方法: - Names() []string / Values() []interface{} / Descriptions() []string - GetValueByDescription(desc string) interface{} - GetDescriptionByValue(value interface{}) string ``` ## H3 — spec_parser: writable/readable/notifiable ``` 目标文件:D:\miot\go-miot\spec_parser.go 详细说明:D:\miot\go-miot\migration\R2-03-spec-accessors.md 在 MIoTSpecProperty 上添加 3 个布尔方法,遍历 Access 字段检查是否含 "write"/"read"/"notify"。 ``` ## H4 — miot_client: sub_device_state / unsub_device_state ``` 目标文件:D:\miot\go-miot\miot_client.go 或 miot_client_sub.go 详细说明:D:\miot\go-miot\migration\R2-04-client-device-state.md 添加 SubDeviceState(did, handler) / UnsubDeviceState(did),管理 device state 订阅列表。 handler 签名:func(did string, state MIoTDeviceState, ctx interface{}) ``` ## H5 — miot_cloud: set_redirect_url ``` 目标文件:D:\miot\go-miot\miot_cloud.go 详细说明:D:\miot\go-miot\migration\R2-05-cloud-oauth-redirect.md 在 MIoTOauthClient 上添加 SetRedirectURL(url string) error,校验非空后更新 redirectURL 字段。 ``` ## M1 — miot_client: 配置属性 ``` 目标文件:D:\miot\go-miot\miot_client.go 详细说明:D:\miot\go-miot\migration\R2-06-client-config.md MIoTClient 结构体添加 7 个字段:ActionDebug, HideNonStandardEntities, DisplayBinaryText, DisplayBinaryBool, CoverDeadZoneWidth, DisplayDevicesChangedNotify, PersistentNotify ``` ## M2 — miot_client: auth/cert 定时刷新 ``` 目标文件:D:\miot\go-miot\miot_client.go 详细说明:D:\miot\go-miot\migration\R2-07-client-auth-refresh.md 添加定时方法: - RequestRefreshAuthInfo(delaySec int) — MIHOME_CERT_EXPIRE_MARGIN 到期前刷新 token - RequestRefreshUserCert(delaySec int) — MIHOME_CERT_EXPIRE_MARGIN 到期前刷新证书 使用 time.AfterFunc 延迟执行。 ``` ## M3 — miot_client: 通知方法 ``` 目标文件:D:\miot\go-miot\miot_client.go 详细说明:D:\miot\go-miot\migration\R2-08-client-notify.md 添加 ShowClientErrorNotify(title, message), ShowDevicesChangedNotify(), ShowCentralStateChangedNotify(connected bool),通过 PersistentNotify 回调输出。 ``` ## M4 — miot_cloud: 单属性获取 ``` 目标文件:D:\miot\go-miot\miot_cloud.go 详细说明:D:\miot\go-miot\migration\R2-09-cloud-single-prop.md GetProp(did string, siid, piid int) — 封装 GetProps([]PropParam{{did,siid,piid}}),返回单结果。 ``` ## M5 — miot_storage: CSR 生成 ``` 目标文件:D:\miot\go-miot\miot_storage.go 详细说明:D:\miot\go-miot\migration\R2-10-14-batch.md(10号) GenUserCSR() — 用 crypto/ed25519 私钥 + x509.CreateCertificateRequest 生成 CSR。 ``` ## M6 — miot_matcher: 查询方法 ``` 目标文件:D:\miot\go-miot\miot_matcher.go 详细说明:D:\miot\go-miot\migration\R2-10-14-batch.md(11号) 添加 IterAllNodes() 迭代器和 Get(topic string) 精确匹配方法。 ``` ## M7 — const.go: CtrlMode.load ``` 目标文件:D:\miot\go-miot\const.go 详细说明:D:\miot\go-miot\migration\R2-10-14-batch.md(12号) ParseCtrlMode(s string) (CtrlMode, error) — "cloud"→CtrlModeCloud, "gateway"→CtrlModeGateway, "lan"→CtrlModeLAN。 ``` ## L1 — 资源: lan/profile_models.yaml ``` 源文件:D:\miot\py-miot\lan\profile_models.yaml 目标路径:D:\miot\go-miot\lan\profile_models.yaml 先 mkdir D:\miot\go-miot\lan,再复制文件。 ``` ## L2 — 资源: specs/ 目录 ``` 源目录:D:\miot\py-miot\specs\ 目标目录:D:\miot\go-miot\specs\ 递归复制全部 6 个文件。 ```