我已經在Xcode 6中製作了一個非常簡單的iOS應用程序來試用CoreBluetooth並與我的Polar H6心率監視器進行通信。出於某種原因,didDiscoverPeripheral方法未被調用。iOS - CoreBluetooth didDiscoverPeripheral不被稱爲
我發現在計算器上類似如下的問題,但你要麼是有點不同,或者真的不回答這個問題對我來說:
- corebluetooth-diddiscoverperipheral-not-being-called-in-swift
- not-working-call-to-centralmanager-diddiscoverperipheral-advertisementdata
- diddiscoverperipheral-delegate-method-is-not-called
我的codeD viewLidLoad:
NSArray *services = @[[CBUUID UUIDWithString:HRM_HEART_RATE_SERVICE_UUID]];
CBCentralManager *centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[centralManager scanForPeripheralsWithServices:services options:nil];
self.centralManager = centralManager;
方法centralManagerDidUpdateState
正在被調用,它告訴我狀態等於CBCentralManagerStatePoweredOn
。 didDiscoverPeripheral
方法永遠不會被調用,即使我將nil
轉換爲scanForPeripheralsWithServices
方法。
在app store中,我已經下載了一個名爲LightBlue的應用程序。它是一個非常簡單的應用程序來測試任何使用藍牙4.0 LowEnergy的設備。它掃描外圍設備並顯示有關設備及其服務的詳細信息。 LightBlue應用程序看到我的HeartRate顯示器,而我自己的小應用程序沒有。
有沒有人有任何提示或線索如何前進?
(我使用的Xcode 6和iPhone 6與iOS 8)
的[iOS 8的核心藍牙未發現外設]可能重複(http://stackoverflow.com/questions/25586527/ios-8-core-bluetooth-not-discovering-peripherals) – Paulw11 2014-10-19 19:33:38
@ Paulw11謝謝!這確實是一個相同的問題(我自己沒有找到它的恥辱),它給了我解決方案! – Brabbeldas 2014-10-20 08:42:10
請檢查此解決方案:http://stackoverflow.com/questions/28167804/why-use-corebluetooth-connectperipheral-did-not-call-delegate-methods-in-ios8/31961410#31961410 – oOEric 2015-08-12 09:38:44