From: liangzhenying <867174124@qq.com> Date: Thu, 27 Feb 2025 02:36:42 +0000 (+0800) Subject: 修改扫描的设备的mac地址,改成统一转换成大写 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=refs%2Fheads%2Fdev;p=mirrors%2FIOTBluetooth-iOS.git 修改扫描的设备的mac地址,改成统一转换成大写 --- diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate index d2353ca..cb21653 100644 Binary files a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift index 7c69522..da68032 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift @@ -66,7 +66,7 @@ class IBReceiveManager { if characteristic.uuid.uuidString == readCharacteristicUUID { let info = IBWatchInfo(data) IBBluetooth.shared.currentConnected.battery = info.battery - IBBluetooth.shared.currentConnected.macAddress = info.macAddress + IBBluetooth.shared.currentConnected.macAddress = info.macAddress.uppercased() IBBluetooth.shared.currentConnected.productID = info.productID IBBluetooth.shared.currentConnected.customerID = info.customerID sendDeviceInfo() diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift index 2a8535d..d6dfa2e 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift @@ -105,10 +105,18 @@ class IBBluetooth: NSObject { } centralManager.scanForPeripherals(withServices: nil, options: option.values) - if let connectedPeripheral = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: serviceUUID)]).first{ - currentConnected = IBPeripheral() - currentConnected.peripheral = connectedPeripheral - IBManager.discoverHandler?(currentConnected) +// if let connectedPeripheral = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: serviceUUID)]).first{ +// currentConnected = IBPeripheral() +// currentConnected.peripheral = connectedPeripheral +// IBManager.discoverHandler?(currentConnected) +// } + + let devices = centralManager.retrieveConnectedPeripherals(withServices: [CBUUID(string: serviceUUID)]) + for item in devices { + var p = IBPeripheral() + p .peripheral = item + IBManager.discoverHandler?(p ) + } } @@ -200,7 +208,7 @@ extension IBBluetooth: CBCentralManagerDelegate { device.productID = manufacturer.productID device.customerID = manufacturer.productID device.advertisementData = advertisementData - device.macAddress = manufacturer.macAddress + device.macAddress = manufacturer.macAddress.uppercased() device.softwareVersion = manufacturer.softwareVersion IBManager.discoverHandler?(device) // Logger.log("发现设备", device.name, device.macAddress) diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBManufacturer.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBManufacturer.swift index 6300d84..7cad842 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBManufacturer.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBManufacturer.swift @@ -16,7 +16,7 @@ struct IBManufacturer { guard code == "JH" else { return nil } isBind = data[2].int - macAddress = data[3...8].reversedJoined(":") + macAddress = data[3...8].reversedJoined(":").uppercased() customerID = data[9].int productID = data[10].int softwareVersion = data[11..<14].joined(format: "%d", ".") diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBWatchInfo.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBWatchInfo.swift index 2a7c0c1..f0b0fbc 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBWatchInfo.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBWatchInfo.swift @@ -14,7 +14,7 @@ struct IBWatchInfo { battery = data[0].int dialID = data[1...2].int firmwareVersion = data[3...5].joined(format: "%d", ".") - macAddress = data[6...11].joined(":") + macAddress = data[6...11].joined(":").uppercased() messagePush = data[12].int media = data[13].int customerID = data[14].int