From: liangzhenying <867174124@qq.com> Date: Fri, 17 Jan 2025 07:16:55 +0000 (+0800) Subject: 新增日程管理指令 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=30b7d5e8d8630847b328239b48a329d7abbc7a51;p=mirrors%2FIOTBluetooth-iOS.git 新增日程管理指令 --- diff --git a/IOTBluetooth/IOTBluetooth/Example/Datas.swift b/IOTBluetooth/IOTBluetooth/Example/Datas.swift index ca97cac..f824194 100644 --- a/IOTBluetooth/IOTBluetooth/Example/Datas.swift +++ b/IOTBluetooth/IOTBluetooth/Example/Datas.swift @@ -11,6 +11,7 @@ import IOTBluetooth let datas: [(ability: IBAbility, label: String, parameters: [IBParameter])] = [ + (.sendSchedule,"发送日程管理给手表",[.sendSchedule([IBSchedule()])]), (.getSosContact,"获取OS紧急联系人",[]), (.setSosContact,"设置SOS紧急联系人",[.setSosContact([IBContact()])]), diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj index 1e45d64..6104e9a 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj @@ -64,6 +64,7 @@ 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 */; }; + 3FFAE0572D3A2CFF00325873 /* IBSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FFAE0562D3A2CF800325873 /* IBSchedule.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 */; }; @@ -187,6 +188,7 @@ 3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBPassword.swift; sourceTree = ""; }; 3F9355B62D38FF1900C54DAB /* IBPush.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBPush.swift; sourceTree = ""; }; 3FFAE0542D3A03EF00325873 /* IBContact.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBContact.swift; sourceTree = ""; }; + 3FFAE0562D3A2CF800325873 /* IBSchedule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBSchedule.swift; sourceTree = ""; }; 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 = ""; }; 8A0A39C52B980C88006A3B18 /* IBluetooth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IBluetooth.swift; sourceTree = ""; }; @@ -411,6 +413,7 @@ 3F6A07CB2D2D2C3F00F4122A /* IBPassword.swift */, 3F9355B62D38FF1900C54DAB /* IBPush.swift */, 3FFAE0542D3A03EF00325873 /* IBContact.swift */, + 3FFAE0562D3A2CF800325873 /* IBSchedule.swift */, ); path = Models; sourceTree = ""; @@ -584,6 +587,7 @@ 18EF69512C45130200AA0A36 /* IBAiManager.swift in Sources */, 18204C022C199D0E00F94E69 /* IBFileSender+Ota.swift in Sources */, 18EC6E282BFF4C6D00757CA8 /* IBPhoneInfo.swift in Sources */, + 3FFAE0572D3A2CFF00325873 /* IBSchedule.swift in Sources */, 18EF69532C45136800AA0A36 /* IBPairling.swift in Sources */, 18C9589F2C086A9D006A5DE8 /* IBHistorySleep.swift in Sources */, 180220CE2C2D5D560090D34A /* IBAiResponse.swift in Sources */, diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate index 3c632fc..436d032 100644 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 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 295d9b7..b77e291 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,22 +3,4 @@ uuid = "2CC27BE0-931D-4412-B83C-49E80F4BA55C" type = "1" version = "2.0"> - - - - - - diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift index 292bfb6..c96c932 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAbility.swift @@ -108,7 +108,9 @@ public extension IBAbility { /// - Parameter setSosContact: see ``[IBContact]`` static let setSosContact = IBAbility.long.id(0x25).parser(IBGeneralParser.self).checker(IBSetSosChecker.self) - + /// 发送日程管理给手表 + /// - Parameter sendSchedule: see ``[IBSchedule]`` + static let sendSchedule = IBAbility.long.id(0x24).parser(IBGeneralParser.self).checker(IBSendScheduleChecker.self) /// 设置用户数据 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift index 20f1890..a6715ee 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBChecker.swift @@ -267,7 +267,7 @@ struct IBSetPasswordChecker: IBChecker { guard case let .setPassword(value) = parameters[.setPassword] else { fatalError("缺少参数: SetPassword") } Logger.log(value.description) - var psd = value.password + let psd = value.password var data:[UInt8] = [UInt8(value.type)] if value.type == 1 { for i in 0.. [UInt8] { - guard case let .setSosContact(value) = parameters[.setSosContact] else { fatalError("缺少参数: setpush") } + guard case let .setSosContact(value) = parameters[.setSosContact] else { fatalError("缺少参数: setSosContact") } Logger.log(value.description) var data = [UInt8]() data += [value.count.byte] @@ -332,7 +332,30 @@ struct IBSetSosChecker: IBChecker { return data } } - +struct IBSendScheduleChecker: IBChecker { + static func check(_ parameters: [IBParameter]) -> [UInt8] { + guard case let .sendSchedule(value) = parameters[.sendSchedule] else { fatalError("缺少参数: sendSchedule") } + Logger.log(value.description) + var data = [UInt8]() + for item in value { + data += item.id.byte2 + if let value = item.title.data(using: .utf8),!value.isEmpty { + data += value.count.byte2 + data += value.bytes + } + data += item.begin.byte4 + data += item.end.byte4 + if let value = item.content?.data(using: .utf8),!value.isEmpty { + data += value.count.byte2 + data += value.bytes + } + else{ + data += 0.byte2 + } + } + return data + } +} struct IBClockChecker: IBChecker { static func check(_ parameters: [IBParameter]) -> [UInt8] { diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift index 04d3a82..87a20f4 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBParameter.swift @@ -43,6 +43,7 @@ enum IBKey: String { case setPassword = "setPassword" case setPush = "setPushConfig" case setSosContact = "setSosContact" + case sendSchedule = "sendSchedule" } /// 参数 @@ -115,6 +116,8 @@ public enum IBParameter { case setPush([IBPush]) /// 设置SOS紧急联系人 case setSosContact([IBContact]) + /// 向手表发送日程 + case sendSchedule([IBSchedule]) var key: IBKey { switch self { @@ -152,6 +155,7 @@ public enum IBParameter { case .setPassword(_): return .setPassword case .setPush(_): return .setPush case .setSosContact(_): return .setSosContact + case .sendSchedule(_): return .sendSchedule } } } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift index c20764e..57973ff 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBContact.swift @@ -11,9 +11,9 @@ public class IBContact { /// 性别 0:男性 1:女性 public var gender: Int = 0 /// 名称 - public var name:String = "广州" + public var name:String = "" /// 电话 - public var tel:String = "13480000000" + public var tel:String = "" public init() { } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBSchedule.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBSchedule.swift new file mode 100644 index 0000000..0e52a40 --- /dev/null +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBSchedule.swift @@ -0,0 +1,29 @@ +// +// IBSchedule.swift +// IOTBluetooth +// +// Created by liangshi on 2025/1/17. +// + +import Foundation +/// 日程 +public class IBSchedule { + /// 日程id + public var id:Int = 0 + /// 标题 + public var title: String = "" + /// 开始时间戳 + public var begin:Int = 1737196185 + /// 结束时间戳 + public var end:Int = 1737396185 + /// 备注内容 + public var content: String? + + public init() { } + + var description: String { + let str = "IBSchedule(title: \(title),begin:\(begin),end:\(end),content:\(content ?? ""))" + return str + } + +}