From: liangzhenying <867174124@qq.com> Date: Sat, 20 Jul 2024 02:40:47 +0000 (+0800) Subject: 新增分包接收处理 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=7b2a13eb5231921519254f5315a31d77ff28c695;p=mirrors%2FIOTBluetooth-iOS.git 新增分包接收处理 --- diff --git a/IOTBluetooth/IOTBluetooth/Example/AbilityViewController.swift b/IOTBluetooth/IOTBluetooth/Example/AbilityViewController.swift index b0c79bb..5265b15 100644 --- a/IOTBluetooth/IOTBluetooth/Example/AbilityViewController.swift +++ b/IOTBluetooth/IOTBluetooth/Example/AbilityViewController.swift @@ -157,12 +157,12 @@ extension AbilityViewController{ info.theme = "黑暗" - activityIndicatorView.startAnimating() +// activityIndicatorView.startAnimating() IBFileSender().dial(info).progress({ total, current in print("\(total) : \(current)") }).response {[weak self] result in print(result) - self?.activityIndicatorView.stopAnimating() +// self?.activityIndicatorView.stopAnimating() } } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj index 499d979..48e3708 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.pbxproj @@ -49,7 +49,6 @@ 18EF69512C45130200AA0A36 /* IBAiManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69502C45130200AA0A36 /* IBAiManager.swift */; }; 18EF69532C45136800AA0A36 /* IBPairling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69522C45136800AA0A36 /* IBPairling.swift */; }; 18EF69552C45266D00AA0A36 /* IBReceiveManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69542C45266D00AA0A36 /* IBReceiveManager.swift */; }; - 18EF696F2C47983200AA0A36 /* MixSdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF696E2C47983200AA0A36 /* MixSdk.framework */; }; 18EF69702C4798BB00AA0A36 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF696B2C47766400AA0A36 /* libbz2.tbd */; }; 18EF69712C4798C600AA0A36 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF69692C47765800AA0A36 /* libiconv.tbd */; }; 18EF69722C4798D100AA0A36 /* liblzma.5.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 18EF69672C47764400AA0A36 /* liblzma.5.tbd */; }; @@ -173,7 +172,6 @@ 18EF69672C47764400AA0A36 /* liblzma.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.5.tbd; path = usr/lib/liblzma.5.tbd; sourceTree = SDKROOT; }; 18EF69692C47765800AA0A36 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; }; 18EF696B2C47766400AA0A36 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; - 18EF696E2C47983200AA0A36 /* MixSdk.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MixSdk.framework; sourceTree = ""; }; 18EF69752C47A0F200AA0A36 /* AIAudio.sbc */ = {isa = PBXFileReference; lastKnownFileType = file; path = AIAudio.sbc; sourceTree = ""; }; 18EF69782C47A86D00AA0A36 /* IBTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBTools.swift; sourceTree = ""; }; 18EFF59A2C080F14001B1E0E /* IBUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBUserInfo.swift; sourceTree = ""; }; @@ -229,7 +227,6 @@ 18EF69722C4798D100AA0A36 /* liblzma.5.tbd in Frameworks */, 18EF69712C4798C600AA0A36 /* libiconv.tbd in Frameworks */, 18EF69702C4798BB00AA0A36 /* libbz2.tbd in Frameworks */, - 18EF696F2C47983200AA0A36 /* MixSdk.framework in Frameworks */, 8A0A39C92B980CC2006A3B18 /* CoreBluetooth.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -280,7 +277,6 @@ 8A0A39BD2B980BEF006A3B18 /* IOTBluetooth */ = { isa = PBXGroup; children = ( - 18EF696E2C47983200AA0A36 /* MixSdk.framework */, 8A9F6ABF2BA04B5100DA520F /* Models */, 8A0A39D02B980DFD006A3B18 /* Tools */, 8A0A39C52B980C88006A3B18 /* IBluetooth.swift */, 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 02eb1fa..bc4f4ca 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 bf753d4..baf400b 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 @@ -36,5 +36,21 @@ landmarkType = "7"> + + + + diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift index d4113fe..143cc12 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift @@ -6,7 +6,7 @@ // import Foundation -import MixSdk +//import MixSdk class IBAiManager{ static let shared = IBAiManager() var audioData = Data() @@ -14,7 +14,6 @@ class IBAiManager{ var reply = "" init(){ -// loginAction() setupChatCallBack() } @@ -53,71 +52,71 @@ class IBAiManager{ } extension IBAiManager{ func loginAction() { - MixSdk.shared.isDebug = true - let deviceId = "281106AFB0F7" - let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT" - let password = "F1xdqQL2fXjcmD4dV4To42dUUiBb2L"//注册获得的密码 - - MixSdk.shared.auth.login(productKey:productKey,deviceId: deviceId, password: password){ token,error in - if let err = error{ - Logger.log(err) - } - else{ - Logger.log("token = \(token!)") - } - } +// MixSdk.shared.isDebug = true +// let deviceId = "281106AFB0F7" +// let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT" +// let password = "F1xdqQL2fXjcmD4dV4To42dUUiBb2L"//注册获得的密码 +// +// MixSdk.shared.auth.login(productKey:productKey,deviceId: deviceId, password: password){ token,error in +// if let err = error{ +// Logger.log(err) +// } +// else{ +// Logger.log("token = \(token!)") +// } +// } } func receiveAiData(sbcData:Data){ - let pcmData = MSAudioConvert.sbcTopcm(sbcData) - if pcmData.count == 0{ - Logger.log("sbc2pcm失败") - let model = IBAiResponse() - model.type = 0 - sendRelpy(model: model) - return - } - guard let pcmPath = IBTools.saveToFile(data: pcmData) else {return} - MixSdk.shared.stt.sentenceRecognize(filePath: pcmPath,format:"pcm",sample_rate:"16000",lang: "zh-cn") {[weak self] text, error in - guard let self = self else {return} - if let text = text,text.count > 0{ - Logger.log(text) - let model = IBAiResponse() - model.type = 1 - model.value = text - sendRelpy(model: model) - - MixSdk.shared.chat.send(content: text) - } - else{ - Logger.log(error ?? "") - let model = IBAiResponse() - model.type = 0 - sendRelpy(model: model) - } - } +// let pcmData = MSAudioConvert.sbcTopcm(sbcData) +// if pcmData.count == 0{ +// Logger.log("sbc2pcm失败") +// let model = IBAiResponse() +// model.type = 0 +// sendRelpy(model: model) +// return +// } +// guard let pcmPath = IBTools.saveToFile(data: pcmData) else {return} +// MixSdk.shared.stt.sentenceRecognize(filePath: pcmPath,format:"pcm",sample_rate:"16000",lang: "zh-cn") {[weak self] text, error in +// guard let self = self else {return} +// if let text = text,text.count > 0{ +// Logger.log(text) +// let model = IBAiResponse() +// model.type = 1 +// model.value = text +// sendRelpy(model: model) +// +// MixSdk.shared.chat.send(content: text) +// } +// else{ +// Logger.log(error ?? "") +// let model = IBAiResponse() +// model.type = 0 +// sendRelpy(model: model) +// } +// } } func setupChatCallBack(){ - let chat = MixSdk.shared.chat - chat.callBack = {[weak self] model in - guard let self = self else {return} - print("\(model.type) : \(model.content ?? "")") - - if model.type == "start" { - reply = "" - } - else if model.type == "end" { - let model = IBAiResponse() - model.type = 2 - model.value = reply - sendRelpy(model: model) - } - else if model.type == "middle"{ - reply += model.content ?? "" - } - } +// let chat = MixSdk.shared.chat +// chat.callBack = {[weak self] model in +// guard let self = self else {return} +// print("\(model.type) : \(model.content ?? "")") +// +// if model.type == "start" { +// reply = "" +// } +// else if model.type == "end" { +// let model = IBAiResponse() +// model.type = 2 +// model.value = reply +// sendRelpy(model: model) +// } +// else if model.type == "middle"{ +// reply += model.content ?? "" +// } +// } } func sendRelpy(model:IBAiResponse){ diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBManager.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBManager.swift index 45cb27b..8ed4999 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBManager.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBManager.swift @@ -31,7 +31,7 @@ public class IBManager { public extension IBManager { /// SDK 版本号 - static let version: String = "1.0.19" + static let version: String = "1.0.20" /// 默认为 false static var isDebug: Bool = false { didSet { Logger.isDebug = isDebug } diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift index 97ec4b3..fac1e0b 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift @@ -38,8 +38,8 @@ class IBReceiveManager{ Logger.log(mark, uuid, "->", "pkgTotal = \(pkgTotal),dataTotal = \(dataTotal),pkgIndex = \(pkgIndex),pkgLen = \(pkgLen)",data.joined(" ")) - if data[1] == 0x01,data[2] == 0x34{ - //ai语音 +// if data[1] == 0x01,data[2] == 0x34{ +// //ai语音 if pkgIndex == 1{ headData = data.prefix(17) } @@ -51,10 +51,10 @@ class IBReceiveManager{ let fullData = headData + totalData didGetFullData(characteristic: characteristic, data: fullData) } - } - else{ - didGetFullData(characteristic: characteristic, data: data) - } +// } +// else{ +// didGetFullData(characteristic: characteristic, data: data) +// } } else{ Logger.log( data.joined(" ")) diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBHistoryCalorie.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBHistoryCalorie.swift index 94e855a..c5f7ed8 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBHistoryCalorie.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBHistoryCalorie.swift @@ -16,7 +16,7 @@ import Foundation for i in stride(from: 0, to: data.count, by: 8){ if data.count > i + 7 { let model = IBHistoryCalorieItem() - model.time = data[0...3].int + model.time = data[i...i+3].int model.value = data[i+4...i+7].float historyList.append(model) }