From: liangzhenying <867174124@qq.com> Date: Tue, 2 Jul 2024 07:02:03 +0000 (+0800) Subject: 设置声音震动协议修改 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=4f0f682500841d13e3c6deb1c7b4ac3659d2b743;p=mirrors%2FIOTBluetooth-iOS.git 设置声音震动协议修改 --- diff --git a/IOTBluetooth/IOTBluetooth/Example/Datas.swift b/IOTBluetooth/IOTBluetooth/Example/Datas.swift index 17b4dd0..b1f17b8 100644 --- a/IOTBluetooth/IOTBluetooth/Example/Datas.swift +++ b/IOTBluetooth/IOTBluetooth/Example/Datas.swift @@ -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 } } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate index a1c401b..5086531 100644 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 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 9ace3af..7ca3830 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -14,8 +14,8 @@ filePath = "IOTBluetooth/IBChecker.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "362" - endingLineNumber = "362" + startingLineNumber = "386" + endingLineNumber = "386" landmarkName = "unknown" landmarkType = "0"> diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift index 32277be..594b045 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift @@ -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") } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift index 45599c7..ed19566 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift @@ -69,7 +69,7 @@ public enum IBParameter { /// 设置屏幕 case screen(IBScreenConfig) /// 设置声音和震动 - case vibrateSound(IBVibrateSound) + case vibrateSound(IBVibrateConfig) /// 设置目标设置 case otherTarget(IBOtherTarget) /// 设置训练目标 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift index 01f2275..0bcb0ef 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParser.swift @@ -280,7 +280,7 @@ struct IBFetchDialsParser: IBParser { var list:[Int] = [] for i in 0..