设置声音震动协议修改
authorliangzhenying <867174124@qq.com>
Tue, 2 Jul 2024 07:02:03 +0000 (15:02 +0800)
committerliangzhenying <867174124@qq.com>
Tue, 2 Jul 2024 07:02:03 +0000 (15:02 +0800)
IOTBluetooth/IOTBluetooth/Example/Datas.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBVibrateSound.swift

index 17b4dd0..b1f17b8 100644 (file)
@@ -38,7 +38,7 @@ let datas: [(ability: IBAbility, label: String, parameters: [IBParameter])] = [
     
     (.fetchWatchState, "获取当前手表状态", []),
     (.fetchVibrateSound, "获取手表声音与震动参数", []),
-    (.vibrateSound, "设置手表声音与震动参数", [.vibrateSound(IBVibrateSound())]),
+    (.vibrateSound, "设置手表声音与震动参数", [.vibrateSound(Config.setVibrateSound())]),
     (.fetchAuxiliary, "获取手表辅助功能参数", []),
     (.auxiliary, "设置手表辅助功能参数", [.auxiliary(.bloodOxygen)]),
     (.unit, "设置手表公英制单位", [.value(1)]),
@@ -114,7 +114,19 @@ class Config{
 //        model.type = 1
 //        model.duration = .minute
 //        model.wrist = 0
-        
+        return model
+    }
+    static func setVibrateSound()->IBVibrateConfig{
+        let model = IBVibrateConfig()
+        model.type = 0
+        model.systemValue = 80
+
+//        model.type = 1
+//        model.ringsValue = 70
+//
+//        model.type = 3
+//        model.ringsState = 1
+//        model.vibrateState = 1
         return model
     }
 }
index a1c401b..5086531 100644 (file)
Binary files a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate and b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate differ
index 9ace3af..7ca3830 100644 (file)
@@ -14,8 +14,8 @@
             filePath = "IOTBluetooth/IBChecker.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "362"
-            endingLineNumber = "362"
+            startingLineNumber = "386"
+            endingLineNumber = "386"
             landmarkName = "unknown"
             landmarkType = "0">
          </BreakpointContent>
index 32277be..594b045 100644 (file)
@@ -173,6 +173,49 @@ struct IBBloodOxygenChecker: IBChecker {
         return data
     }
 }
+
+
+struct IBOtherTargetChecker: IBChecker {
+    static func check(_ parameters: [IBParameter]) -> [UInt8] {
+        guard case let .otherTarget(value) = parameters[.otherTarget] else { fatalError("缺少参数: otherTarget") }
+        Logger.log(value.description)
+        var data = value.calorie.byte2 + [value.mileage.byte] + [value.stand.byte] + [value.burning.byte] + [value.ringsState.byte] + [value.vibrateState.byte]
+        data = data + [value.noticeState.byte]
+        return data
+    }
+}
+
+struct IBVibrateSoundChecker: IBChecker {
+    static func check(_ parameters: [IBParameter]) -> [UInt8] {
+        guard case let .vibrateSound(value) = parameters[.vibrateSound] else { fatalError("缺少参数: IBVibrateConfig") }
+        Logger.log(value.description)
+        if value.type == 0{
+            if let systemValue = value.systemValue {
+                return [value.type.byte] + [systemValue.byte]
+            }
+            else{
+                fatalError("参数错误: IBScreenConfig")
+            }
+        }
+        else if value.type == 1{
+            if let ringsValue = value.ringsValue{
+                return [value.type.byte] + [ringsValue.byte]
+            }
+            else{
+                fatalError("参数错误: IBScreenConfig")
+            }
+        }
+        else if value.type == 3{
+            if let ringsState = value.ringsState,let vibrateState = value.vibrateState{
+                return [value.type.byte] + [ringsState.byte] + [vibrateState.byte]
+            }
+            else{
+                fatalError("参数错误: IBScreenConfig")
+            }
+        }
+        return []
+    }
+}
 struct IBScreenChecker: IBChecker {
     static func check(_ parameters: [IBParameter]) -> [UInt8] {
         guard case let .screen(value) = parameters[.screen] else { fatalError("缺少参数: IBScreenConfig") }
@@ -195,25 +238,6 @@ struct IBScreenChecker: IBChecker {
         }
     }
 }
