Corebluetooth method scanForPeripheralsWithServices not working for me in any device.all github example not working with my devices ipod touch

不打扰是莪最后的温柔 提交于 2019-12-22 10:06:30

问题


I am working on bluetooth related app.but i didn't get any success.

in my app i want to connect my iDevice with any other bluetooth device who is scanning.

but with CBCentralManager method scanForPeripheralsWithServices , i didn't get any response in didDiscoverPeripheral method.

CBCentralManager alloc method here :-

(void)viewDidLoad
    {
        [super viewDidLoad];

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

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

Scanning method for 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");
}

but i never receive any response in didDiscoverPeripheral method.can any one help me with this code.?

来源:https://stackoverflow.com/questions/29935317/corebluetooth-method-scanforperipheralswithservices-not-working-for-me-in-any-de

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!