- 所有公开 API 改为 completion handler (Result<T, Error>) - 状态通知改为 DuooomiBleSDKDelegate 协议 - 移除 Sendable、@MainActor、AsyncStream、CheckedContinuation - 网络请求改为 URLSession.dataTask 回调 - BLE 通信改为 delegate + 闭包模式 - deployment target 降至 iOS 12.2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
836 B
Swift
28 lines
836 B
Swift
import Foundation
|
||
|
||
public struct VersionInfo: Equatable {
|
||
public let version: String
|
||
/// 命令类型标识,设备可能返回 Int (如 7) 或 String (如 "0x07")
|
||
public let type: String
|
||
}
|
||
|
||
extension VersionInfo: Codable {
|
||
enum CodingKeys: String, CodingKey {
|
||
case version, type
|
||
}
|
||
|
||
public init(from decoder: Decoder) throws {
|
||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||
version = try container.decode(String.self, forKey: .version)
|
||
|
||
// type may come as Int or String from different firmware versions
|
||
if let str = try? container.decode(String.self, forKey: .type) {
|
||
type = str
|
||
} else if let num = try? container.decode(Int.self, forKey: .type) {
|
||
type = "\(num)"
|
||
} else {
|
||
type = ""
|
||
}
|
||
}
|
||
}
|