Corebluetooth方法scanForPeripheralsWithServices在我的任何设备中都不起作用。所有github示例都不能与我的设备一起工作ipod touch

时间:2015-04-29 05:47:16

标签: android iphone ios8 bluetooth

我正在研究与蓝牙相关的应用程序。但我没有取得任何成功。

在我的应用程序中,我想将我的iDevice与正在扫描的任何其他蓝牙设备连接。

但是使用CBCentralManager方法scanForPeripheralsWithServices,我没有在didDiscoverPeripheral方法中得到任何响应。

CBCentralManager alloc方法在这里: -

(void)viewDidLoad
    {
        [super viewDidLoad];

        // Start up the CBCentralManager
        _centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

        _textview.userInteractionEnabled = NO; // not used in this test app
    }

CBCentralManager的扫描方法: -

(void)scanForPeripherals {
    if (self.centralManager.state != CBCentralManagerStatePoweredOn) {
        NSLog(@"CBCentralManager must be powered to scan peripherals. %d", self.centralManager.state);
        return;
    }

    if (self.scanning) {
        return;
    }

    self.scanning = YES;

    [self.centralManager scanForPeripheralsWithServices:nil options:@{ CBCentralManagerScanOptionAllowDuplicatesKey: @YES }];
    NSLog(@"Scanning started");
}

但是我从未在didDiscoverPeripheral方法中收到任何回复。任何人都可以帮我解决这个问题。?

0 个答案:

没有答案