IOS 蓝牙搜不到设备

发布于 2022-09-01 06:07:56 字数 1439 浏览 15 评论 0

图片描述

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心欲静而疯不止 2022-09-08 06:07:56

可以的话放下代码,帮你调调 还有参考参考链接

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

写好了,你的教程确实实现不了,可能iOS蓝牙的实现方式变过了,注意设置完代理,貌似现在scanForPeripheralsWithServices必须放在centralManagerDidUpdateState这里

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

图片描述

香草可樂 2022-09-08 06:07:56

你的设备都是bluetooth 4.0的设备吗?

妄司 2022-09-08 06:07:56

你好我也是遇到同样的问题,iOS 蓝牙搜不到设备,imac和android机器都可以看到 iOS的蓝牙设备就是

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文