我在Arduino上使用了BLE盾牌- LightBlue正确地检测到了BLE屏蔽。现在,我正在尝试做一个应用程序,扫描所有的BLE设备,并连接到正确的一个,以便我可以发送一些信息到我的屏蔽从我的应用。
但是这个应用程序没有检测到BLE盾牌(它检测到另一个BLE设备,尽管.)。
我的代码如下:
- (void)centralManagerDidUpdateState:(CBCentralManager *)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)centralManager:(CBCentralManager *)central didDiscoverPeripheral: (CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
NSLog(@"%@\n--------------------", advertisementData.description);
}我查过LightBlue,180 A是我盾的正确服务UUID。我还试图通过传递一个零值而不是服务UUID来进行扫描,但是仍然无法检测到它。
这段代码似乎是我的BLE设备之一,是found...Any的想法,为什么我的屏蔽可以被LightBlue检测到,而不是这段代码?
发布于 2015-11-17 04:08:30
您可以尝试在扫描时传递“允许复制”选项,因为如果它认为它是一个副本,则可能会抑制它的发现。
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[cbcManager scanForPeripheralsWithServices:nil options:options];https://stackoverflow.com/questions/33748553
复制相似问题