簡體   English   中英

在核心藍牙中無法發現外圍設備

[英]Couldn't Discover Peripheral in Core Bluetooth

我有iPhone應用程序,我想與藍牙設備連接以獲得葡萄糖測量值。 您可以從這里找到設備。

在閱讀了有關Core Bluetooth的Apple文檔之后,我開始閱讀這些教程 此外,我得到了服務ID的藍牙設備從這些鏈接在這里

因此,在了解了基礎知識之后,我便開始像本教程中那樣編寫代碼。

這些是我的代碼:

#define POLARH7_HRM_DEVICE_INFO_SERVICE_UUID @"180A" // for Device Information service.
#define POLARH7_HRM_HEART_RATE_SERVICE_UUID @"1808" // For Glucose service.

NSArray *services = @[[CBUUID UUIDWithString:POLARH7_HRM_HEART_RATE_SERVICE_UUID], [CBUUID UUIDWithString:POLARH7_HRM_DEVICE_INFO_SERVICE_UUID]];
CBCentralManager *centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[centralManager scanForPeripheralsWithServices:services options:nil];
self.centralManager = centralManager;

我已經實現了CBCentralManagerDelegate和CBPeripheralDelegate的委托

我收到有關centralManagerDidUpdateState的通知

- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
    // Determine the state of the peripheral
    if ([central state] == CBCentralManagerStatePoweredOff) {
        NSLog(@"CoreBluetooth BLE hardware is powered off");
    }
    else if ([central state] == CBCentralManagerStatePoweredOn) {
        NSLog(@"CoreBluetooth BLE hardware is powered on and ready");
    }
    else if ([central state] == CBCentralManagerStateUnauthorized) {
        NSLog(@"CoreBluetooth BLE state is unauthorized");
    }
    else if ([central state] == CBCentralManagerStateUnknown) {
        NSLog(@"CoreBluetooth BLE state is unknown");
    }
    else if ([central state] == CBCentralManagerStateUnsupported) {
        NSLog(@"CoreBluetooth BLE hardware is unsupported on this platform");
    }
}

我的NSLog日志: CoreBluetooth BLE hardware is powered on and ready.

但是我沒有收到有關central didDiscoverPeripheral的通知。

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
    NSString *localName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey];
    if ([localName length] > 0) {
        NSLog(@"Found the heart rate monitor: %@", localName);
        [self.centralManager stopScan];
        self.polarH7HRMPeripheral = peripheral;
        peripheral.delegate = self;
        [self.centralManager connectPeripheral:peripheral options:nil];
    }
}

這些方法沒有被調用。

因此,中央(我的iPhone)無法找到作為我的葡萄糖設備的外圍設備。

從設置->藍牙搜索設備時找不到設備。

如果從不調用centralManager:didDiscoverPeripheral:advertisementData:RSSI:則可能意味着沒有外圍設備具有提供的CBUUID之一。 您可以嘗試提供nil而不是services-array,並檢查是否有可用的外圍設備(不要在生產模式下執行此操作)。

好的,我認為在向TaiDoc公司發送電子郵件后發現了問題,他們告訴我這些設備不支持i​​Phone藍牙集成。

我試圖與Tom-Tom GPS手表連接,並且連接成功:)因此,我認為這個問題是硬件問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM