Files
xiaomihome/miot/migration/R2-10-14-batch.md
T
4566704 3a44cb9e6a feat: 初始化小米 IoT (MIoT) 智能家居 Go 库
- 实现 MIoT 客户端核心功能(MQTT 连接、设备管理、属性读写)
- 支持云端 API 调用与局域网设备发现(mDNS)
- 集成国际化(i18n)多语言支持
- 添加 MIoT 设备规约解析器(spec_parser)
- 包含单元测试与使用示例
2026-06-28 22:05:49 +08:00

1.7 KiB

R2-10 — miot_storage.go: CSR 生成

缺失方法

Python MIoTCert.gen_user_csr():

def gen_user_csr(self) -> str:
    """使用 Ed25519 私钥生成 CSR"""

目标文件

D:\miot\go-miot\miot_storage.go

使用 crypto/ed25519 + crypto/x509.CreateCertificateRequest 生成 CSR。 因依赖 Ed25519 密钥对,需先确保 LoadUserKey/SaveUserKey 已实现。

R2-11 — miot_matcher.go: 匹配器方法

缺失方法

def iter_all_nodes(self) -> Any:  # 遍历所有节点
def get(self, topic: str) -> Optional[Any]:  # 按 topic 获取

目标文件

D:\miot\go-miot\miot_matcher.go

在 MIoTMatcher 上添加 IterAllNodes() iterator 和 Get(topic string) 方法。

R2-12 — const.go: CtrlMode.load

缺失方法

@staticmethod
def load(mode: str) -> 'CtrlMode':
    """从字符串解析控制模式"""

目标文件

D:\miot\go-miot\const.go

func ParseCtrlMode(s string) (CtrlMode, error) {
    switch strings.ToLower(s) {
    case "cloud":   return CtrlModeCloud, nil
    case "gateway": return CtrlModeGateway, nil
    case "lan":     return CtrlModeLAN, nil
    default:        return 0, fmt.Errorf("unknown ctrl mode: %s", s)
    }
}

R2-13 — 资源: lan/profile_models.yaml

缺失文件

复制 D:\miot\py-miot\lan\profile_models.yaml → D:\miot\go-miot\lan\profile_models.yaml

miot_lan.go 可能引用此文件用于设备 profile 映射。

R2-14 — 资源: specs/ 目录

缺失文件

复制 D:\miot\py-miot\specs\ → D:\miot\go-miot\specs\

包含 6 个文件:bool_trans.yaml、multi_lang.json、spec_add.json、spec_filter.yaml、spec_modify.yaml、specv2entity.py。

spec_parser.go 可能引用这些文件用于 SPEC 扩展配置。