didDiscoverPeripheral未调用 [英] didDiscoverPeripheral not called

查看:153
本文介绍了didDiscoverPeripheral未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过蓝牙将ASCII码发送到第三方设备. 希望有可能与spp有关.我的术语可能是错误的.我对这个编程领域还不够了解.

I need to send ASCII-codes via bluetooth to the third-party device. Hope it's possible to do with spp. I could be wrong in terminology. I don't know enough this programming area.

centralManagerDidUpdateState中,我正在扫描外围设备:

In centralManagerDidUpdateState I'm scanning for peripherals:

CBUUID *cbuuidService = [CBUUID UUIDWithString:@"0x1101"];
NSArray *service = @[ cbuuidService ];
NSDictionary *options = @{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES };
[central scanForPeripheralsWithServices:service options:options];

didDiscoverPeripheral从未调用过.

我尝试不使用服务进行扫描,并且效果相同.

I tried to scan without services and it has the same effect.

我做错了什么?我需要什么cbuuid?在哪里可以找到它?感谢您的帮助.

What am I doing wrong? What cbuuid do I need and where can I find it? Thank for any help.

推荐答案

您需要让一台设备充当中央设备(而您需要这样做),而另一台设备充当外围设备.因此,假设您使用MB Air作为中央服务器,则需要在iPad上启动CBPeripheralManager并发布和宣传服务.然后,您应该可以在自己的MB上发现它.

You need to have one device act as a central (which you do) and one as a peripheral device. So assuming that you use your MB Air as the central, you need to start a CBPeripheralManager on your iPad and have it publish and advertise a service. Then you should be able to discover it on your MB.

我想最简单的方法是使外围设备正常工作(例如心跳带),这样您就可以熟悉CBCentralManager的用法.然后,您可以开始实现自己的外围设备.

I guess the easiest way would be to get a working peripheral (e.g. a heart rate belt), so you can familiarize yourself with the usage of CBCentralManager. Then you could start implementing your own peripheral.

PS:我不确定将0x放在标识符的开头是否正确.

PS: I am not sure it is correct to put 0x at the beginning of the identifier.

这篇关于didDiscoverPeripheral未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