From 8406b947dba539d84a2e24fda493955b76640a76 Mon Sep 17 00:00:00 2001 From: XiaNengQi <920986617@qq.com> Date: Mon, 23 Dec 2024 17:39:09 +0800 Subject: [PATCH] 8 --- .../UserInterfaceState.xcuserstate | Bin 33903 -> 35225 bytes demo-esp32/BlufiManager.swift | 45 +++++++++++++++++- demo-esp32/ContentView.swift | 18 ++++++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/demo-esp32.xcodeproj/project.xcworkspace/xcuserdata/xinceioskaifa.xcuserdatad/UserInterfaceState.xcuserstate b/demo-esp32.xcodeproj/project.xcworkspace/xcuserdata/xinceioskaifa.xcuserdatad/UserInterfaceState.xcuserstate index ea894d39bfc955014947026d47492973d726ac8f..f861441d31807996bd6914256d965e22ed5cf3f4 100644 GIT binary patch delta 14582 zcmb7q2UwHW7kA$MzClQsF^m|(j1a;O#6g6p?7byG0s#Vq0Ew$wlk2K=YuwtZ;NBMN ztX1o%TDP^eZmqj+tyb&!Za}pC?EiVbPoKOAH|M?gyyy2j=iGC0AC5!kTG6R$#Al=C zA!6=@^~L&O{jn@88_U6Ru|li_tHiWe6;_SaV2xN4_9ZqRn}AKkCSjAYDcDqO8a5rX zVzaTYv4z+oY%#VHTZOI0zQs0UTd=Lzci3+1Aa)2ljQxZi!G6ZhVE3^H*hB0Q_85DD zJ;k13e`3$E7uer8ietE)8SjGITDF2O_aXk3P8;F)+9o{i_= zxp*F)j~C#DcoD9`D{(Deg*V^^yb&LQ55+&jN8@AgvG^DG1bhlU8=r%JjW5I(;Vt-5 zd?mgfZ^L)u-{ZUR-S`3gNBk%J82&SU2LBB=U&L?VH}PBeUHm?Q5ja5*Bta20!4Pc1 zj_5+z6AlE2;1Z663n3)D2@&B#_!54EKM_Dk2pJJW#1e9%2ho%0NAxEWiBuw!C@0i} zhNvJa2`y1Y=!jZk1YssD1RzEdqlnSO7-B5(1@RT}HL=i4EFu;YEkrA^gjh-}BQ_IT zh^@pnVmq;e_>MS893l=AKM_ZW6U0g4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J+}YssS`C zYS`Iuq~X_wD-G8gZZ_O$xYzKo;Yq{uMxv2wWEw3Rtr~3_IgR#>j*ZTZDUHpB#+JrY zjqh~9x^mq_-FLdVx&^vc-D2HR-FDr6-C^A^-AUbP-4)#}-Cf;%-6P#g-5K2#s0Pu6GXv-G+80)3gjTwkHD)~oc5`l0$S^`d#`1`a}Ao`kp8BKk0wg|DwOFzpDRT|4jd}iE3h-teR|_oSWR5+?#k! X-c6AmtwjXGIzKHeIzPMKo4Wl!yo#(D diff --git a/demo-esp32/BlufiManager.swift b/demo-esp32/BlufiManager.swift index f7cda98..5f0ecf6 100644 --- a/demo-esp32/BlufiManager.swift +++ b/demo-esp32/BlufiManager.swift @@ -13,6 +13,7 @@ class BlufiManager: NSObject { var onError: ((String) -> Void)? var onConnected: (() -> Void)? var onConfigured: (() -> Void)? + var onDeviceFound: ((CBPeripheral, NSNumber) -> Void)? private override init() { super.init() @@ -21,17 +22,21 @@ class BlufiManager: NSObject { // 开始扫描设备 func startScan() { + print("开始扫描...") + // 扫描所有可用设备,不过滤任何服务 centralManager?.scanForPeripherals(withServices: nil, options: [CBCentralManagerScanOptionAllowDuplicatesKey: false]) } // 停止扫描 func stopScan() { + print("停止扫描") centralManager?.stopScan() } // 连接设备 func connect(peripheral: CBPeripheral) { currentPeripheral = peripheral + peripheral.delegate = self // 设置代理 centralManager?.connect(peripheral, options: nil) } @@ -61,15 +66,28 @@ extension BlufiManager: CBCentralManagerDelegate { func centralManagerDidUpdateState(_ central: CBCentralManager) { switch central.state { case .poweredOn: + print("蓝牙已开启") onStateUpdate?("蓝牙已开启") case .poweredOff: + print("蓝牙已关闭") onStateUpdate?("蓝牙已关闭") default: + print("蓝牙状态异常: \(central.state.rawValue)") onError?("蓝牙状态异常") } } + // 发现外设 + func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { +// print("发现设备: \(peripheral.name ?? "Unknown") RSSI: \(RSSI)") + + // 通知发现了新设备 + onDeviceFound?(peripheral, RSSI) + } + func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { + print("已连接到设备: \(peripheral.name ?? "Unknown")") + // 创建并配置 BlufiClient let client = BlufiClient() client.blufiDelegate = self @@ -80,33 +98,58 @@ extension BlufiManager: CBCentralManagerDelegate { } func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) { + print("连接失败: \(error?.localizedDescription ?? "未知错误")") onError?("连接失败: \(error?.localizedDescription ?? "未知错误")") } + + func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { + print("设备断开连接: \(error?.localizedDescription ?? "正常断开")") + if let error = error { + onError?("设备断开连接: \(error.localizedDescription)") + } + } +} + +// MARK: - CBPeripheralDelegate +extension BlufiManager: CBPeripheralDelegate { + func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { + print("发现服务: \(error?.localizedDescription ?? "成功")") + } + + func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { + print("发现特征: \(error?.localizedDescription ?? "成功")") + } } // MARK: - BlufiDelegate extension BlufiManager: BlufiDelegate { func blufi(_ client: BlufiClient!, gattPrepared status: Int32, service: CBService!, writeChar: CBCharacteristic!, notifyChar: CBCharacteristic!) { if status == 0 { + print("GATT准备完成,开始安全协商") client.negotiateSecurity() } else { + print("GATT准备失败: \(status)") onError?("GATT准备失败") } } func blufi(_ client: BlufiClient!, didNegotiateSecurity status: Int32) { if status == 0 { + print("安全协商成功") onStateUpdate?("安全协商成功") } else { + print("安全协商失败: \(status)") onError?("安全协商失败") } } func blufi(_ client: BlufiClient!, didPostConfigureParams status: Int32) { if status == 0 { + print("WiFi配置成功") onConfigured?() } else { + print("WiFi配置失败: \(status)") onError?("WiFi配置失败") } } -} \ No newline at end of file +} diff --git a/demo-esp32/ContentView.swift b/demo-esp32/ContentView.swift index 7965839..19b0deb 100644 --- a/demo-esp32/ContentView.swift +++ b/demo-esp32/ContentView.swift @@ -92,6 +92,22 @@ class BluetoothViewModel: ObservableObject { self?.state = .configured } } + + // 添加设备发现回调 + blufiManager.onDeviceFound = { [weak self] (peripheral, RSSI) in + DispatchQueue.main.async { + // 检查设备是否已存在 + if !(self?.discoveredDevices.contains(where: { $0.peripheral.identifier == peripheral.identifier }) ?? false) { + let device = DiscoveredDevice( + id: UUID(), + peripheral: peripheral, + name: peripheral.name ?? "Unknown Device", + rssi: RSSI.intValue + ) + self?.discoveredDevices.append(device) + } + } + } } func startScan() { @@ -224,7 +240,7 @@ struct ContentView: View { switch viewModel.state { case .poweredOff: return "蓝牙已关闭" case .poweredOn: return "蓝牙已开启" - case .scanning: return "正在扫描设备..." + case .scanning: return "正在扫���设备..." case .connected: return "设备已连接" case .configuring: return "正在配置WiFi..." case .configured: return "配置成功"