我在 Arduino 上使用 BLE Shield - LightBlue 正确检测到 BLE 屏蔽。现在,我正在尝试制作一个应用程序来扫描所有 BLE 设备并连接到正确的设备,这样我就可以从我的应用程序向我的防护罩发送一些信息。
但该应用未检测到 BLE Shield(但它检测到另一个 BLE 设备......)。
我的代码如下:
- (void)centralManagerDidUpdateStateCBCentralManager *)central{
switch (central.state) {
case CBCentralManagerStatePoweredOn:
msg=[NSString stringWithFormat"Bluetooth is currently powered on and available to use."];
[cbcManager scanForPeripheralsWithServices:[NSArray arrayWithObject:[CBUUID UUIDWithString"180A"]] options:nil];
break;
}
}
- (void)centralManagerCBCentralManager *)central didDiscoverPeripheral: (CBPeripheral *)peripheral advertisementDataNSDictionary *)advertisementData RSSINSNumber *)RSSI {
NSLog(@"%@\n--------------------", advertisementData.description);
}
我检查了 LightBlue,180A 是我的盾牌的正确服务 UUID。我还尝试通过传递 nil 值而不是服务 UUID 来进行扫描,但仍然无法检测到。
当我的一个 BLE 设备被发现时,该代码似乎可以工作...任何想法为什么 LightBlue 可以检测到我的盾牌而不是这段代码?
您可以尝试在扫描时传递允许重复选项,因为如果它认为它是重复的,它的发现可能会被抑制。
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[cbcManager scanForPeripheralsWithServices:nil optionsptions];
关于ios - LightBlue 找到了设备,但 iOS CoreBluetooth 没有找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33748553/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |