Я пытаюсь подключить Motorola Ring Scanner «R1000BT», проблема, с которой я столкнулся, заключается в том, что когда я запускаю scanForPeripheralsWithServices:, метод делегирования didDiscoverPeripheral: никогда не вызывается.Ядро Bluetooth: не удалось обнаружить Ring Scanner
Я искал аналогичный вопрос, но никто из них не помог мне.
Мой код до сих пор:
#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.
Да, я хочу использовать его в качестве клавиатуры, но не знаю о протоколе SSP и HID. Как мы можем подключиться к устройствам с этими протоколами. –
вы просто соединяете устройство в настройках Bluetooth iOS. Вам не нужно ничего делать в своем приложении. Инструкции здесь - http://www.generalscan.com/download/Generalscan-Bluetooth-Pair-User-Guide-EN.pdf – Paulw11
действительно сканер звонка спит через 10 минут или около того, во избежание этого я хочу автоматически подключить устройство из моего приложения. –