bluetooth - IOS 蓝牙搜不到设备
天蓬老师
天蓬老师 2017-04-17 14:19:21
0
3
653

RT,不知道为什么搜不到设备,我用lightBlue也搜不到设备,然后我自己写的demo用ipad测试也是搜不到设备,求解,判断蓝牙是否打开那些方法都写了

  • (CBCentralManager *)mgr
    {
    if (!_mgr) {
    // 创建中心设备管理者,用来管理中心设备
    self.mgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
    }
    return _mgr;
    }
  • (void)viewDidLoad
    {
    [super viewDidLoad];

    // 扫描外设
    [self.mgr scanForPeripheralsWithServices:nil options:nil];

}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{

 NSLog(@"搜到的peripheralName:%@----%@",peripheral,peripheral.name);

}
-(void)centralManagerDidUpdateState:(CBCentralManager *)central
{
switch (central.state)
{
case CBCentralManagerStatePoweredOn:
{
[self.mgr scanForPeripheralsWithServices:nil options:nil];

        NSLog(@"蓝牙已经打开");
    }
        break;

    default:
        NSLog(@"蓝牙没打开或设备不支持");
        break;
}

}

就这3个方法,我现在还在尝试能不能搜索到蓝牙,搜到再去考虑连接蓝牙
http://blog.csdn.net/pony_maggie/article/details/26740237这是我参考的demo

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(3)
洪涛

If possible, put down the code and help you adjust it. There are also reference links

———————————————————————————————————— ————

It’s written. Your tutorial really cannot be implemented. Maybe the implementation method of iOS Bluetooth has changed. Pay attention to setting up the proxy. It seems that now scanForPeripheralsWithServices must be placed here in centralManagerDidUpdateState

-(void)centralManagerDidUpdateState:(CBCentralManager *)central{
    switch (central.state) {
        case CBCentralManagerStatePoweredOn:
            [_manager scanForPeripheralsWithServices:nil options:nil];
            break;
        default:
            NSLog(@"不支持!!!");
            break;
    }
}

PHPzhong

Are all your devices bluetooth 4.0 devices?

Ty80

Hello, I also encountered the same problem. The iOS Bluetooth device cannot be found. Both imac and android machines can see the iOS Bluetooth device.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template