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,"关于本机内容",[]),
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 */,
--- /dev/null
+<?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>
}
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)
}
}
}
+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") }
case fetchFils = "fetchFils"
case aiValid = "aiValid"
case aiResponse = "aiResponse"
+
+ case setPassword = "setPassword"
}
/// 参数
case aiValid(IBAiValid)
/// 发送Ai回应内容
case aiResponse(IBAiResponse)
+ /// 设置密码
+ case setPassword(IBPassword)
var key: IBKey {
switch self {
case .fetchFils(_): return .fetchFils
case .aiValid(_): return .aiValid
case .aiResponse(_): return .aiResponse
+ case .setPassword(_): return .setPassword
}
}
}
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
--- /dev/null
+//
+// 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
+ }
+}