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

708 B

R2-03 — spec_parser.go: 属性访问器

缺失方法

MIoTSpecProperty 缺少 writable / readable / notifiable 三个布尔访问器。

Python 中通过 access 属性 setter 自动设置:

@access.setter
def access(self, value: list) -> None:
    self._writable = 'write' in value
    self._readable = 'read' in value
    self._notifiable = 'notify' in value

目标文件

D:\miot\go-miot\spec_parser.go

添加:

func (p *MIoTSpecProperty) Writable() bool {
    for _, a := range p.Access {
        if a == "write" { return true }
    }
    return false
}
func (p *MIoTSpecProperty) Readable() bool { ... }
func (p *MIoTSpecProperty) Notifiable() bool { ... }