break
case.poweredOn:
// startScanDevice()
- checkConnect()
+ checkConectState()
break
@unknown default:
break
NotificationManager.post(type: .deviceValidChange, objtect: nil)
disConnectDeviceCallback?(connectPeripheral!)
OtaMananger.shared.otaManager.centralManager(central, didDisconnectPeripheral: peripheral, error: error)
+ checkConectState()
}
func getMac(_ dict:[String:Any])->String?{
if let advMsd = dict[CBAdvertisementDataManufacturerDataKey] as? Data {
// devices.append(DCPeripheral(device: item,mac: mac))
// }
// }
-
centralManager.scanForPeripherals(withServices: [CBUUID(string: kJoyGemAIServiceUUID)],options: [CBCentralManagerScanOptionAllowDuplicatesKey : false])
discoverDeviceCallback?(devices)
}
-
- func checkConnect(){
-// let list = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: kJoyGemAIServiceUUID)])
-// for item in list {
-// devices.append(item)
-// break
-// }
-//
-// for item in devices{
-// if let current = CacheManager.shared.currentDevice,current.uuid == item.identifier.uuidString {
-// connectPeripheral(item)
-// return
-// }
-// }
-//
-// if connectPeripheral == nil || connectPeripheral?.state == .disconnected {
-// DispatchQueue.main.asyncAfter(deadline:.now() + 3) {
-// self.checkConnect()
-// }
-// }
- }
+
func stopScanDevice() {
centralManager.stopScan()
extension BleManager{
- func sendOtaData(_ data:Data){
-
+ func checkConectState(){
+ guard let mac = connectPeripheral?.mac else {
+ return
+ }
+ if isConnetd {
+ return
+ }
+ connect(mac: mac) {result in
+ }
+
+ DispatchQueue.main.asyncAfter(deadline:.now() + 30) {
+ self.checkConectState()
+ }
}
}
extension ChatVC:ChatRecordBarDelegate{
func recordBarCancel(_ toolBar: ChatRecordBar) {
- JoyGemChatManager.shared().stopChat()
+// JoyGemChatManager.shared().stopChat()
JoyGemChatManager.shared().stopSingleChat()
if let item = JoySdkManager.shared.dataList.last,item.content.isEmpty{
JoySdkManager.shared.dataList.removeLast()
JoySdkManager.shared.dataList.append(model)
refreshData()
- JoyGemChatManager.shared().stopChat()
+// JoyGemChatManager.shared().stopChat()
JoyGemChatManager.shared().startSingleChat()
}
private var isRecording = false
private var isCanceling = false
+
// 取消阈值(可根据需求调整)
private let cancelThreshold: CGFloat = 30
var state:RecordStatus = .start{
didSet{
+ Logger.debug("当前状态",state)
if state == .start {
animationBg.backgroundColor = .hexString("#0092E1")
animationView.isHidden = false
}
private func setupUI() {
- // 基本样式
-// backgroundColor = normalColor
-// layer.cornerRadius = 0 // 圆角在 layoutSubviews 中设置(保证正方形)
-// clipsToBounds = true
-
titleLabel.do { v in
v.textColor = .hexString("#121212")
v.font = .bold(16)
if isRecording {
animationView.isHidden = false
if isCanceling {
- animationBg.backgroundColor = .red
+ animationBg.backgroundColor = .hexString("#FF4E4E")
cancelLabel.isHidden = false
titleLabel.isHidden = true
}