From: liangzhenying <867174124@qq.com> Date: Wed, 4 Sep 2024 08:23:44 +0000 (+0800) Subject: 修复注册、聊天切换模型bug X-Git-Tag: deepseek~5 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=ef796435a1798bdb2cfc73924e76a72391452e36;p=mirrors%2FMixSdk-iOS.git 修复注册、聊天切换模型bug --- diff --git a/MixSdk/Example/Example.xcodeproj/project.pbxproj b/MixSdk/Example/Example.xcodeproj/project.pbxproj index 1df9d74..21439bd 100644 --- a/MixSdk/Example/Example.xcodeproj/project.pbxproj +++ b/MixSdk/Example/Example.xcodeproj/project.pbxproj @@ -44,7 +44,6 @@ 18DB20482C213D730070D571 /* AiMouseAudioRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 18DB20462C213D730070D571 /* AiMouseAudioRecord.m */; }; 18DB20492C213D730070D571 /* AiMouseRecordManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 18DB20472C213D730070D571 /* AiMouseRecordManager.m */; }; 18EC39D12C4F421C00964461 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EC39D02C4F421C00964461 /* Config.swift */; }; - 18EF694A2C44CB1E00AA0A36 /* BleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18EF69492C44CB1E00AA0A36 /* BleManager.swift */; }; 18FBC2BB2C38E0FC002240AF /* ChatGptViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18FBC2BA2C38E0FC002240AF /* ChatGptViewController.swift */; }; 18FF930C2C39263A0006452C /* cat.png in Resources */ = {isa = PBXBuildFile; fileRef = 18FF930A2C39263A0006452C /* cat.png */; }; F59940004E1C16053FBD42F5 /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B555BC40ACD8F31DBCDD1A2 /* Pods_Example.framework */; }; @@ -103,7 +102,6 @@ 18DB20462C213D730070D571 /* AiMouseAudioRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AiMouseAudioRecord.m; sourceTree = ""; }; 18DB20472C213D730070D571 /* AiMouseRecordManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AiMouseRecordManager.m; sourceTree = ""; }; 18EC39D02C4F421C00964461 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; - 18EF69492C44CB1E00AA0A36 /* BleManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BleManager.swift; sourceTree = ""; }; 18FBC2BA2C38E0FC002240AF /* ChatGptViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatGptViewController.swift; sourceTree = ""; }; 18FF930A2C39263A0006452C /* cat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cat.png; sourceTree = ""; }; 4B555BC40ACD8F31DBCDD1A2 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -221,7 +219,6 @@ 184FFC482C218FC4006F664D /* PlayerManager.swift */, 184FFC4C2C2199E5006F664D /* SendToolBar.swift */, 180255B92C3BE6BD005AFC5F /* SendRecordTooBar.swift */, - 18EF69492C44CB1E00AA0A36 /* BleManager.swift */, 188695A52C5A3CAD00B9B89F /* Date.swift */, ); path = Tools; @@ -395,7 +392,6 @@ 18B74A242C201CE900FABBA9 /* SttViewController.swift in Sources */, 1843A7962C4E060D00FC010F /* LogViewController.swift in Sources */, 185D665B2C6C4E5D009AE49F /* MSCompress.swift in Sources */, - 18EF694A2C44CB1E00AA0A36 /* BleManager.swift in Sources */, 18204BD42C193F9A00F94E69 /* AppDelegate.swift in Sources */, 18B74A262C201EBD00FABBA9 /* ChatViewController.swift in Sources */, 184FFC492C218FC4006F664D /* PlayerManager.swift in Sources */, diff --git a/MixSdk/Example/Example/Tools/BleManager.swift b/MixSdk/Example/Example/Tools/BleManager.swift deleted file mode 100644 index 7ef4754..0000000 --- a/MixSdk/Example/Example/Tools/BleManager.swift +++ /dev/null @@ -1,244 +0,0 @@ -// -// BleManager.swift -// Example -// -// Created by incar on 2024/7/15. -// - -import Foundation -import CoreBluetooth - -public class IBScanOption { - var values: [String : Any] = [:] - var serviceUUIDs: [String]? = nil - - /// 允许重复扫描 - @discardableResult - public func allowDuplicates(_ value: Bool) -> Self { - values[CBCentralManagerScanOptionAllowDuplicatesKey] = value - return self - } - - /// 扫描指定服务 - @discardableResult - public func solicited(_ serviceUUIDs: [String]) -> Self { - self.serviceUUIDs = serviceUUIDs - values[CBCentralManagerScanOptionSolicitedServiceUUIDsKey] = serviceUUIDs.map({ CBUUID(string: $0) }) - return self - } - - public static let `default` = IBScanOption() - public static var custom: IBScanOption { IBScanOption() } -} - - - -class IBBluetooth: NSObject { - static let shared = IBBluetooth() - - private override init() { - super.init() - centralManager = CBCentralManager(delegate: self, queue: nil) - } - - /// 2AE5 - private var notifyCharacteristic: CBCharacteristic! - /// 2AE2 - private var readCharacteristic: CBCharacteristic! - /// 2AE3 - private var writeCharacteristic: CBCharacteristic! - /// 2AE4 - private var writeBigCharacteristic: CBCharacteristic! - /// 2AE0 - private var writeFileCharacteristic: CBCharacteristic! - - /// 中央管理类,管理蓝牙的扫描连接 - var centralManager: CBCentralManager! - - /// 扫描到的蓝牙设备集合 - var devices: [CBPeripheral] = [] - - - /// 当前连接设备 - var currentConnected: CBPeripheral! - - - private var option: IBScanOption = .default - func scan(_ option: IBScanOption = .default) { - self.option = option - startScan() - } - - /// 重连接设备 - func reconnected() { -// guard let connectedPeripheral = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: serviceUUID)]).first else { return } -// centralManager.connect(connectedPeripheral) - } - - /// 开始扫描 - private func startScan() { - if centralManager.state == .poweredOn { - print("开始扫描蓝牙设备...") - } - centralManager.scanForPeripherals(withServices: nil, options: option.values) - -// if let connectedPeripheral = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: serviceUUID)]).first{ -// IBManager.discoverHandler?(currentConnected) -// } - } - - /// 停止扫描 - func stopScan(){ - print("停止扫描蓝牙设备...") - centralManager.stopScan() - } - - /// 连接蓝牙设备 - /// - /// - Parameter peripheral: 蓝牙设备对像 - func connect(_ peripheral: CBPeripheral) { - currentConnected = peripheral - centralManager.connect(peripheral) - } - - /// 断开与蓝牙设备的连接 - /// - /// - Parameter peripheral: 蓝牙设备对像 - func cancel(_ peripheral: CBPeripheral) { - centralManager.cancelPeripheralConnection(peripheral) - } - - /// 发送数据 - /// - Parameters: - /// - sender: 消息类 - func send() { - if currentConnected.state == .disconnected{ - - print("手机未连上蓝牙设备!") - return - } - - } - -} - -extension IBBluetooth: CBCentralManagerDelegate { - - /// 手机蓝牙状态更新 - /// - Parameter central: 中央管理类 - func centralManagerDidUpdateState(_ central: CBCentralManager) { - switch central.state { - case .unknown: - print("unknown") - case .resetting: - print("resetting") - case .unsupported: - print("unsupported") - case .unauthorized: - print("unauthorized") - case .poweredOff: - print("poweredOff") - case .poweredOn: - startScan() - print("poweredOn") - @unknown default: - break - } - } - - /// 发现设备 - func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { - - } - - /// 连接上设备 - func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { - peripheral.delegate = self -// peripheral.discoverServices([CBUUID(string: serviceUUID)]) - print("已连接", currentConnected.name) - } - - /// 连接失败 - func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) { - print("连接失败",error?.localizedDescription ?? "" ) - currentConnected = nil - } - - /// 断开连接 - func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { - print("断开连接") - - deinitTimer() - - } -} - -extension IBBluetooth: CBPeripheralDelegate { - - /// 读取到信号 - func peripheral(_ peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: Error?) { - - } - - /// 发现服务 - func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { - peripheral - .services? - .forEach { - peripheral.discoverCharacteristics(nil, for: $0) - } - } - - /// 发现服务找那个的特征,然后遍历所有特征订阅 - func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { - - } - - /// 来自蓝牙设备的通知 - func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) { - // 读取特征的值 - peripheral.readValue(for: characteristic) - } - - /// 蓝牙设备发过来的数据 - func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { - if let error = error { - print(error) - } - - guard let data = characteristic.value else { return } - - - let uuid = characteristic.uuid.uuidString - print( uuid, "->", data.map{String(format: "%02x", $0)}.joined(separator: " "), "Bytes(\(data.count))") - } - - /// 写入完成(发送指令完成) - func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) { - if let error = error { - print(characteristic.uuid.uuidString,error.localizedDescription) - } - - } -} - -extension IBBluetooth { - - static var timer: Timer? - func startTimer() { - deinitTimer() - - Self.timer = Timer.scheduledTimer(withTimeInterval: 3.0, repeats: false, block: { [unowned self] _ in - deinitTimer() - }) -// print("创建定时器") - } - - func deinitTimer() { - guard let _ = Self.timer else { return } - Self.timer?.invalidate() - Self.timer = nil - -// print("销毁定时器") - } -} diff --git a/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate b/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate index 6a00ed7..fad0485 100644 Binary files a/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate and b/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 2155d5d..7273284 100644 --- a/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/MixSdk/MixSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -84,5 +84,37 @@ landmarkType = "7"> + + + + + + + + diff --git a/MixSdk/MixSdk/MixSdk/MSAuth.swift b/MixSdk/MixSdk/MixSdk/MSAuth.swift index d9bab89..2b667a4 100644 --- a/MixSdk/MixSdk/MixSdk/MSAuth.swift +++ b/MixSdk/MixSdk/MixSdk/MSAuth.swift @@ -30,10 +30,10 @@ public class MSAuth { public func register(productId:String,productKey:String,deviceId:String,completeHandler: @escaping MSRegisterCallBack){ let timeStamp = "\(Int(Date().timeIntervalSince1970)*1000)" - let value = deviceId + productKey + timeStamp + let value = deviceId + productId + timeStamp let signValue = MSUtils.string(toHmacSha1: productKey, text: value) let params = [ - "pid":productKey, + "pid":productId, "deviceId":deviceId, "signMethod":"HMACSHA1", "sign":signValue, diff --git a/MixSdk/MixSdk/MixSdk/MSChat.swift b/MixSdk/MixSdk/MixSdk/MSChat.swift index 60f64a2..18d23b1 100644 --- a/MixSdk/MixSdk/MixSdk/MSChat.swift +++ b/MixSdk/MixSdk/MixSdk/MSChat.swift @@ -48,6 +48,7 @@ public class MSChat { socket?.close(10100,reason: "正常结束") } if let model = lastChatModel,model.type != "end"{ + lastChatModel = nil let endModel = MSChatModel() endModel.type = "end" callBack?(endModel)