Commit 0a4298f69ca004936128cc6c1103665609ed67ca
1 parent
ae78ae3c
feat:workflow print
Showing
1 changed file
with
9 additions
and
1 deletions
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -198,7 +198,7 @@ class BluetoothManager: NSObject { |
198 | 198 | |
199 | 199 | |
200 | 200 | func startScanning() { |
201 | - print("开始扫描") | |
201 | + print("jason_bluetooth_action_0:开始扫描") | |
202 | 202 | peripheralDic = [:] |
203 | 203 | deviceArray = [] |
204 | 204 | centralManger = CBCentralManager(delegate: self, queue: nil) |
... | ... | @@ -218,6 +218,7 @@ class BluetoothManager: NSObject { |
218 | 218 | } |
219 | 219 | |
220 | 220 | func connect(peripheral: CBPeripheral) { |
221 | + print("jason_bluetooth_action_2:发起连接"); | |
221 | 222 | // setupManger(peripheral) |
222 | 223 | let name = peripheral.name |
223 | 224 | // 这里是根据名字来判断其平台类型 |
... | ... | @@ -1345,11 +1346,13 @@ extension BluetoothManager: ClientProfileDelegate { |
1345 | 1346 | } |
1346 | 1347 | |
1347 | 1348 | func onConnected(_ peripheral: CBPeripheral!) { |
1349 | + print("jason_bluetooth_action_3:通过MTKBleManager的ClientProfileDelegate得到连接成功回调"); | |
1348 | 1350 | print("已经连接: \(peripheral.identifier.uuidString)--\(peripheral.name ?? "")") |
1349 | 1351 | |
1350 | 1352 | stopScanning() |
1351 | 1353 | connectedPerArray.append(peripheral) |
1352 | 1354 | self.peripheral = peripheral |
1355 | + print("jason_bluetooth_action_4:开始发现外设服务"); | |
1353 | 1356 | peripheral.discoverServices(nil) |
1354 | 1357 | |
1355 | 1358 | var delayTime: Double = 2 |
... | ... | @@ -1413,10 +1416,12 @@ extension BluetoothManager: ClientProfileDelegate { |
1413 | 1416 | } |
1414 | 1417 | |
1415 | 1418 | func onServiceDiscovered(_ periphearl: CBPeripheral!, error: Error!) { |
1419 | + print("jason_bluetooth_action_5:通过MTKBleManager的ClientProfileDelegate得到发现服务成功回调,这里应该是SDK做了相关后续动作,直接触发后续回调"); | |
1416 | 1420 | // print("已经连接2") |
1417 | 1421 | } |
1418 | 1422 | |
1419 | 1423 | func onCharacteristicDiscovered(_ peripheral: CBPeripheral!, for service: CBService!, error err: Error!) { |
1424 | + print("jason_bluetooth_action_6:通过MTKBleManager的ClientProfileDelegate得到发现特征回调"); | |
1420 | 1425 | if service.characteristics == nil { |
1421 | 1426 | return |
1422 | 1427 | } |
... | ... | @@ -1457,6 +1462,7 @@ extension BluetoothManager: ClientProfileDelegate { |
1457 | 1462 | print("接收: \([UInt8](data))") |
1458 | 1463 | mergeData(data) |
1459 | 1464 | default: |
1465 | + print("接收: \([UInt8](data))") | |
1460 | 1466 | mergeData(data) |
1461 | 1467 | } |
1462 | 1468 | } |
... | ... | @@ -1545,6 +1551,8 @@ extension BluetoothManager: CBCentralManagerDelegate { |
1545 | 1551 | } |
1546 | 1552 | |
1547 | 1553 | func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { |
1554 | + print("jason_bluetooth_action_1:通过CBCentralManagerDelegate回调得到扫描结果"); | |
1555 | + print("jason " + (peripheral.name ?? "")); | |
1548 | 1556 | if peripheralDic.keys.contains(peripheral.identifier.uuidString) { |
1549 | 1557 | return |
1550 | 1558 | } | ... | ... |