新增SOS指令
authorliangzhenying <867174124@qq.com>
Fri, 17 Jan 2025 06:11:31 +0000 (14:11 +0800)
committerliangzhenying <867174124@qq.com>
Fri, 17 Jan 2025 06:11:31 +0000 (14:11 +0800)
IOTBluetooth/IOTBluetooth/Example/Datas.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift [new file with mode: 0644]
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPassword.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPush.swift

index 867831f..ca97cac 100644 (file)
@@ -11,6 +11,8 @@ import IOTBluetooth
 
 
 let datas: [(ability: IBAbility, label: String, parameters: [IBParameter])] = [
+    (.getSosContact,"获取OS紧急联系人",[]),
+    (.setSosContact,"设置SOS紧急联系人",[.setSosContact([IBContact()])]),
     
     (.getPushConfig,"获取推送配置",[]),
     (.setPushConfig,"设置推送",[.setPush(IBPush.all)]),
index 8f5c54e..1e45d64 100644 (file)
@@ -63,6 +63,7 @@
                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 */,
index f2903ef..3c632fc 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 b77e291..295d9b7 100644 (file)
@@ -3,4 +3,22 @@
    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>
index cd782cc..292bfb6 100644 (file)
@@ -97,7 +97,19 @@ public extension IBAbility {
     
     /// 设置消息推送
     /// - 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``
index 93e6c3c..20f1890 100644 (file)
@@ -294,7 +294,7 @@ struct IBUserInfoChecker: IBChecker {
         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)
@@ -312,6 +312,26 @@ struct IBPUshChecker: IBChecker {
         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 {
index e01be3f..04d3a82 100644 (file)
@@ -42,6 +42,7 @@ enum IBKey: String {
     
     case setPassword = "setPassword"
     case setPush = "setPushConfig"
+    case setSosContact = "setSosContact"
 }
 
 /// 参数
@@ -110,8 +111,10 @@ public enum IBParameter {
     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 {
@@ -148,6 +151,7 @@ public enum IBParameter {
         case .aiResponse(_): return .aiResponse
         case .setPassword(_): return .setPassword
         case .setPush(_): return .setPush
+        case .setSosContact(_): return .setSosContact
         }
     }
 }
index 55b0414..96ba4a5 100644 (file)
@@ -97,6 +97,31 @@ struct IBGetPushParser: IBParser {
         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
diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift
new file mode 100644 (file)
index 0000000..c20764e
--- /dev/null
@@ -0,0 +1,26 @@
+//
+//  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
+    }
+
+}
index 651b4e8..aec3ef2 100644 (file)
@@ -7,7 +7,7 @@
 
 
 import Foundation
-/// å\85³äº\8eæ\9c¬æ\9cº模型
+/// å¯\86ç \81模型
 public class IBPassword:Codable {
     /// 0不启用,1启用
     public var type: Int = 0
index 04fde22..ec29b93 100644 (file)
@@ -6,7 +6,7 @@
 //
 
 import Foundation
-/// 关于本机模型
+/// 消息推送
 public class IBPush {
     /// 类型
     public var type: IBPushType = .tel
@@ -36,7 +36,7 @@ public class IBPush {
     }
 }
 
-/// 推送配置
+/// 推送类型
 public enum IBPushType: Int  {
     case tel = 0
     case sms = 1