-
-struct IBOtherTargetChecker: IBChecker {
-    static func check(_ parameters: [IBParameter]) -> [UInt8] {
-        guard case let .otherTarget(value) = parameters[.otherTarget] else { fatalError("缺少参数: otherTarget") }
-        Logger.log(value.description)
-        var data = value.calorie.byte2 + [value.mileage.byte] + [value.stand.byte] + [value.burning.byte] + [value.ringsState.byte] + [value.vibrateState.byte]
-        data = data + [value.noticeState.byte]
-        return data
-    }
-}
-
-struct IBVibrateSoundChecker: IBChecker {
-    static func check(_ parameters: [IBParameter]) -> [UInt8] {
-        guard case let .vibrateSound(value) = parameters[.vibrateSound] else { fatalError("缺少参数: vibrateSound") }
-        Logger.log(value.description)
-        let data = [value.systemValue.byte] + [value.ringsValue.byte] + [value.mediaValue.byte] + [value.ringsState.byte] + [value.vibrateState.byte]
-        return data
-    }
-}
 struct IBUserInfoChecker: IBChecker {
     static func check(_ parameters: [IBParameter]) -> [UInt8] {
         guard case let .userInfo(value) = parameters[.userInfo] else { fatalError("缺少参数: userInfo") }
index 45599c7..ed19566 100644 (file)
@@ -69,7 +69,7 @@ public enum IBParameter {
     /// 设置屏幕
     case screen(IBScreenConfig)
     /// 设置声音和震动
-    case vibrateSound(IBVibrateSound)
+    case vibrateSound(IBVibrateConfig)
     /// 设置目标设置
     case otherTarget(IBOtherTarget)
     /// 设置训练目标
index 01f2275..0bcb0ef 100644 (file)
@@ -280,7 +280,7 @@ struct IBFetchDialsParser: IBParser {
         
         var list:[Int] = []
         for i in 0..<num {
-            var value = dataPacket.data[2*i + 1...2*i + 2].int
+            let value = dataPacket.data[2*i + 1...2*i + 2].int
             list.append(value)
         }
         return .response.code(.success).items(list)
index 802fdc8..88e1ccd 100644 (file)
@@ -5,6 +5,30 @@
 ////  Created by incar on 2024/5/9.
 ////
 //
+
+/// 声音震动设置模型
+public class IBVibrateConfig {
+    /// 类型 0系统音量调节,1铃声音量调节,3铃声开关,震动开关
+    public var type: Int = 0
+    /// 系统音量调节0~100(type为0设置)
+    public var systemValue: Int?
+    
+    /// 铃声音量调节0~100(type为1设置)
+    public var ringsValue: Int?
+ 
+    /// 静音开关0:关闭 1:开启(type为3设置)
+    public var ringsState: Int?
+    
+    /// 震动设置  0:关闭    1:弱    2:中    3:强 (type为3设置)
+    public var vibrateState: Int?
+    
+    public init() { }
+    
+    var description: String  {
+        return "IBVibrateConfig(type: \(type),systemValue: \(systemValue), ringsValue:\(ringsValue), ringsState:\(ringsState), vibrateState:\(vibrateState))"
+    }
+}
+
 /// 声音震动模型
 public class IBVibrateSound {
     /// 系统音量调节0~100
@@ -16,10 +40,10 @@ public class IBVibrateSound {
     /// 媒体音量调节0~100
     public var mediaValue: Int = 0
  
-    /// é\93\83声开关0:关闭 1:开启
+    /// é\9d\99é\9f³开关0:关闭 1:开启
     public var ringsState: Int = 0
     
-    /// 震动开关0:关闭 1:开启
+    /// 震动设置  0:关闭    1:弱    2:中    3:强
     public var vibrateState: Int = 0
     
     public init() { }