- 实现 MIoT 客户端核心功能(MQTT 连接、设备管理、属性读写) - 支持云端 API 调用与局域网设备发现(mDNS) - 集成国际化(i18n)多语言支持 - 添加 MIoT 设备规约解析器(spec_parser) - 包含单元测试与使用示例
31 lines
708 B
Markdown
31 lines
708 B
Markdown
# R2-03 — spec_parser.go: 属性访问器
|
|
|
|
## 缺失方法
|
|
|
|
`MIoTSpecProperty` 缺少 `writable / readable / notifiable` 三个布尔访问器。
|
|
|
|
Python 中通过 `access` 属性 setter 自动设置:
|
|
```python
|
|
@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`
|
|
|
|
添加:
|
|
```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 { ... }
|
|
```
|