gpt4 book ai didi

ios - LightBlue 找到的设备,但 iOS CoreBluetooth 找不到的设备

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:56:26 46 4
gpt4 key购买 nike

我在 Arduino 上使用 BLE Shield - LightBlue 正确检测到 BLE Shield。现在,我正在尝试制作一个应用程序来扫描所有 BLE 设备并连接到正确的设备,这样我就可以从我的应用程序向我的盾牌发送一些信息。

但是应用程序没有检测到 BLE Shield(它检测到另一个 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 核对过,180A 是我的防护罩的正确服务 UUID。我也尝试通过传递 nil 值而不是服务 UUID 来进行扫描,但仍然无法检测到它。

代码似乎可以工作,因为找到了我的一个 BLE 设备...知道为什么我的防护罩可以被 LightBlue 而不是这段代码检测到吗?

最佳答案

您可以尝试在扫描时传递允许重复选项,因为如果它认为它是重复的,它的发现可能会被抑制。

NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];    

[cbcManager scanForPeripheralsWithServices:nil options:options];

关于ios - LightBlue 找到的设备,但 iOS CoreBluetooth 找不到的设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33748553/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com