From: liangzhenying <867174124@qq.com> Date: Wed, 8 Jan 2025 01:48:20 +0000 (+0800) Subject: 密码协议调试 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=1a222597081c727aa2c0e9c71d9e29f1c70c4837;p=mirrors%2FIOTBluetooth-iOS.git 密码协议调试 --- diff --git a/IOTBluetooth/IOTBluetooth/Example/Datas.swift b/IOTBluetooth/IOTBluetooth/Example/Datas.swift index 98c64a2..ffdd68a 100644 --- a/IOTBluetooth/IOTBluetooth/Example/Datas.swift +++ b/IOTBluetooth/IOTBluetooth/Example/Datas.swift @@ -11,6 +11,12 @@ import IOTBluetooth let datas: [(ability: IBAbility, label: String, parameters: [IBParameter])] = [ + + + (.getPasssword,"获取密码",[]), + (.setPasssword,"启用密码",[.setPassword(IBPassword(type: 1, password: "123456"))]), + (.setPasssword,"删除密码",[.setPassword(IBPassword(type: 0, password: ""))]), + (.userData,"设置用户数据",[.userInfo(IBUserInfo())]), (.language, "设置语言", [.language(.chinese)]), (.about,"关于本机内容",[]), diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj index e6b0799..09c1c8a 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj @@ -61,6 +61,7 @@ 18EF697A2C47A86D00AA0A36 /* IBTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69782C47A86D00AA0A36 /* IBTools.swift */; }; 18EFF59B2C080F14001B1E0E /* IBUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EFF59A2C080F14001B1E0E /* IBUserInfo.swift */; }; 3F6A07C52D2D06D600F4122A /* MixTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F6A07C42D2D06D600F4122A /* MixTools.framework */; }; + 3F6A07CC2D2D2C3F00F4122A /* IBPassword.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */; }; 8A0A39BF2B980BEF006A3B18 /* IOTBluetooth.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A0A39BE2B980BEF006A3B18 /* IOTBluetooth.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8A0A39C62B980C88006A3B18 /* IBluetooth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A0A39C52B980C88006A3B18 /* IBluetooth.swift */; }; 8A0A39C92B980CC2006A3B18 /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A0A39C82B980CC2006A3B18 /* CoreBluetooth.framework */; }; @@ -181,6 +182,7 @@ 18EF69782C47A86D00AA0A36 /* IBTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBTools.swift; sourceTree = ""; }; 18EFF59A2C080F14001B1E0E /* IBUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBUserInfo.swift; sourceTree = ""; }; 3F6A07C42D2D06D600F4122A /* MixTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MixTools.framework; sourceTree = ""; }; + 3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBPassword.swift; sourceTree = ""; }; 8A0A39BB2B980BEF006A3B18 /* IOTBluetooth.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = IOTBluetooth.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8A0A39BE2B980BEF006A3B18 /* IOTBluetooth.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOTBluetooth.h; sourceTree = ""; }; 8A0A39C52B980C88006A3B18 /* IBluetooth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IBluetooth.swift; sourceTree = ""; }; @@ -402,6 +404,7 @@ 180220CD2C2D5D560090D34A /* IBAiResponse.swift */, 1849DC902BECD131002C2D2D /* IBCode.swift */, 182DDFD32C5CE68900D44D37 /* IBAiValid.swift */, + 3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */, ); path = Models; sourceTree = ""; @@ -547,6 +550,7 @@ 180B01982BFC831300524729 /* IBHistoryHeartRate.swift in Sources */, 189C158D2C05F58A00676A80 /* IBHistoryBloodOxygen.swift in Sources */, 8A79D2272BA433330096A98C /* IBNotify.swift in Sources */, + 3F6A07CC2D2D2C3F00F4122A /* IBPassword.swift in Sources */, 8A0A39D42B980E93006A3B18 /* Any.swift in Sources */, 1849DC912BECD131002C2D2D /* IBCode.swift in Sources */, 1839DBD02C14442200E33B6E /* IBFetchFile.swift in Sources */, diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/IDEFindNavigatorScopes.plist b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/IDEFindNavigatorScopes.plist new file mode 100644 index 0000000..5dd5da8 --- /dev/null +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/IDEFindNavigatorScopes.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate index 84ebf94..aca58d4 100644 Binary files a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift index 0801421..209fb35 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift @@ -82,6 +82,14 @@ extension IBAbility { } public extension IBAbility { + /// 获取手表密码` + /// - Returns: ``Int`` \ + /// Read from ``IBResponse``.value + static let getPasssword = IBAbility.short.id(0x2f).parser(IBGetPasswordParser.self) + /// 设置手表密码 + /// - Parameter setPassword: see ``IBPassword`` + static let setPasssword = IBAbility.long.id(0x1c).parser(IBGeneralParser.self).checker(IBSetPasswordChecker.self) + /// 设置用户数据 /// - Parameter userInfo: see ``IBUserInfo`` static let userData = IBAbility.long.id(0x01).parser(IBGeneralParser.self).checker(IBUserInfoChecker.self) diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift index e414359..de9edb8 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift @@ -262,6 +262,29 @@ struct IBScreenChecker: IBChecker { } } } +struct IBSetPasswordChecker: IBChecker { + static func check(_ parameters: [IBParameter]) -> [UInt8] { + guard case let .setPassword(value) = parameters[.setPassword] else { fatalError("缺少参数: SetPassword") } + + Logger.log(value.description) + var psd = value.password + var data:[UInt8] = [UInt8(value.type)] + if value.type == 1 { + for i in 0.. [UInt8] { guard case let .userInfo(value) = parameters[.userInfo] else { fatalError("缺少参数: userInfo") } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift index 853f8a4..c27b866 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift @@ -39,6 +39,8 @@ enum IBKey: String { case fetchFils = "fetchFils" case aiValid = "aiValid" case aiResponse = "aiResponse" + + case setPassword = "setPassword" } /// 参数 @@ -105,6 +107,8 @@ public enum IBParameter { case aiValid(IBAiValid) /// 发送Ai回应内容 case aiResponse(IBAiResponse) + /// 设置密码 + case setPassword(IBPassword) var key: IBKey { switch self { @@ -139,6 +143,7 @@ public enum IBParameter { case .fetchFils(_): return .fetchFils case .aiValid(_): return .aiValid case .aiResponse(_): return .aiResponse + case .setPassword(_): return .setPassword } } } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift index f77524f..b24bf46 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift @@ -70,6 +70,14 @@ struct IBGeneralParser: IBParser { return .response.code(code == 1 ? .success:.failure) } } +/// 获取密码 +struct IBGetPasswordParser: IBParser { + static func parse(_ data: Data) -> IBResponse { + let code = dataPacket(data).int + let desc = code == 0 ? "不启用":"启用" + return .response.code(.success).value(code).message(desc) + } +} struct IBTakePhotoParser: IBParser { static func parse(_ data: Data) -> IBResponse { let code = dataPacket(data).int diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPassword.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPassword.swift new file mode 100644 index 0000000..651b4e8 --- /dev/null +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPassword.swift @@ -0,0 +1,28 @@ +// +// IBPassword.swift +// IOTBluetooth +// +// Created by liangshi on 2025/1/7. +// + + +import Foundation +/// 关于本机模型 +public class IBPassword:Codable { + /// 0不启用,1启用 + public var type: Int = 0 + /// 密码 + public var password: String = "" + + public init() { } + + public init(type:Int,password:String) { + self.type = type + self.password = password + } + + var description: String { + let str = "IBPassword(type: \(type),password:\(password))" + return str + } +}