Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 扫描特定服务CBUUID时找不到外围设备_Ios_Core Bluetooth - Fatal编程技术网

Ios 扫描特定服务CBUUID时找不到外围设备

Ios 扫描特定服务CBUUID时找不到外围设备,ios,core-bluetooth,Ios,Core Bluetooth,当我使用: CBUUID * uuid = [CBUUID UUIDWithString:@"1800"]; // GAP DEBUG_LOG(@"CBUUID: %@",uuid); // CBUUID: Generic Access Profile _centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; [_centralMan scanForPeripheralsWithServices:[NSAr

当我使用:

CBUUID * uuid = [CBUUID UUIDWithString:@"1800"]; // GAP
DEBUG_LOG(@"CBUUID: %@",uuid); // CBUUID: Generic Access Profile
_centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_centralMan scanForPeripheralsWithServices:[NSArray arrayWithObject:uuid]
                                    options:nil];
_centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_centralMan scanForPeripheralsWithServices:nil
                                    options:nil];
我找不到我的外设,但当我使用:

CBUUID * uuid = [CBUUID UUIDWithString:@"1800"]; // GAP
DEBUG_LOG(@"CBUUID: %@",uuid); // CBUUID: Generic Access Profile
_centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_centralMan scanForPeripheralsWithServices:[NSArray arrayWithObject:uuid]
                                    options:nil];
_centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_centralMan scanForPeripheralsWithServices:nil
                                    options:nil];
…它马上就出现了

当我连接时,我能够发现/读取/写入我期望的所有服务。我的理解是GAP使这成为可能。我还尝试了
CBUUID
,用于我知道正在运行的其他服务(特别是“1804”,TX电源服务),但没有成功;扫描从未发现任何东西

即使服务正在运行(我可以在连接时与它们通信),当我扫描通过服务UUID数组作为
nil
时,此委托方法被称为

-(void) centralManager:(CBCentralManager *)central 
 didDiscoverPeripheral:(CBPeripheral *)peripheral 
     advertisementData:(NSDictionary *)advertisementData 
                  RSSI:(NSNumber *)RSSI {
    DEBUG_LOG(@"Found peripheral w/ UUID: %@ RSSI: %@ \n AdvData: %@",peripheral.UUID,RSSI,advertisementData);
    DEBUG_LOG(@"Services found: %d",peripheral.services.count);
    for (CBService * service in peripheral.services) {
        DEBUG_LOG(@"Found service: %@ w/ UUID %@",service, service.UUID);
    }
}
…它始终报告“找到的服务:0”。我是否应该使用扫描期间找到的服务填充
服务
阵列?(我假设这至少部分是可能的,基于
scanForPeripheralsWithServices:[NSArray arraywhithobject:uuid]
选项:无

这可能是我的外设服务广告的问题吗?我是否错误地使用了API?非常感谢您的指导!:-)

附言:我很喜欢蓝牙


PPS:我控制外设的源(它是CC2540DK)。因此,我很可能认为问题就在这里。

事实证明,我们的外围代码并不是在宣传UUID a la


我们一把它们放到广告包里,iOS就毫不费力地把它们捡了起来。

你能展示一下你的cc2540代码吗?我也有同样的问题,我想我的广告一定是错的。是的,我也有同样的问题,你能发布你的代码吗;我们转向了Bluegiga的硬件和脚本语言,它使用起来简单得多。不过,IIRC的CC2540代码是一个硬编码的字节数组,按照规范进行编码,并提供给一些C函数来启动广告。