From: liangzhenying <867174124@qq.com> Date: Thu, 25 Dec 2025 06:35:49 +0000 (+0800) Subject: 改修deepchordssdk初始化 X-Git-Tag: 1.0.2~18 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=2bb77e3c2164de66a88e5b09ce11526ac3a0f11d;p=mirrors%2FShenYin.git 改修deepchordssdk初始化 --- diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift index 2f2cb0e..6c9509c 100644 --- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift +++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift @@ -15,31 +15,21 @@ public class DeepChordsAiSdk{ public func initSDK(){ -// StarburstConfig.shared().switch(to: .ble) -// StarburstConfig.shared().appId = "app_ro4n4nwljr20kwqo" - //MARK: 配置缓存路径 - StarburstConfig.shared().sdkFolder = NSTemporaryDirectory() - StarburstConfig.shared().isDebug = true - StarburstConfig.shared().enableTextSyncToDevice = true - StarburstConfig.shared().enableEmotionSyncToDevice = true - StarburstConfig.shared().enableEarbudsSwitchSync = true - + StarburstConfig.shared().switch(to: .ble) StarburstConfig.shared().appId = "prjzVnOEpKL1N" - - - //debug模式会打印日志 - StarburstConfig.shared().isDebug = false - // sdk缓存路径 - StarburstConfig.shared().sdkFolder = NSHomeDirectory() + "/Documents/DeepChordsSdk" + StarburstConfig.shared().isDebug = true + //MARK: 配置缓存路径 + StarburstConfig.shared().sdkFolder = NSTemporaryDirectory() +// StarburstConfig.shared().sdkFolder = NSHomeDirectory() + "/Documents/DeepChordsSdk" // 日志路径 StarburstConfig.shared().logPath = logPath() - // //是否下发文字到耳机仓 - // StarburstConfig.shared().enableTextSyncToDevice = true; - // //主从耳机切换是否同步sdk信息到耳机 - // StarburstConfig.shared().enableEarbudsSwitchSync = true; - // //耳机仓表情下发开关 - // StarburstConfig.shared().enableEmotionSyncToDevice = true; + //是否下发文字到耳机仓 + StarburstConfig.shared().enableTextSyncToDevice = false + //主从耳机切换是否同步sdk信息到耳机 + StarburstConfig.shared().enableEarbudsSwitchSync = true + //耳机仓表情下发开关 + StarburstConfig.shared().enableEmotionSyncToDevice = false //添加调试信息 // StarburstConfig.shared().debugInfo = [ // "x-use-ppe":"1", diff --git a/ShenYin/ShenYin/DcSdk/BleManager.swift b/ShenYin/ShenYin/DcSdk/BleManager.swift new file mode 100644 index 0000000..3952660 --- /dev/null +++ b/ShenYin/ShenYin/DcSdk/BleManager.swift @@ -0,0 +1,143 @@ +//// +//// BleManager.swift +//// Example +//// +//// Created by liangshi on 2025/11/24. +//// +// +//// +//// Untitled.swift +//// ShenYin +//// +//// Created by liangshi on 2025/8/28. +//// +// +//import UIKit +//import CoreBluetooth +//import DeepChordsSdk +// +//class BleManager: NSObject { +// var discoverDeviceCallback: (([CBPeripheral]) -> Void)? +// var didConnectDeviceCallback: ((CBPeripheral) -> Void)? +// var disConnectDeviceCallback: ((CBPeripheral) -> Void)? +// var conetedFailureCallback: ((CBPeripheral) -> Void)? +// +// private var centralManager: CBCentralManager! +// var devices: [CBPeripheral] = [] +// +// private override init() { +// super.init() +// centralManager = CBCentralManager(delegate: self, queue: nil) +// } +// +// static let shared = BleManager() +// +// func stopScanDevice() { +// centralManager.stopScan() +// } +// func startScanDevice() { +// // centralManager.stopScan() +// DCLogger.debug("扫描中...") +// devices = [] +// +// if let connectedPeripheral = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: "AE30")]).first{ +// devices = [connectedPeripheral] +// } +// discoverDeviceCallback?(devices) +// centralManager.scanForPeripherals(withServices: nil,options: [CBCentralManagerScanOptionAllowDuplicatesKey : false]) +// +// } +// func connectPeripheral(_ peripheral: CBPeripheral) { +// DCLogger.debug("正在连接...",peripheral) +// centralManager.connect(peripheral, options: [CBConnectPeripheralOptionNotifyOnConnectionKey: true]) +// } +// func cancel(){ +// +// } +// func autoConnect(){ +//// if let peripheral = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: "AE30")]).first{ +//// connectPeripheral(peripheral) +//// } +// } +//} +//extension BleManager:CBCentralManagerDelegate{ +// func centralManagerDidUpdateState(_ central: CBCentralManager) { +// DCLogger.debug("蓝牙状态",central.state.rawValue) +// switch central.state { +// case.unknown: +// break +// case.resetting: +// break +// case.unsupported: +// break +// case.unauthorized: +// break +// case.poweredOff: +// +// break +// case.poweredOn: +// startScanDevice() +// break +// @unknown default: +// break +// } +// } +// +// func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { +// if devices.contains(peripheral) { +// return +// } +// if let name = peripheral.name,name.hasPrefix("AI") { +// devices.append(peripheral) +// DCLogger.debug(peripheral) +// discoverDeviceCallback?(devices) +// } +// } +// +// func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { +// stopScanDevice() +// DCLogger.debug("蓝牙已连接 \(peripheral)") +// +// peripheral.delegate = self +// peripheral.discoverServices(nil); +// DCBleManager.shared.centralManager(central, didConnect: peripheral) +// self.didConnectDeviceCallback?(peripheral) +// App.shared.window?.makeToast("蓝牙已连接") +// } +// func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) { +// DCBleManager.shared.centralManager(central, didFailToConnect: peripheral, error: error) +// } +// func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { +// disConnectDeviceCallback?(peripheral) +// DCBleManager.shared.centralManager(central, didDisconnectPeripheral: peripheral, error: nil) +// App.shared.window?.makeToast("蓝牙已断开连接") +// App.shared.window?.rootViewController = UINavigationController(rootViewController: DeviceListVC()) +// } +//} +// +//extension BleManager: CBPeripheralDelegate { +// func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { +// DCBleManager.shared.peripheral(peripheral, didDiscoverServices: error) +// } +// +// func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { +// DCBleManager.shared.peripheral(peripheral, didDiscoverCharacteristicsFor: service, error: error) +// } +// +// func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: (any Error)?) { +// DCLogger.debug("状态改变 == UUID ",characteristic.uuid) +// } +// +// func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { +// DCBleManager.shared.peripheral(peripheral, didUpdateValueFor: characteristic, error: error) +// +// } +// +// func peripheral(_ peripheral: CBPeripheral, didModifyServices invalidatedServices: [CBService]) { +// // Accessory's GATT database has updated. Refresh your local cache (if any) +// } +// +// func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: (any Error)?) { +// +// } +//} diff --git a/ShenYin/ShenYin/Launch/AppManager.swift b/ShenYin/ShenYin/Launch/AppManager.swift index 456bec6..038c4c7 100644 --- a/ShenYin/ShenYin/Launch/AppManager.swift +++ b/ShenYin/ShenYin/Launch/AppManager.swift @@ -33,8 +33,12 @@ class App{ Logger.debug(DCFolder.user) Logger.debug(DCFolder.record) self.window?.rootViewController = BaseTC() - JoySdkManager.shared.setupSdk() - // DCSdkManager.shared.initSdk() + if App.shared.isJoy { + JoySdkManager.shared.setupSdk() + } + else{ + DCSdkManager.shared.initSdk() + } } func goToLogin(){ window?.rootViewController = BaseNC(rootViewController: LoginVC())