- 实现 MIoT 客户端核心功能(MQTT 连接、设备管理、属性读写) - 支持云端 API 调用与局域网设备发现(mDNS) - 集成国际化(i18n)多语言支持 - 添加 MIoT 设备规约解析器(spec_parser) - 包含单元测试与使用示例
23 lines
610 B
Markdown
23 lines
610 B
Markdown
# R2-04 — miot_client: sub_device_state / unsub_device_state
|
|
|
|
## 缺失方法
|
|
|
|
Python `MIoTClient` 提供设备状态订阅:
|
|
|
|
```python
|
|
def sub_device_state(self, did: str, handler: Callable, handler_ctx: Any = None) -> bool
|
|
def unsub_device_state(self, did: str) -> bool
|
|
```
|
|
|
|
功能:订阅指定 did 的设备在线/离线状态变化通知。
|
|
|
|
## 目标文件
|
|
|
|
`D:\miot\go-miot\miot_client.go` 或 `miot_client_sub.go`
|
|
|
|
添加:
|
|
```go
|
|
func (c *MIoTClient) SubDeviceState(did string, handler func(string, MIoTDeviceState, interface{})) error
|
|
func (c *MIoTClient) UnsubDeviceState(did string) error
|
|
```
|