Commit 79f6c3aac5da1acc38a8f2c992db78892c0ff7c6
1 parent
ebd8c665
feat:mac null handler
Showing
1 changed file
with
15 additions
and
10 deletions
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -1574,19 +1574,24 @@ extension BluetoothManager: CBCentralManagerDelegate { |
1574 | 1574 | delegate.didDiscover(devices: deviceArray) |
1575 | 1575 | } |
1576 | 1576 | } else { |
1577 | - // 该设备无值 | |
1578 | -// if let json = advertisementData["kCBAdvDataServiceData"] { | |
1579 | -// if let dic = json as? Dictionary<CBUUID, Data> { | |
1580 | -// if let data = dic.values.first { | |
1581 | -// var mac = data.hexToString(":") | |
1582 | -// mac = mac.substring(fromIndex: mac.length-17) | |
1583 | - deviceArray.append(ScanDevice(peripheral, mac: "111")) | |
1577 | + if let json = advertisementData["kCBAdvDataServiceData"] { | |
1578 | + if let dic = json as? Dictionary<CBUUID, Data> { | |
1579 | + if let data = dic.values.first { | |
1580 | + var mac = data.hexToString(":") | |
1581 | + mac = mac.substring(fromIndex: mac.length-17) | |
1582 | + deviceArray.append(ScanDevice(peripheral, mac: mac)) | |
1584 | 1583 | for delegate in delegateList { |
1585 | 1584 | delegate.didDiscover(devices: deviceArray) |
1586 | 1585 | } |
1587 | -// } | |
1588 | -// } | |
1589 | -// } | |
1586 | + } | |
1587 | + } | |
1588 | + }else {// 当无值时直接给个值跑通调试 | |
1589 | + var mac = "111" | |
1590 | + deviceArray.append(ScanDevice(peripheral, mac: mac)) | |
1591 | + for delegate in delegateList { | |
1592 | + delegate.didDiscover(devices: deviceArray) | |
1593 | + } | |
1594 | + } | |
1590 | 1595 | } |
1591 | 1596 | } |
1592 | 1597 | } | ... | ... |