密码协议调试
authorliangzhenying <867174124@qq.com>
Wed, 8 Jan 2025 01:48:20 +0000 (09:48 +0800)
committerliangzhenying <867174124@qq.com>
Wed, 8 Jan 2025 01:48:20 +0000 (09:48 +0800)
IOTBluetooth/IOTBluetooth/Example/Datas.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/IDEFindNavigatorScopes.plist [new file with mode: 0644]
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPassword.swift [new file with mode: 0644]

index 98c64a2..ffdd68a 100644 (file)
@@ -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,"关于本机内容",[]),
index e6b0799..09c1c8a 100644 (file)
@@ -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 */; };
                18EF69782C47A86D00AA0A36 /* IBTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBTools.swift; sourceTree = "<group>"; };
                18EFF59A2C080F14001B1E0E /* IBUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBUserInfo.swift; sourceTree = "<group>"; };
                3F6A07C42D2D06D600F4122A /* MixTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MixTools.framework; sourceTree = "<group>"; };
+               3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBPassword.swift; sourceTree = "<group>"; };
                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 = "<group>"; };
                8A0A39C52B980C88006A3B18 /* IBluetooth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IBluetooth.swift; sourceTree = "<group>"; };
                                180220CD2C2D5D560090D34A /* IBAiResponse.swift */,
                                1849DC902BECD131002C2D2D /* IBCode.swift */,
                                182DDFD32C5CE68900D44D37 /* IBAiValid.swift */,
+                               3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */,
                        );
                        path = Models;
                        sourceTree = "<group>";
                                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 (file)
index 0000000..5dd5da8
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array/>
+</plist>
index 84ebf94..aca58d4 100644 (file)
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
index 0801421..209fb35 100644 (file)
@@ -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)
index e414359..de9edb8 100644 (file)
@@ -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..<psd.count{
+                let start = psd.index(psd.startIndex, offsetBy: i)
+                let end = psd.index(psd.startIndex, offsetBy: i+1)
+                let num = psd[start..<end]
+                if let n = UInt8(num){
+                    data = data + [n]
+                }
+            }
+        }
+
+        
+        return data
+    }
+}
+
 struct IBUserInfoChecker: IBChecker {
     static func check(_ parameters: [IBParameter]) -> [UInt8] {
         guard case let .userInfo(value) = parameters[.userInfo] else { fatalError("缺少参数: userInfo") }
index 853f8a4..c27b866 100644 (file)
@@ -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
         }
     }
 }
index f77524f..b24bf46 100644 (file)
@@ -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 (file)
index 0000000..651b4e8
--- /dev/null
@@ -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
+    }
+}