- 新增 Flutter 跨平台客户端项目 (clients/flutter/)
- 29 个 Dart 文件: 服务层/状态管理/5个页面/BLE配网
- BLE 蓝牙配网: 扫描设备、写入WiFi凭据、配网状态监听
- HTTP API 客户端: 覆盖全部端点 (播放/场景/WiFi/视频/配置/文件/插件)
- WebSocket 实时通信: 事件流 + 自动重连
- 暗色主题 Material 3 UI, 中文界面
- Android 配置: minSdkVersion 21, BLE/网络权限
- PRD 产品需求文档 + 开发任务看板
- Web UI 添加 APK 下载入口 (routes.rs)
- 下载弹窗 + 二维码 + /download/{filename} 静态文件路由
- BLE 插件增加自动重连循环 (ble/mod.rs)
- BLE 默认设备名修正为 'Showen' (config.rs)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
1.3 KiB
Dart
70 lines
1.3 KiB
Dart
import 'dart:convert';
|
|
|
|
class BleDevice {
|
|
const BleDevice({
|
|
required this.name,
|
|
required this.id,
|
|
required this.rssi,
|
|
});
|
|
|
|
final String name;
|
|
final String id;
|
|
final int rssi;
|
|
}
|
|
|
|
class BleStatus {
|
|
const BleStatus({
|
|
required this.ok,
|
|
required this.action,
|
|
this.state,
|
|
this.error,
|
|
});
|
|
|
|
factory BleStatus.fromJson(Map<String, dynamic> json) {
|
|
return BleStatus(
|
|
ok: json['ok'] == true,
|
|
action: (json['action'] ?? '').toString(),
|
|
state: json['state']?.toString(),
|
|
error: json['error']?.toString(),
|
|
);
|
|
}
|
|
|
|
factory BleStatus.fromRawJson(String source) {
|
|
final dynamic decoded = jsonDecode(source);
|
|
if (decoded is! Map<String, dynamic>) {
|
|
throw const FormatException('BLE status payload is not a JSON object');
|
|
}
|
|
return BleStatus.fromJson(decoded);
|
|
}
|
|
|
|
static const BleStatus idle = BleStatus(ok: true, action: 'idle');
|
|
|
|
final bool ok;
|
|
final String action;
|
|
final String? state;
|
|
final String? error;
|
|
|
|
bool get isQueued => state == 'queued';
|
|
|
|
bool get isSuccess => ok && !isQueued;
|
|
|
|
String get message {
|
|
if ((error ?? '').isNotEmpty) {
|
|
return error!;
|
|
}
|
|
if ((state ?? '').isNotEmpty) {
|
|
return state!;
|
|
}
|
|
return action;
|
|
}
|
|
}
|
|
|
|
enum ProvisioningState {
|
|
scanning,
|
|
connecting,
|
|
writingCredentials,
|
|
connectingWifi,
|
|
success,
|
|
failed,
|
|
}
|