let datas: [(ability: IBAbility, label: String, parameters: [IBParameter])] = [
+ (.getSosContact,"获取OS紧急联系人",[]),
+ (.setSosContact,"设置SOS紧急联系人",[.setSosContact([IBContact()])]),
(.getPushConfig,"获取推送配置",[]),
(.setPushConfig,"设置推送",[.setPush(IBPush.all)]),
3F6A07C52D2D06D600F4122A /* MixTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F6A07C42D2D06D600F4122A /* MixTools.framework */; };
3F6A07CC2D2D2C3F00F4122A /* IBPassword.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */; };
3F9355B72D38FF2100C54DAB /* IBPush.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F9355B62D38FF1900C54DAB /* IBPush.swift */; };
+ 3FFAE0552D3A042900325873 /* IBContact.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFAE0542D3A03EF00325873 /* IBContact.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 */; };
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>"; };
3F9355B62D38FF1900C54DAB /* IBPush.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBPush.swift; sourceTree = "<group>"; };
+ 3FFAE0542D3A03EF00325873 /* IBContact.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBContact.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>"; };
182DDFD32C5CE68900D44D37 /* IBAiValid.swift */,
3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */,
3F9355B62D38FF1900C54DAB /* IBPush.swift */,
+ 3FFAE0542D3A03EF00325873 /* IBContact.swift */,
);
path = Models;
sourceTree = "<group>";
8A5822CF2BA1A67700590AB6 /* IBAbility.swift in Sources */,
8A65F9652BAC271B005C1EA4 /* IBScreen.swift in Sources */,
1859DFA02BFF5A2700112E8C /* IBSendTime.swift in Sources */,
+ 3FFAE0552D3A042900325873 /* IBContact.swift in Sources */,
18EF69792C47A86D00AA0A36 /* IBTools.swift in Sources */,
8A65F9632BAC1018005C1EA4 /* IBTargetStep.swift in Sources */,
181441D32C115AC500CCDD46 /* IBFileSender.swift in Sources */,
uuid = "2CC27BE0-931D-4412-B83C-49E80F4BA55C"
type = "1"
version = "2.0">
+ <Breakpoints>
+ <BreakpointProxy
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+ <BreakpointContent
+ uuid = "F50E648D-FC87-4335-B9B9-976A5D8720FA"
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "IOTBluetooth/IBChecker.swift"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "332"
+ endingLineNumber = "332"
+ landmarkName = "check(_:)"
+ landmarkType = "7">
+ </BreakpointContent>
+ </BreakpointProxy>
+ </Breakpoints>
</Bucket>
/// 设置消息推送
/// - Parameter setPush: see ``[IBPush]``
- static let setPushConfig = IBAbility.long.id(0x1e).parser(IBGeneralParser.self).checker(IBPUshChecker.self)
+ static let setPushConfig = IBAbility.long.id(0x1e).parser(IBGeneralParser.self).checker(IBPushChecker.self)
+
+ /// 获取SOS紧急联系人
+ /// - Returns: ``[IBContact]`` \
+ /// Read from ``IBResponse``.value
+ static let getSosContact = IBAbility.short.id(0x36).parser(IBGetSosParser.self)
+
+ /// 设置SOS紧急联系人
+ /// - Parameter setSosContact: see ``[IBContact]``
+ static let setSosContact = IBAbility.long.id(0x25).parser(IBGeneralParser.self).checker(IBSetSosChecker.self)
+
+
+
/// 设置用户数据
/// - Parameter userInfo: see ``IBUserInfo``
return data
}
}
-struct IBPUshChecker: IBChecker {
+struct IBPushChecker: IBChecker {
static func check(_ parameters: [IBParameter]) -> [UInt8] {
guard case let .setPush(value) = parameters[.setPush] else { fatalError("缺少参数: setpush") }
Logger.log(value.description)
return data
}
}
+struct IBSetSosChecker: IBChecker {
+ static func check(_ parameters: [IBParameter]) -> [UInt8] {
+ guard case let .setSosContact(value) = parameters[.setSosContact] else { fatalError("缺少参数: setpush") }
+ Logger.log(value.description)
+ var data = [UInt8]()
+ data += [value.count.byte]
+ for item in value {
+ data += [item.gender.byte]
+ if let value = item.name.data(using: .utf8),!value.isEmpty {
+ data += [value.count.byte]
+ data += value.bytes
+ }
+ if let value = item.tel.data(using: .utf8),!value.isEmpty {
+ data += [value.count.byte]
+ data += value.bytes
+ }
+ }
+ return data
+ }
+}
struct IBClockChecker: IBChecker {
case setPassword = "setPassword"
case setPush = "setPushConfig"
+ case setSosContact = "setSosContact"
}
/// 参数
case aiResponse(IBAiResponse)
/// 设置密码
case setPassword(IBPassword)
- /// 设置å¯\86ç \81
+ /// 设置æ¶\88æ\81¯æ\8e¨é\80\81
case setPush([IBPush])
+ /// 设置SOS紧急联系人
+ case setSosContact([IBContact])
var key: IBKey {
switch self {
case .aiResponse(_): return .aiResponse
case .setPassword(_): return .setPassword
case .setPush(_): return .setPush
+ case .setSosContact(_): return .setSosContact
}
}
}
return .response.code(.success).value(list)
}
}
+/// 获取SOS紧急联系人
+struct IBGetSosParser: IBParser {
+ static func parse(_ data: Data) -> IBResponse {
+ let datas = dataPacket(data)
+ let num = datas[0].int
+ var list = [IBContact]()
+ var index = 1
+ for _ in 0 ..< num {
+ let value = IBContact()
+ value.gender = datas[index].int
+ index = index + 1
+ let nameLen = datas[index].int
+ index = index + 1
+ value.name = String.init(data: Data(datas[index..<index + nameLen]), encoding: .utf8) ?? ""
+ index = index + nameLen
+
+ let phoneLen = datas[index].int
+ index = index + 1
+ value.tel = String.init(data: Data(datas[index..<index + phoneLen]), encoding: .utf8) ?? ""
+ index = index + phoneLen
+ list.append(value)
+ }
+ return .response.code(.success).value(list)
+ }
+}
struct IBTakePhotoParser: IBParser {
static func parse(_ data: Data) -> IBResponse {
let code = dataPacket(data).int
--- /dev/null
+//
+// IBContact.swift
+// IOTBluetooth
+//
+// Created by liangshi on 2025/1/17.
+//
+
+import Foundation
+/// 联系人
+public class IBContact {
+ /// 性别 0:男性 1:女性
+ public var gender: Int = 0
+ /// 名称
+ public var name:String = "广州"
+ /// 电话
+ public var tel:String = "13480000000"
+
+ public init() { }
+
+
+ var description: String {
+ let str = "IBContact(gender: \(gender),name:\(name),tel:\(tel))"
+ return str
+ }
+
+}
import Foundation
-/// å\85³äº\8eæ\9c¬æ\9cº模型
+/// å¯\86ç \81模型
public class IBPassword:Codable {
/// 0不启用,1启用
public var type: Int = 0
//
import Foundation
-/// 关于本机模型
+/// 消息推送
public class IBPush {
/// 类型
public var type: IBPushType = .tel
}
}
-/// 推送配置
+/// 推送类型
public enum IBPushType: Int {
case tel = 0
case sms = 1