无法搜索自定义 CBUUID

dvd*_*oid 3 xcode bluetooth-lowenergy swift

我有一个可以将我的 iOS 设备连接到蓝牙 arduino 的应用程序(到目前为止很好),到目前为止,这主要用于练习,但现在我收到了我应该连接的真实内容。
问题是我找不到!(当我搜索它时)。如果我执行 scanwithservices: nil,我可以看到设备并连接到它。但是,如果我 scanwithservices: [device'sCBUUID] 那么我什么也得不到。我使用其他应用程序检查了 CBUUID,使用我自己的应用程序并查看了设备文档,但无论如何我都找不到它。
它有一个自定义的 CBUUID,从我读过的内容来看,这不是标准的,CBUUID 是:

BLETPodService = CBUUID(string: "4D494B45-414c-5741-5953-524F434B5321")
Run Code Online (Sandbox Code Playgroud)

搜索它不会产生任何结果,但是如果我扫描 nil 我会找到它,如果我使用 Bluefruit 应用程序(来自 Adafruit)检查它的特征,我可以看到它的服务和特征 ID,它们与我在这里发布的字符串相匹配!
我告诉一个朋友,他说这是一个存在多年的 BLE 错误(关于自定义 CBUUID),这是真的吗?真的没有解决办法吗?

编辑添加完整的扫描代码仅供参考:

    func centralManagerDidUpdateState(_ central: CBCentralManager) {
        var statusMessage = ""

        switch (central.state)
        {
        case .unsupported:
            statusMessage = "Bluetooth Low Energy is not supported!"
            displayStatusAlert(localmsg: statusMessage)
            print(statusMessage)
        case .unauthorized:
            statusMessage = "Bluetooth Low Energy is not authorized!"
            displayStatusAlert(localmsg: statusMessage)
            print(statusMessage)
        case .unknown:
            statusMessage = "Bluetooth Low Energy is unknown!"
            displayStatusAlert(localmsg: statusMessage)
            print(statusMessage)
        case .poweredOff:
            statusMessage = "Bluetooth Low Energy is powered off!"
            displayStatusAlert(localmsg: statusMessage)
            print(statusMessage)
        case .resetting:
            statusMessage = "Bluetooth Low Energy is resetting!"
            displayStatusAlert(localmsg: statusMessage)
            print(statusMessage)
        case .poweredOn:
            statusMessage = "BLE is ready!" //If BLE is ready then start scanning right away!
            peripheralsFoundNames.removeAll()
            peripheralsFoundCB.removeAll()
            peripheralsFoundRSSIs.removeAll()
            peripheralsFoundData.removeAll() //Remove previous data from previous scans
            central.scanForPeripherals(withServices: nil, options: nil)
        }
    }

//What happens when you discover a peripheral
    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
        //What to do when it discovers a peripheral, add it to the array list
        print("Peripheral found: " + (peripheral.name ?? "Unknown Name"))
        peripheralsFoundNames.append((peripheral.name ?? "Unknown Name"))
        peripheralsFoundData.append((advertisementData.description ))
        peripheralsFoundCB.append(peripheral)
        peripheralsFoundRSSIs.append(RSSI)
    }
Run Code Online (Sandbox Code Playgroud)

Pau*_*aul 5

我碰巧同时在 BLE 固件和 iOS 应用程序上工作。我有同样的问题,过滤器不起作用。

iOS 找不到带有 UUID 的设备的原因是设备在做广告时不包含 UUID。

我不得不更改设备固件以在广告数据包中添加服务 UUID。随着设备广告 UUID,UUID 过滤器按预期工作。