From: liangzhenying <867174124@qq.com>
Date: Wed, 24 Dec 2025 07:44:47 +0000 (+0800)
Subject: 修改蓝牙管理类
X-Git-Tag: 1.0.2~20
X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=87bb6e70fe24eb7da4ebbbce0551ded2e59cb918;p=mirrors%2FShenYin.git
修改蓝牙管理类
---
diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleManager.swift b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleManager.swift
index 48bd20b..b028548 100644
--- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleManager.swift
+++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleManager.swift
@@ -35,7 +35,7 @@ public class DCBleManager{
full.append(data)
full.addCrc()
if let connectPeripheral = connectPeripheral, let writeCha = writeCha {
-// DCLogger.debug("å",writeCha.uuid.uuidString,full.joined())
+ DCLogger.debug("å",writeCha.uuid.uuidString,full.joined())
connectPeripheral.writeValue(full, for: writeCha, type:.withoutResponse)
}
}
@@ -77,7 +77,7 @@ public extension DCBleManager{
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
-// DCLogger.debug("æ¶ ",characteristic.uuid,characteristic.value?.joined() ?? "")
+ DCLogger.debug("æ¶ ",characteristic.uuid,characteristic.value?.joined() ?? "")
guard let data = characteristic.value else { return }
if data.count > 4 && data[0] == 0xBA {
if let sender = BleSender.answer(data) {
diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/project.pbxproj b/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/project.pbxproj
index 3e37ec9..71f1cf7 100644
--- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/project.pbxproj
+++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/project.pbxproj
@@ -660,6 +660,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -713,6 +714,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
new file mode 100644
index 0000000..08ce773
--- /dev/null
+++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ShenYin/ShenYin.xcodeproj/project.pbxproj b/ShenYin/ShenYin.xcodeproj/project.pbxproj
index ac87ccd..1ea9a02 100644
--- a/ShenYin/ShenYin.xcodeproj/project.pbxproj
+++ b/ShenYin/ShenYin.xcodeproj/project.pbxproj
@@ -262,7 +262,7 @@
CODE_SIGN_ENTITLEMENTS = ShenYin/ShenYin.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 1100;
+ CURRENT_PROJECT_VERSION = 1002;
DEVELOPMENT_TEAM = G23X75CJ67;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -288,7 +288,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- MARKETING_VERSION = 1.0.1;
+ MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.deepchords.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -312,7 +312,7 @@
CODE_SIGN_ENTITLEMENTS = ShenYin/ShenYin.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 1100;
+ CURRENT_PROJECT_VERSION = 1002;
DEVELOPMENT_TEAM = G23X75CJ67;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@@ -338,7 +338,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- MARKETING_VERSION = 1.0.1;
+ MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.deepchords.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
diff --git a/ShenYin/ShenYin/JoySdk/JoyBleManager.swift b/ShenYin/ShenYin/JoySdk/JoyBleManager.swift
index 971d7c7..5bed6f5 100644
--- a/ShenYin/ShenYin/JoySdk/JoyBleManager.swift
+++ b/ShenYin/ShenYin/JoySdk/JoyBleManager.swift
@@ -1,88 +1,259 @@
-////
-//// JotBleManager.swift
-//// ShenYin
-////
-//// Created by liangshi on 2025/12/23.
-////
//
-//public class JoyBleManager {
-// public static let shared = JoyBleManager()
-// private var connectPeripheral: CBPeripheral?
-// private var writeCha: CBCharacteristic?
-//}
-//extension JoyBleManager{
-// static func getMac(_ dict:[String:Any])->String?{
-// if let advMsd = dict[CBAdvertisementDataManufacturerDataKey] as? Data {
-// if (advMsd.count >= 13) {
-// let mac = advMsd[7...12];
-// return mac.map { String($0, radix: 16).padLeft(toLength: 2, withPad: "0") }.joined(separator: ":").uppercased()
-// } else {
-// return nil
+// Untitled.swift
+// ShenYin
+//
+// Created by liangshi on 2025/8/28.
+//
+
+import UIKit
+import CoreBluetooth
+import AVFAudio
+
+class DCPeripheral{
+ var device:CBPeripheral!
+ var mac = ""
+ init(device: CBPeripheral!, mac: String = "") {
+ self.device = device
+ self.mac = mac
+ }
+}
+
+class JoyBleManager: NSObject {
+ var discoverDeviceCallback: (([DCPeripheral]) -> Void)?
+ var didConnectDeviceCallback: ((DCPeripheral) -> Void)?
+ var conetedFailureCallback: ((DCPeripheral) -> Void)?
+
+ private var centralManager: CBCentralManager!
+ var devices: [DCPeripheral] = []
+ var connectPeripheral: DCPeripheral?
+ static let shared = JoyBleManager()
+ var isConnetd:Bool = false
+
+ private override init() {
+ super.init()
+ centralManager = CBCentralManager(delegate: self, queue: nil)
+ }
+}
+extension JoyBleManager:CBCentralManagerDelegate{
+ func centralManagerDidUpdateState(_ central: CBCentralManager) {
+ Logger.debug("èçç¶æ",central.state.rawValue)
+ switch central.state {
+ case.unknown:
+ break
+ case.resetting:
+ break
+ case.unsupported:
+ break
+ case.unauthorized:
+ break
+ case.poweredOff:
+ self.isConnetd = false
+ NotificationManager.post(type: .deviceValidChange, objtect: nil)
+ break
+ case.poweredOn:
+// startScanDevice()
+ checkConectState()
+ break
+ @unknown default:
+ break
+ }
+ OtaMananger.shared.otaManager.centralManagerDidUpdateState(central)
+ }
+
+ func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
+ if devices.map({ $0.device }).contains(peripheral) {
+ return
+ }
+
+ // DB209A55-DD0E-5031-29FA-40D734C34971
+ // "edr:21140DE4C3D9"
+ // "ble:21140D2CC682"
+// if peripheral.identifier.uuidString != "DB209A55-DD0E-5031-29FA-40D734C34971" {
+// return
+// }
+ let mac = JoySdkManager.getMac(advertisementData) ?? ""
+ devices.append(DCPeripheral(device: peripheral,mac: mac))
+ Logger.debug(peripheral)
+ discoverDeviceCallback?(devices)
+ }
+
+ func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
+ stopScanDevice()
+ Logger.debug("èçå·²è¿æ¥ \(peripheral)")
+
+ peripheral.delegate = self
+ peripheral.discoverServices([CBUUID(string: JoySdkManager.serviceUUID),CBUUID(string: OtaMananger.otaServiceUUId)]);
+ }
+ func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
+ Logger.debug("peripheral: %@ failed to connect", peripheral)
+ conetedFailureCallback?(connectPeripheral!)
+ }
+ func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
+ Logger.debug("èçå·²æå¼ \(peripheral)")
+ self.isConnetd = false
+ NotificationManager.post(type: .deviceValidChange, objtect: nil)
+ OtaMananger.shared.otaManager.centralManager(central, didDisconnectPeripheral: peripheral, error: error)
+ checkConectState()
+ }
+}
+
+extension JoyBleManager: CBPeripheralDelegate {
+ func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
+ Logger.debug("åç°æå¡æå")
+ for service in peripheral.services! {
+ Logger.debug("peripheral service: %@", service)
+ peripheral.discoverCharacteristics(nil, for: service)
+ }
+
+ }
+
+ func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
+ if (service.uuid.uuidString == JoySdkManager.serviceUUID) {
+ JoySdkManager.shared.peripheral(peripheral, didDiscoverCharacteristicsFor: service, error: error)
+ }
+ else if service.uuid.uuidString == OtaMananger.otaServiceUUId{
+ OtaMananger.shared.otaManager.peripheral(peripheral, didDiscoverCharacteristicsFor: service, error: error)
+ }
+ }
+
+ func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: (any Error)?) {
+ if (characteristic.isNotifying == true && characteristic.service?.uuid.uuidString == JoySdkManager.serviceUUID && characteristic.uuid.uuidString == JoySdkManager.notifyUUID) {
+ Logger.debug("ç¹å¾ä½¿è½æå")
+ JoySdkManager.shared.bleConnected()
+ }
+ if OtaMananger.isOtadata(characteristic){
+ OtaMananger.shared.otaManager.peripheral(peripheral, didUpdateNotificationStateFor: characteristic, error: error)
+ }
+ }
+
+ func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
+// Logger.debug("æ¶å°æ°æ® ===uUId ",characteristic.uuid)
+ if OtaMananger.isOtadata(characteristic){
+ if let _ = characteristic.value,error == nil {
+ OtaMananger.shared.otaManager.peripheral(peripheral, didUpdateValueFor: characteristic)
+ }
+ else{
+ Logger.debug("ota æ¶å°æ°æ® ===\(characteristic.uuid)","æ æ°æ®")
+ }
+ }
+ else {
+ //MARK: éè¦é
ç½®ä¼ å
¥æ°æ®
+ JoySdkManager.shared.receiveValue(characteristic)
+ }
+ }
+
+ 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)?) {
+
+ }
+}
+
+extension JoyBleManager{
+ func startScanDevice() {
+// centralManager.stopScan()
+ Logger.debug("æ«æä¸...")
+ Logger.debug("èçç¶æ",centralManager.state.rawValue)
+ devices = []
+// let list = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: kJoyGemAIServiceUUID)])
+// Logger.debug("å·²è¿æ¥è®¾å¤",list)
+// for item in list {
+// if let mac = DeviceCache.shared.getMac(item.identifier.uuidString){
+// devices.append(DCPeripheral(device: item,mac: mac))
// }
-// } else {
-// return nil
// }
-// }
-//}
-////public extension JoyBleManager{
-//// func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
-//// Logger.debug("èçå·²è¿æ¥ \(peripheral)")
-//// connectPeripheral = peripheral
-//// }
-//// func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
-//// Logger.debug("peripheral: %@ failed to connect", peripheral)
-//// }
-//// func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
-//// Logger.debug("èçå·²æå¼ \(peripheral)")
-//// }
-////
-////// func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
-////// Logger.debug("åç°æå¡æå")
-////// for service in peripheral.services! {
-////// Logger.debug("peripheral service: %@", service)
-////// peripheral.discoverCharacteristics(nil, for: service)
-////// }
-//////
-////// }
-////// func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
-////// if let list = service.characteristics{
-////// Logger.debug("åç°ç¹å¾",list)
-////// for char in list{
-////// Logger.debug(char)
-////// peripheral.setNotifyValue(true, for: char)
-////// if char.uuid.uuidString == "AE03" {
-////// writeCha = char
-////// StarburstSdk.shared().bleConnected()
-////// }
-////// }
-////// }
-////// }
-//////
-////// func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
-////// // Logger.debug("æ¶ ",characteristic.uuid,characteristic.value?.joined() ?? "")
-////// guard let data = characteristic.value else { return }
-////// if data.count > 4 && data[0] == 0xBA {
-////// if let sender = BleSender.answer(data) {
-////// sender.completion?(.response.code(.success).value(data))
-////// if data[1] == 0x10,data[2] == 0x01{
-////// //é³ä¹å表åå
ï¼è§£æçæ¶åå¤ç
-////// }
-////// else{
-////// sender.deinitTimer()
-////// sender.remove()
-////// }
-////// return
-////// }
-////// else if data[1] == 0x0D{
-////// let subData = data.subdata(in: 2..Bool{
+ guard let device = connectPeripheral else { return false }
+ if device.mac == mac {
+ return isConnetd
+ }
+ else{
+ return false
+ }
+ }
+
+// #è¿æ¥æé®é¢ï¼åºå½è·å设置éé¢å·²è¿æ¥ç设å¤
+ func connect(mac:String, finished:@escaping ((Bool) -> Void)){
+ JoyBleManager.shared.cancel()
+ JoyBleManager.shared.discoverDeviceCallback = { list in
+ if list.count <= 0 {
+ return
+ }
+ for item in list {
+ if item.mac == mac {
+ JoyBleManager.shared.connectPeripheral(item)
+ break
+ }
+ }
+ }
+ JoyBleManager.shared.didConnectDeviceCallback = { device in
+ finished(true)
+ }
+ JoyBleManager.shared.conetedFailureCallback = { device in
+ finished(false)
+ }
+ JoyBleManager.shared.startScanDevice()
+ }
+
+ func checkSettingsConnected()->[CBPeripheral]{
+ let list = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: JoySdkManager.serviceUUID)])
+ Logger.debug("å·²è¿æ¥è®¾å¤",list)
+ return list
+ }
+}
+
+extension JoyBleManager{
+ func checkConectState(){
+ guard let mac = connectPeripheral?.mac else {
+ return
+ }
+ if isConnetd {
+ return
+ }
+ connect(mac: mac) {result in
+ }
+
+ DispatchQueue.main.asyncAfter(deadline:.now() + 10) {
+ self.checkConectState()
+ }
+ }
+}
diff --git a/ShenYin/ShenYin/JoySdk/JoySdkManager.swift b/ShenYin/ShenYin/JoySdk/JoySdkManager.swift
index dcf455d..4a17dfe 100644
--- a/ShenYin/ShenYin/JoySdk/JoySdkManager.swift
+++ b/ShenYin/ShenYin/JoySdk/JoySdkManager.swift
@@ -132,10 +132,10 @@ extension JoySdkManager : JoyGemAIManagerDelegate {
Logger.debug(error)
}
- DeviceCache.saveLastConnected(mac: BleManager.shared.connectPeripheral!.mac)
- DeviceCache.shared.add(BleManager.shared.connectPeripheral!.device.identifier.uuidString, mac: BleManager.shared.connectPeripheral!.mac)
- BleManager.shared.isConnetd = true
- BleManager.shared.didConnectDeviceCallback?(BleManager.shared.connectPeripheral!)
+ DeviceCache.saveLastConnected(mac: JoyBleManager.shared.connectPeripheral!.mac)
+ DeviceCache.shared.add(JoyBleManager.shared.connectPeripheral!.device.identifier.uuidString, mac: JoyBleManager.shared.connectPeripheral!.mac)
+ JoyBleManager.shared.isConnetd = true
+ JoyBleManager.shared.didConnectDeviceCallback?(JoyBleManager.shared.connectPeripheral!)
NotificationManager.post(type: .deviceValidChange, objtect: nil)
DeviceVM.updateOtaVersion()
}
@@ -201,17 +201,23 @@ extension JoySdkManager : JoyGemAIManagerDelegate {
extension JoySdkManager : JoyGemAIManagerDataSource {
func joyGemSend(_ data: Data, with characteristic: CBCharacteristic) {
// print("åé",data.map { String($0) }.joined(separator: ""))
- BleManager.shared.joySdkSend(data, with: characteristic)
+ JoyBleManager.shared.joySdkSend(data, with: characteristic)
}
}
extension JoySdkManager{
static func getMac(_ dict:[String:Any])->String?{
+
if let advMsd = dict[CBAdvertisementDataManufacturerDataKey] as? Data {
if (advMsd.count >= 13) {
let mac = advMsd[7...12];
- return mac.map { String($0, radix: 16).padLeft(toLength: 2, withPad: "0") }.joined(separator: ":").uppercased()
+ let text = mac.map { String($0, radix: 16).padLeft(toLength: 2, withPad: "0") }.joined(separator: ":").uppercased()
+ Logger.debug(dict)
+ Logger.debug(advMsd)
+ Logger.debug(mac.joined())
+ Logger.debug(text)
+ return text
} else {
return nil
}
diff --git a/ShenYin/ShenYin/Launch/BleManager.swift b/ShenYin/ShenYin/Launch/BleManager.swift
deleted file mode 100644
index ab82dd9..0000000
--- a/ShenYin/ShenYin/Launch/BleManager.swift
+++ /dev/null
@@ -1,259 +0,0 @@
-//
-// Untitled.swift
-// ShenYin
-//
-// Created by liangshi on 2025/8/28.
-//
-
-import UIKit
-import CoreBluetooth
-import AVFAudio
-
-class DCPeripheral{
- var device:CBPeripheral!
- var mac = ""
- init(device: CBPeripheral!, mac: String = "") {
- self.device = device
- self.mac = mac
- }
-}
-
-class BleManager: NSObject {
- var discoverDeviceCallback: (([DCPeripheral]) -> Void)?
- var didConnectDeviceCallback: ((DCPeripheral) -> Void)?
- var conetedFailureCallback: ((DCPeripheral) -> Void)?
-
- private var centralManager: CBCentralManager!
- var devices: [DCPeripheral] = []
- var connectPeripheral: DCPeripheral?
- static let shared = BleManager()
- var isConnetd:Bool = false
-
- private override init() {
- super.init()
- centralManager = CBCentralManager(delegate: self, queue: nil)
- }
-}
-extension BleManager:CBCentralManagerDelegate{
- func centralManagerDidUpdateState(_ central: CBCentralManager) {
- Logger.debug("èçç¶æ",central.state.rawValue)
- switch central.state {
- case.unknown:
- break
- case.resetting:
- break
- case.unsupported:
- break
- case.unauthorized:
- break
- case.poweredOff:
- self.isConnetd = false
- NotificationManager.post(type: .deviceValidChange, objtect: nil)
- break
- case.poweredOn:
-// startScanDevice()
- checkConectState()
- break
- @unknown default:
- break
- }
- OtaMananger.shared.otaManager.centralManagerDidUpdateState(central)
- }
-
- func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
- if devices.map({ $0.device }).contains(peripheral) {
- return
- }
-
- // DB209A55-DD0E-5031-29FA-40D734C34971
- // "edr:21140DE4C3D9"
- // "ble:21140D2CC682"
-// if peripheral.identifier.uuidString != "DB209A55-DD0E-5031-29FA-40D734C34971" {
-// return
-// }
- let mac = JoySdkManager.getMac(advertisementData) ?? ""
- devices.append(DCPeripheral(device: peripheral,mac: mac))
- Logger.debug(peripheral)
- discoverDeviceCallback?(devices)
- }
-
- func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
- stopScanDevice()
- Logger.debug("èçå·²è¿æ¥ \(peripheral)")
-
- peripheral.delegate = self
- peripheral.discoverServices([CBUUID(string: JoySdkManager.serviceUUID),CBUUID(string: OtaMananger.otaServiceUUId)]);
- }
- func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
- Logger.debug("peripheral: %@ failed to connect", peripheral)
- conetedFailureCallback?(connectPeripheral!)
- }
- func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
- Logger.debug("èçå·²æå¼ \(peripheral)")
- self.isConnetd = false
- NotificationManager.post(type: .deviceValidChange, objtect: nil)
- OtaMananger.shared.otaManager.centralManager(central, didDisconnectPeripheral: peripheral, error: error)
- checkConectState()
- }
-}
-
-extension BleManager: CBPeripheralDelegate {
- func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
- Logger.debug("åç°æå¡æå")
- for service in peripheral.services! {
- Logger.debug("peripheral service: %@", service)
- peripheral.discoverCharacteristics(nil, for: service)
- }
-
- }
-
- func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
- if (service.uuid.uuidString == JoySdkManager.serviceUUID) {
- JoySdkManager.shared.peripheral(peripheral, didDiscoverCharacteristicsFor: service, error: error)
- }
- else if service.uuid.uuidString == OtaMananger.otaServiceUUId{
- OtaMananger.shared.otaManager.peripheral(peripheral, didDiscoverCharacteristicsFor: service, error: error)
- }
- }
-
- func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: (any Error)?) {
- if (characteristic.isNotifying == true && characteristic.service?.uuid.uuidString == JoySdkManager.serviceUUID && characteristic.uuid.uuidString == JoySdkManager.notifyUUID) {
- Logger.debug("ç¹å¾ä½¿è½æå")
- JoySdkManager.shared.bleConnected()
- }
- if OtaMananger.isOtadata(characteristic){
- OtaMananger.shared.otaManager.peripheral(peripheral, didUpdateNotificationStateFor: characteristic, error: error)
- }
- }
-
- func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
-// Logger.debug("æ¶å°æ°æ® ===uUId ",characteristic.uuid)
- if OtaMananger.isOtadata(characteristic){
- if let _ = characteristic.value,error == nil {
- OtaMananger.shared.otaManager.peripheral(peripheral, didUpdateValueFor: characteristic)
- }
- else{
- Logger.debug("ota æ¶å°æ°æ® ===\(characteristic.uuid)","æ æ°æ®")
- }
- }
- else {
- //MARK: éè¦é
ç½®ä¼ å
¥æ°æ®
- JoySdkManager.shared.receiveValue(characteristic)
- }
- }
-
- 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)?) {
-
- }
-}
-
-extension BleManager{
- func startScanDevice() {
-// centralManager.stopScan()
- Logger.debug("æ«æä¸...")
- Logger.debug("èçç¶æ",centralManager.state.rawValue)
- devices = []
-// let list = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: kJoyGemAIServiceUUID)])
-// Logger.debug("å·²è¿æ¥è®¾å¤",list)
-// for item in list {
-// if let mac = DeviceCache.shared.getMac(item.identifier.uuidString){
-// devices.append(DCPeripheral(device: item,mac: mac))
-// }
-// }
- centralManager.scanForPeripherals(withServices: [CBUUID(string: JoySdkManager.serviceUUID)],options: [CBCentralManagerScanOptionAllowDuplicatesKey : false])
- discoverDeviceCallback?(devices)
- }
-
- func stopScanDevice() {
- centralManager.stopScan()
- }
-
- func connectPeripheral(_ peripheral: DCPeripheral) {
- connectPeripheral = peripheral
- Logger.debug("è¿æ¥ä¸...")
- centralManager.connect(peripheral.device, options: [CBConnectPeripheralOptionEnableTransportBridgingKey:true])
- }
-
- func cancel() {
- guard let peripheral = connectPeripheral else { return }
- self.isConnetd = false
- NotificationManager.post(type: .deviceValidChange, objtect: nil)
- centralManager.cancelPeripheralConnection(peripheral.device)
- connectPeripheral = nil
- }
- func unbind(_ peripheral: DCPeripheral){
- if let mac = connectPeripheral?.mac ,peripheral.mac == mac{
- cancel()
- }
- }
-}
-
-extension BleManager{
- func joySdkSend(_ data: Data, with characteristic: CBCharacteristic) {
- if let connectPeripheral = connectPeripheral{
- connectPeripheral.device.writeValue(data, for: characteristic, type:.withoutResponse)
- }
- }
-}
-
-extension BleManager{
- func isConected(mac:String)->Bool{
- guard let device = connectPeripheral else { return false }
- if device.mac == mac {
- return isConnetd
- }
- else{
- return false
- }
- }
-
-// #è¿æ¥æé®é¢ï¼åºå½è·å设置éé¢å·²è¿æ¥ç设å¤
- func connect(mac:String, finished:@escaping ((Bool) -> Void)){
- BleManager.shared.cancel()
- BleManager.shared.discoverDeviceCallback = { list in
- if list.count <= 0 {
- return
- }
- for item in list {
- if item.mac == mac {
- BleManager.shared.connectPeripheral(item)
- break
- }
- }
- }
- BleManager.shared.didConnectDeviceCallback = { device in
- finished(true)
- }
- BleManager.shared.conetedFailureCallback = { device in
- finished(false)
- }
- BleManager.shared.startScanDevice()
- }
-
- func checkSettingsConnected()->[CBPeripheral]{
- let list = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: JoySdkManager.serviceUUID)])
- Logger.debug("å·²è¿æ¥è®¾å¤",list)
- return list
- }
-}
-
-extension BleManager{
- func checkConectState(){
- guard let mac = connectPeripheral?.mac else {
- return
- }
- if isConnetd {
- return
- }
- connect(mac: mac) {result in
- }
-
- DispatchQueue.main.asyncAfter(deadline:.now() + 10) {
- self.checkConectState()
- }
- }
-}
diff --git a/ShenYin/ShenYin/Ota/OtaManager.swift b/ShenYin/ShenYin/Ota/OtaManager.swift
index 5c1ef35..2b57aa7 100644
--- a/ShenYin/ShenYin/Ota/OtaManager.swift
+++ b/ShenYin/ShenYin/Ota/OtaManager.swift
@@ -33,9 +33,9 @@ extension OtaMananger:JLBleAssistManagerOtaDelegate{
ProgressHUDHelper.shared.hide()
YLprogressHUD.showAutoHiden("å级æå".l10n)
Logger.debug("å级æå")
-// let mac = BleManager.shared.connectPeripheral?.mac ?? ""
-// BleManager.shared.cancel()
-// BleManager.shared.connect(mac: mac) { result in
+// let mac = JoyBleManager.shared.connectPeripheral?.mac ?? ""
+// JoyBleManager.shared.cancel()
+// JoyBleManager.shared.connect(mac: mac) { result in
//
// }
}
diff --git a/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC1.swift b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC1.swift
deleted file mode 100644
index 03b6570..0000000
--- a/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishVC1.swift
+++ /dev/null
@@ -1,227 +0,0 @@
-////
-//// Untitled.swift
-//// ShenYin
-////
-//// Created by liangshi on 2025/11/27.
-////
-//
-//import UIKit
-//import JoyGemAI
-//import AVFAudio
-//class Chinese2EnglishVC:BaseVC{
-// let toolBar = RecordBar()
-// let tableView = UITableView(frame: CGRectZero, style: .plain)
-// let bg = UIImageView()
-// var dataList:[(Chinese2EnglishCellModel,Int)] = []
-// var recordFilePath : String?
-// var startIndex = 0//è®°å½å¼å§å½é³ç次æ°ï¼ç¨äºåºåè¿åçæ°æ®
-//
-// deinit {
-// PcmSound.sharedInstance().stopAudioUnit()
-// PcmSound.sharedInstance().cleanup()
-// }
-//
-// override func setupViews() {
-// navBar.title = "ä¸è±äºè¯".l10n
-// navBar.rightView.isHidden = false
-// navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal)
-// view.addSubview(tableView)
-// view.addSubview(toolBar)
-// view.addSubview(bg)
-//
-// toolBar.delegate = self
-// toolBar.isChienseEnglish = true
-// toolBar.leftItem.valueLabel.text = "å·¦è³".l10n
-// toolBar.rightItem.valueLabel.text = "å³è³".l10n
-//
-// tableView.backgroundColor = .clear
-// tableView.delegate = self
-// tableView.dataSource = self
-// tableView.estimatedRowHeight = 60
-// tableView.separatorStyle = .none
-// tableView.register(Chinese2EnglishCell.self, forCellReuseIdentifier: Chinese2EnglishCell.reuseID)
-//
-// bg.image = UIImage(named: "translate_bg")
-//
-//
-// }
-// override func setupLayout() {
-// toolBar.snp.makeConstraints { make in
-// make.width.centerX.equalToSuperview()
-// make.height.equalTo(120)
-// make.bottom.equalToSuperview().inset(20)
-// }
-// tableView.snp.makeConstraints { make in
-// make.top.equalToSuperview().inset(80)
-// make.left.right.equalToSuperview()
-// make.bottom.equalTo(toolBar.snp.top)
-// }
-// bg.snp.makeConstraints { make in
-// make.size.equalTo(90)
-// make.center.equalTo(tableView)
-// }
-// }
-// override func setupData() {
-// JoyGemSIDeviceManager.shared().delegate = self
-//
-// PcmSound.sharedInstance().delegate = self;
-// PcmSound.sharedInstance().setup(16000, withchannels: 1)
-// // do {
-// // try AVAudioSession.sharedInstance().setActive(true)
-// // } catch {
-// // print(error)
-// // }
-//
-// if TipsCache.needShow(type: .chinese2english) {
-// RecordTipsView(type: .chinese2english).show()
-// }
-// }
-// override func viewDidAppear(_ animated: Bool) {
-// super.viewDidAppear(animated)
-// navigationController?.fd_fullscreenPopGestureRecognizer?.isEnabled = false
-// }
-// override func viewDidDisappear(_ animated: Bool) {
-// super.viewDidDisappear(animated)
-// navigationController?.fd_fullscreenPopGestureRecognizer?.isEnabled = true
-// }
-// override func navleftViewTapped() {
-// if toolBar.recordBtn.isSelected {
-// CustomAlert.showWith(title: "æç¤º".l10n, messgage: "å½åæ£å¨å½é³ï¼ç¡®å®æ¾å¼å½åå½é³å".l10n, cancelCallback: {}) {
-// JoyGemSIDeviceManager.shared().stop()
-// PcmSound.sharedInstance().stopAudioUnit()
-// PcmSound.sharedInstance().cleanup()
-// super.navleftViewTapped()
-// }
-// }
-// else{
-// super.navleftViewTapped()
-// }
-// }
-// override func navRightViewTapped() {
-// let tip = RecordTipsView(type: .chinese2english)
-// tip.show()
-// }
-// func refreshData(){
-// tableView.reloadData()
-// if dataList.count > 0 {
-// tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true)
-// bg.isHidden = true
-// }
-// else{
-// bg.isHidden = false
-// }
-// }
-//}
-//extension Chinese2EnglishVC:RecordBarDelegate{
-// func recordBarLanguageChange(_ bar: RecordBar) {
-//
-// }
-//
-//
-// func recordBar(_ bar: RecordBar, stateChange state: RecordBarSate) {
-// if state == .start {
-// startIndex += 100000
-// JoyGemSIDeviceManager.shared().originalLanguage = bar.leftItem.language.value
-// JoyGemSIDeviceManager.shared().targetLanguage = bar.rightItem.language.value
-// JoyGemSIDeviceManager.shared().start()
-// // do {
-// // try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.defaultToSpeaker])
-// // try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
-// // } catch {
-// // print(error)
-// // }
-// }
-// else if state == .stop{
-// JoyGemSIDeviceManager.shared().stop()
-// }
-// }
-//}
-//extension Chinese2EnglishVC:UITableViewDelegate,UITableViewDataSource {
-// func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-// return dataList.count
-// }
-//
-// func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-// let cell = Chinese2EnglishCell.cell(withTableView: tableView, indexPath: indexPath)
-// let (vallue,index) = dataList[indexPath.row]
-// cell.data = vallue
-// return cell
-// }
-// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-//
-// }
-//}
-//
-//extension Chinese2EnglishVC:JoyGemSIDeviceManagerDelegate{
-//
-//
-// func siDeviceManagerStopped(_ manager: JoyGemSIDeviceManager, reason code: JoyGemRecordStopCode) {
-// Logger.debug("忢",code.rawValue)
-// if code == .passively {
-// toolBar.recordBtn.isSelected = false
-// }
-// }
-//
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateRaw model: JoyGemAsrModel) {
-// Logger.debug("text: \(model.text),index: \(model.index)")
-// let msg = dataList.firstIndex (where: { (str,idx) in
-// return idx == Int(model.index) + startIndex
-// })
-// if (msg == nil) {
-// dataList.append((Chinese2EnglishCellModel(send: model.text),Int(model.index) + startIndex))
-// } else {
-// let (item,_) = dataList[msg!]
-// item.send = model.text
-// }
-// //
-// // ///çå¬å°ä¸å¥è¯ç»æï¼èªå¨ç»æå½åå½é³
-// // if (model.definite == true) {
-// // stopEarRecord()
-// // }
-// refreshData()
-// }
-//
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateTranslate model: JoyGemAsrModel) {
-// let msg = dataList.firstIndex (where: { (str,idx) in
-// return idx == Int(model.index) + startIndex
-// })
-// if (msg == nil) {
-// dataList.append((Chinese2EnglishCellModel(response: model.text),Int(model.index) + startIndex))
-// } else {
-// let (item,_) = dataList[msg!]
-// item.response = model.text
-// }
-// refreshData()
-// }
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateAudioData data: Data, sampleRate: UInt) {
-// PcmSound.sharedInstance().feed(data)
-// }
-// // func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateAudioData data: Data) {
-// // pcmData.append(data)
-// // PcmSound.sharedInstance().feed(data)
-// // }
-//
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, update mode: JoyGemRecordMode) {
-//
-// }
-//
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, saveFile path: String) {
-// Logger.debug("path: \(path)")
-// recordFilePath = path
-// }
-//
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, stateChange code: JoyGemStateCode) {
-// Logger.debug("code: \(code)")
-// }
-//
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, onError code: JoyGemErrorCode) {
-//
-// }
-//}
-//extension Chinese2EnglishVC:PcmSoundDelegate{
-// func remaining(_ frames: UInt) {
-//
-// }
-//
-//
-//}
diff --git a/ShenYin/ShenYin/UI/Home/Device/HomeDeviceCell.swift b/ShenYin/ShenYin/UI/Home/Device/HomeDeviceCell.swift
index 81ea1cc..20e76c2 100644
--- a/ShenYin/ShenYin/UI/Home/Device/HomeDeviceCell.swift
+++ b/ShenYin/ShenYin/UI/Home/Device/HomeDeviceCell.swift
@@ -21,7 +21,7 @@ class HomeDeviceCell: BaseCollectionViewCell {
icon.kf.setImage(with: model.image.yc.asUrl)
- if BleManager.shared.isConected(mac: model.mac) {
+ if JoyBleManager.shared.isConected(mac: model.mac) {
valueLabel.text = "å·²è¿æ¥".l10n
bgView.alpha = 1
}
diff --git a/ShenYin/ShenYin/UI/Home/Device/HomeDeviceVC.swift b/ShenYin/ShenYin/UI/Home/Device/HomeDeviceVC.swift
index bc4a4cd..21c3218 100644
--- a/ShenYin/ShenYin/UI/Home/Device/HomeDeviceVC.swift
+++ b/ShenYin/ShenYin/UI/Home/Device/HomeDeviceVC.swift
@@ -87,7 +87,7 @@ class HomeDeviceVC:BaseVC{
func reloadData() {
DeviceVM.shared.refresh {[weak self] result in
self?.collectionView.reloadData()
- if BleManager.shared.isConnetd{
+ if JoyBleManager.shared.isConnetd{
return
}
var autoConnetced = false
@@ -110,7 +110,7 @@ class HomeDeviceVC:BaseVC{
override func navRightViewTapped() {
App.shared.goToPage(BleScanVC())
// App.shared.goToPage(CalendarPickerVC())
-// BleManager.shared.checkSettingsConnected()
+// JoyBleManager.shared.checkSettingsConnected()
// ChatCache.shared.LargeDateDemoSave()
}
@objc func editAction(){
@@ -134,12 +134,12 @@ class HomeDeviceVC:BaseVC{
guard let self = self else {return}
if model.isSuccess{
YLprogressHUD.hidden()
- if let mac0 = BleManager.shared.connectPeripheral?.mac,let mac1 = DeviceCache.getLastConnected(),mac0 == mac1{
+ if let mac0 = JoyBleManager.shared.connectPeripheral?.mac,let mac1 = DeviceCache.getLastConnected(),mac0 == mac1{
DeviceCache.remove()
}
DeviceVM.shared.dataList.removeAll(where: {$0.deviceId == deviceModel.deviceId})
collectionView.reloadData()
- BleManager.shared.cancel()
+ JoyBleManager.shared.cancel()
reloadData()
}
else{
@@ -148,7 +148,7 @@ class HomeDeviceVC:BaseVC{
}
}
func startConectBle(_ model:HomeDeviceModel){
- BleManager.shared.connect(mac: model.mac) { result in
+ JoyBleManager.shared.connect(mac: model.mac) { result in
}
}
@objc func deviceChange(_ noti:Notification){
diff --git a/ShenYin/ShenYin/UI/Home/Dialog/DialogTranlateVC.swift b/ShenYin/ShenYin/UI/Home/Dialog/DialogTranlateVC.swift
index bb1331e..fef2eb8 100644
--- a/ShenYin/ShenYin/UI/Home/Dialog/DialogTranlateVC.swift
+++ b/ShenYin/ShenYin/UI/Home/Dialog/DialogTranlateVC.swift
@@ -68,13 +68,6 @@ class DialogTranslateVC:BaseVC{
}
}
override func setupData() {
-// dataList = [
-// DialogTranslateCellModel(send: "ä½ å¥½", response: "hello",isPhone: false),
-// DialogTranslateCellModel(send: "Nice to meet you", response: "å¾é«å
´è®¤è¯ä½ ",isPhone: true),
-// DialogTranslateCellModel(send: "æ·±å³ä»å¤©ä¸é¨å", response: "ShenZhen is raining today?",isPhone: false),
-// DialogTranslateCellModel(send: "YES", response: "æ¯ç",isPhone: true),
-// ]
-
JoyGemSIManager.shared().delegate = self
JoyGemSIDeviceManager.shared().delegate = self
@@ -192,12 +185,8 @@ extension DialogTranslateVC:DialogRecordBarDelegate{
dataList.append(model)
refreshData()
-// JoyGemSIManager.shared().originalLanguage = toolBar.languageView.leftItem.language.value
-// JoyGemSIManager.shared().targetLanguage = toolBar.languageView.rightItem.language.value
JoyGemSIDeviceManager.shared().originalLanguage = toolBar.languageView.leftItem.language.value
JoyGemSIDeviceManager.shared().targetLanguage = toolBar.languageView.rightItem.language.value
- Logger.debug("æºè¯è¨",JoyGemSIManager.shared().originalLanguage)
- Logger.debug("ç®æ è¯è¨",JoyGemSIManager.shared().targetLanguage)
JoyGemSIDeviceManager.shared().start()
otherPcm = Data()
do {
@@ -284,10 +273,6 @@ extension DialogTranslateVC : JoyGemSIManagerDelegate {
func siManager(_ manager: JoyGemSIManager, didUpdateAudioData data: Data, sampleRate: UInt) {
PcmSound.sharedInstance().feed(data)
}
-// func siManager(_ manager: JoyGemSIManager, didUpdateAudioData data: Data) {
-// PcmSound.sharedInstance().feed(data)
-// }
-
func siManager(_ manager: JoyGemSIManager, onError code: JoyGemErrorCode) {
}
@@ -353,11 +338,6 @@ extension DialogTranslateVC : JoyGemSIDeviceManagerDelegate {
func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateAudioData data: Data, sampleRate: UInt) {
PcmSound.sharedInstance().feed(data)
}
-// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateAudioData data: Data) {
-// //otherPcm.append(data)
-// PcmSound.sharedInstance().feed(data)
-// }
-
func siDeviceManager(_ manager: JoyGemSIDeviceManager, update mode: JoyGemRecordMode) {
}
@@ -377,7 +357,6 @@ extension DialogTranslateVC : JoyGemSIDeviceManagerDelegate {
extension DialogTranslateVC : PcmSoundDelegate {
-
func remaining(_ frames: UInt) {
Logger.debug("[frame:\(frames)]");
}
diff --git a/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift b/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift
index 8046078..9f0127a 100644
--- a/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift
+++ b/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift
@@ -101,7 +101,7 @@ class RecordTranslateVC:BaseVC{
override func navleftViewTapped() {
if toolBar.recordBtn.isSelected {
CustomAlert.showWith(title: "æç¤º".l10n, messgage: "å½åæ£å¨å½é³ï¼ç¡®å®æ¾å¼å½åå½é³åï¼".l10n, cancelCallback: {}) {
- JoyGemSIDeviceManager.shared().stop()
+ JoyGemSIManager.shared().stop()
PcmSound.sharedInstance().stopAudioUnit()
PcmSound.sharedInstance().cleanup()
super.navleftViewTapped()
diff --git a/ShenYin/ShenYin/UI/Home/Root/CurrentDeviceView.swift b/ShenYin/ShenYin/UI/Home/Root/CurrentDeviceView.swift
index b5c37b1..2ff25d8 100644
--- a/ShenYin/ShenYin/UI/Home/Root/CurrentDeviceView.swift
+++ b/ShenYin/ShenYin/UI/Home/Root/CurrentDeviceView.swift
@@ -36,7 +36,7 @@ class CurrentDeviceView: BaseView {
if let device = DeviceVM.shared.currentDevice{
imageView.kf.setImage(with: device.image.yc.asUrl)
- if BleManager.shared.isConnetd {
+ if JoyBleManager.shared.isConnetd {
alpha = 1
}
else{
diff --git a/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift b/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift
index a6e07e0..77165c2 100644
--- a/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift
+++ b/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift
@@ -78,7 +78,7 @@ class HomeFunctionView: BaseView {
var y = 0.0
for (index, value) in list.enumerated() {
let view = HomeCell()
- view.enable = BleManager.shared.isConnetd
+ view.enable = JoyBleManager.shared.isConnetd
addSubview(view)
view.type = value
@@ -99,7 +99,7 @@ class HomeFunctionView: BaseView {
@objc func deviceChange(_ noti:Notification){
for item in self.subviews{
if let view = item as? HomeCell {
- view.enable = BleManager.shared.isConnetd
+ view.enable = JoyBleManager.shared.isConnetd
}
}
}
@@ -180,7 +180,7 @@ class HomeCell: BaseView {
}
}
@objc func tapAction(){
- if !BleManager.shared.isConnetd {
+ if !JoyBleManager.shared.isConnetd {
return
}
switch type {
diff --git a/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift b/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift
index 93ba790..4af2def 100644
--- a/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift
+++ b/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift
@@ -51,7 +51,7 @@ class HomeHeadView: BaseView {
v.text = "AI" + "ä¼ä¼´ï¼éå«éå°".l10n
}
arrowIcon.image = UIImage(named: "arrow_2")
- self.enable = BleManager.shared.isConnetd
+ self.enable = JoyBleManager.shared.isConnetd
NotificationManager.add(self, selector: #selector(deviceChange(_:)), forName: .deviceValidChange)
}
@@ -87,12 +87,12 @@ class HomeHeadView: BaseView {
}
@objc func chatAction(){
- if BleManager.shared.isConnetd {
+ if JoyBleManager.shared.isConnetd {
App.shared.goToPage(ChatVC())
}
}
@objc func deviceChange(_ noti:Notification){
- self.enable = BleManager.shared.isConnetd
+ self.enable = JoyBleManager.shared.isConnetd
}
}
diff --git a/ShenYin/ShenYin/UI/Home/Scan/BleScanVC.swift b/ShenYin/ShenYin/UI/Home/Scan/BleScanVC.swift
index 4751a30..40334fa 100644
--- a/ShenYin/ShenYin/UI/Home/Scan/BleScanVC.swift
+++ b/ShenYin/ShenYin/UI/Home/Scan/BleScanVC.swift
@@ -46,7 +46,7 @@ class BleScanVC: BaseVC{
}
}
override func setupData() {
- BleManager.shared.discoverDeviceCallback = {[weak self] devices in
+ JoyBleManager.shared.discoverDeviceCallback = {[weak self] devices in
self?.list = devices
self?.tableView.reloadData()
if devices.count > 0 {
diff --git a/ShenYin/ShenYin/UI/Home/Scan/DeviceVM.swift b/ShenYin/ShenYin/UI/Home/Scan/DeviceVM.swift
index 3ce8842..647193b 100644
--- a/ShenYin/ShenYin/UI/Home/Scan/DeviceVM.swift
+++ b/ShenYin/ShenYin/UI/Home/Scan/DeviceVM.swift
@@ -5,14 +5,13 @@
// Created by liangshi on 2025/10/20.
//
-//import JoyGemAI
class DeviceVM:BaseVM{
static let shared = DeviceVM()
var dataList = [HomeDeviceModel]()
var currentDevice:HomeDeviceModel?{
for item in dataList {
- if let device = BleManager.shared.connectPeripheral,device.mac == item.mac {
+ if let device = JoyBleManager.shared.connectPeripheral,device.mac == item.mac {
return item
}
}
@@ -33,17 +32,17 @@ class DeviceVM:BaseVM{
extension DeviceVM{
static func startScan(){
- BleManager.shared.startScanDevice()
+ JoyBleManager.shared.startScanDevice()
- BleManager.shared.didConnectDeviceCallback = { device in
+ JoyBleManager.shared.didConnectDeviceCallback = { device in
self.getDeviceInfo(device)
}
- BleManager.shared.conetedFailureCallback = { device in
+ JoyBleManager.shared.conetedFailureCallback = { device in
self.showError()
}
}
static func stopScan(){
- BleManager.shared.stopScanDevice()
+ JoyBleManager.shared.stopScanDevice()
}
static func startConnecte(_ data:DCPeripheral){
guard let name = data.device.name else {
@@ -59,7 +58,7 @@ extension DeviceVM{
ConnectPopView.shared.titleLabel.text = name
ConnectPopView.shared.stateDidChange(.connecting)
}
- BleManager.shared.connectPeripheral(data)
+ JoyBleManager.shared.connectPeripheral(data)
}
}
@@ -67,12 +66,12 @@ extension DeviceVM{
static func getDeviceInfo(_ device:DCPeripheral){
guard let prodName = device.device.name,prodName.count > 0 else{
showError()
- BleManager.shared.cancel()
+ JoyBleManager.shared.cancel()
return
}
JoyDevice.getDN { dn in
guard let deviceName = dn else{
- BleManager.shared.cancel()
+ JoyBleManager.shared.cancel()
self.showError()
return
}
@@ -95,7 +94,7 @@ extension DeviceVM{
}
else{
self.showError()
- BleManager.shared.cancel()
+ JoyBleManager.shared.cancel()
}
}
}
@@ -164,7 +163,7 @@ extension DeviceVM{
}
static func settingsConnected(){
- let list = BleManager.shared.checkSettingsConnected()
+ let list = JoyBleManager.shared.checkSettingsConnected()
if list.count == 0{
CustomAlert.showWith(title: "æç¤º", messgage: "请åå¾ç³»ç»è®¾ç½®è¿æ¥èç") {
diff --git a/ShenYin/ShenYin/UI/Mine/Device/DeviceInfoVC.swift b/ShenYin/ShenYin/UI/Mine/Device/DeviceInfoVC.swift
index f69e4ea..ab1367d 100644
--- a/ShenYin/ShenYin/UI/Mine/Device/DeviceInfoVC.swift
+++ b/ShenYin/ShenYin/UI/Mine/Device/DeviceInfoVC.swift
@@ -179,7 +179,7 @@ fileprivate class FooterView: BaseView {
if model.isSuccess{
YLprogressHUD.hidden()
DeviceVM.shared.dataList.removeAll(where: {$0.deviceId == self.deviceModel.deviceId})
- BleManager.shared.cancel()
+ JoyBleManager.shared.cancel()
App.shared.popPage()
}
else{
diff --git a/ShenYin/ShenYin/UI/Mine/Update/UpdateVC.swift b/ShenYin/ShenYin/UI/Mine/Update/UpdateVC.swift
index ae888b8..cdce644 100644
--- a/ShenYin/ShenYin/UI/Mine/Update/UpdateVC.swift
+++ b/ShenYin/ShenYin/UI/Mine/Update/UpdateVC.swift
@@ -69,7 +69,7 @@ class UpdateVC:BaseVC{
}
}
@objc func tapAction(){
- if !BleManager.shared.isConnetd{
+ if !JoyBleManager.shared.isConnetd{
YLprogressHUD.showAutoHiden("请å
è¿æ¥è®¾å¤".l10n)
return
}
diff --git a/ShenYin/ShenYin/UI/Mode/FindVC.swift b/ShenYin/ShenYin/UI/Mode/FindVC.swift
index 7d2d02d..fb84042 100644
--- a/ShenYin/ShenYin/UI/Mode/FindVC.swift
+++ b/ShenYin/ShenYin/UI/Mode/FindVC.swift
@@ -39,7 +39,7 @@ class FindVC:BaseVC{
v.value = "R"
}
titleLabel.do { v in
- v.text = BleManager.shared.connectPeripheral?.device.name ?? ""
+ v.text = JoyBleManager.shared.connectPeripheral?.device.name ?? ""
v.font = .regular(20)
v.textColor = .hexString("#121212")
diff --git a/ShenYin/ShenYin/UI/Mode/ModeEffectsView.swift b/ShenYin/ShenYin/UI/Mode/ModeEffectsView.swift
index 456e005..07fc6de 100644
--- a/ShenYin/ShenYin/UI/Mode/ModeEffectsView.swift
+++ b/ShenYin/ShenYin/UI/Mode/ModeEffectsView.swift
@@ -70,7 +70,7 @@ class ModeEffectsView: BaseView {
updateState()
}
func updateState(){
- if BleManager.shared.isConnetd {
+ if JoyBleManager.shared.isConnetd {
alpha = 1
}
else{
@@ -85,7 +85,7 @@ class ModeEffectsView: BaseView {
}
@objc func tapAction(_ tap:UITapGestureRecognizer){
- if !BleManager.shared.isConnetd {
+ if !JoyBleManager.shared.isConnetd {
return
}
let view = tap.view as! ItemView
diff --git a/ShenYin/ShenYin/UI/Mode/ModeVC.swift b/ShenYin/ShenYin/UI/Mode/ModeVC.swift
index 39e0989..0dab60c 100644
--- a/ShenYin/ShenYin/UI/Mode/ModeVC.swift
+++ b/ShenYin/ShenYin/UI/Mode/ModeVC.swift
@@ -21,7 +21,7 @@ class ModeVC:BaseVC{
}
override func setupViews() {
- self.navBar.title = BleManager.shared.connectPeripheral?.device.name ?? ""
+ self.navBar.title = JoyBleManager.shared.connectPeripheral?.device.name ?? ""
navBar.backgroundColor = .clear
view.backgroundColor = .color(.bgColor)
@@ -86,11 +86,11 @@ extension ModeVC{
updateState()
}
func updateState(){
- self.findView.alpha = BleManager.shared.isConnetd ? 1:0.3
+ self.findView.alpha = JoyBleManager.shared.isConnetd ? 1:0.3
}
func selectedModeAction(_ mode:ModeEffectsType){
- if !BleManager.shared.isConnetd {
+ if !JoyBleManager.shared.isConnetd {
return
}
JoyDevice.setEQMode(mode)
@@ -99,7 +99,7 @@ extension ModeVC{
}
}
@objc func findAction(){
- if BleManager.shared.isConnetd {
+ if JoyBleManager.shared.isConnetd {
App.shared.goToPage(FindVC())
}
diff --git a/ShenYin/ShenYin/UI/common/pop/ConnectPopView.swift b/ShenYin/ShenYin/UI/common/pop/ConnectPopView.swift
index 63139d0..e8efc4a 100644
--- a/ShenYin/ShenYin/UI/common/pop/ConnectPopView.swift
+++ b/ShenYin/ShenYin/UI/common/pop/ConnectPopView.swift
@@ -83,7 +83,7 @@ class ConnectPopView: BasePresentView2 {
v.textColor = .rgb(0x121212)
v.font = .regular(20)
v.textAlignment = .center
- v.text = BleManager.shared.connectPeripheral?.device.name ?? ""
+ v.text = JoyBleManager.shared.connectPeripheral?.device.name ?? ""
}
desLabel.do { (v) in
v.textColor = .rgb(0x121212)