2015-03-31 42 views
0

我想連接摩托羅拉戒指掃描儀「R1000BT」,我面臨的問題是,當我啓動scanForPeripheralsWithServices:時,委託方法didDiscoverPeripheral:永遠不會被調用。核心藍牙:無法發現戒指掃描器

我尋找類似的問題,但沒有人幫助我。

到目前爲止我的代碼是:

#define RING_SCANNER_SERVICE_UUID @"1813" 

-(void)viewDidLoad{ 
    CBCentralManager *centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; 
    self.centralManager = centralManager; 
} 

- (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"); 

     NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:RING_SCANNER_SERVICE_UUID], nil]; 
     NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey]; 
     [central scanForPeripheralsWithServices:uuidArray options:options]; 
    } 
    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"); 
    } 
} 

- (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 ring scanner: %@", localName); 
     [self.centralManager stopScan]; 
     self.ringScannerPeripheral = peripheral; 
     peripheral.delegate = self; 
     [self.centralManager connectPeripheral:peripheral options:nil]; 
    } 
} 

請幫我解決這個問題,我有iOS的8.1。

回答

3

根據product data該設備是實現串行端口協議(SPP)和人機接口設備(HID)協議的藍牙3.0設備。因此,iOS上的Core Bluetooth不支持。

看來你應該把它放入HID模式,並將它與iOS設備配對爲鍵盤。

您嘗試使用的服務UUID 0x1813被稱爲「掃描參數」,但這與條形碼掃描無關 - 這是允許控制設備的BLE掃描速率以進行電源管理的服務。

+0

是的,我想用它作爲鍵盤,但不知道SSP和HID協議。我們如何連接到具有這些協議的設備。 – 2015-03-31 09:38:06

+0

你只需在iOS藍牙設置中配對設備即可。你不需要在你的應用程序中做任何事情。說明在這裏 - http://www.generalscan.com/download/Generalscan-Bluetooth-Pair-User-Guide-EN.pdf – Paulw11 2015-03-31 09:40:22

+0

實際上環掃描器睡10分鐘左右後,爲了避免這種情況,我想自動連接設備從我的應用程序。 – 2015-03-31 09:45:02