修改扫描的设备的mac地址,改成统一转换成大写 dev
authorliangzhenying <867174124@qq.com>
Thu, 27 Feb 2025 02:36:42 +0000 (10:36 +0800)
committerliangzhenying <867174124@qq.com>
Thu, 27 Feb 2025 02:36:42 +0000 (10:36 +0800)
IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBReceiveManager.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBManufacturer.swift
IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBWatchInfo.swift

index d2353ca..cb21653 100644 (file)
Binary files a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ
index 7c69522..da68032 100644 (file)
@@ -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()
index 2a8535d..d6dfa2e 100644 (file)
@@ -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)
index 6300d84..7cad842 100644 (file)
@@ -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", ".")
index 2a7c0c1..f0b0fbc 100644 (file)
@@ -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