Feat: 引入 Miot 设备 Mock 机制以支持离线开发与测试#59
Merged
Merged
Conversation
- **新增 Mock 核心类**:引入 `BaseMockMiotDeviceClient` 与 `MockMiotDeviceClient`,支持基于 `specAtt` 自动初始化属性存储,并提供属性读写与动作执行的钩子(Hook)机制。
- **支持异步模拟**:`MockPropertyHook` 支持在协程中执行,以便模拟窗帘电机等设备的异步状态切换。
- **优化 `Urn` 解析**:在解析失败时输出具体的 URN 字符串以便排查。
- **增强 `SpecAtt`**:为 `Property` 添加 `getDefaultValue()` 方法,支持根据数据类型自动生成模拟默认值。
- **集成 Mock 逻辑**:
- 在 `DeviceViewModel` 中通过 `MOCK_PREFIX` 识别并自动切换至 `NormalMockMiotDeviceClient`。
- 在 `MainViewModel` 中添加了一个 Mock 窗帘设备示例。
- **UI 改进**:在设备详情页 `activity_device.xml` 中新增设备型号(Model)展示,并清理了部分布局代码。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BaseMockMiotDeviceClient与MockMiotDeviceClient,支持基于specAtt自动初始化属性存储,并提供属性读写与动作执行的钩子(Hook)机制。MockPropertyHook支持在协程中执行,以便模拟窗帘电机等设备的异步状态切换。Urn解析:在解析失败时输出具体的 URN 字符串以便排查。SpecAtt:为Property添加getDefaultValue()方法,支持根据数据类型自动生成模拟默认值。DeviceViewModel中通过MOCK_PREFIX识别并自动切换至NormalMockMiotDeviceClient。MainViewModel中添加了一个 Mock 窗帘设备示例。activity_device.xml中新增设备型号(Model)展示,并清理了部分布局代码。