iOS核心蓝牙:在外围设备上找不到播发的服务

iOS核心蓝牙:在外围设备上找不到播发的服务,ios,objective-c,xcode,core-bluetooth,cbperipheral,Ios,Objective C,Xcode,Core Bluetooth,Cbperipheral,连接到我感兴趣的某项特定服务的BLE设备后,为了发现该服务,我打电话: [self.peripheral discoverServices:@[[self.class serviceUUID]]]; 调用-(void)peripheral:(CBPeripheral*)peripheral didiscoverservices:(NSError*)error委托方法时没有错误,但为该外设返回的服务数为0,因此没有进一步发现任何特征。有人知道为什么会这样吗?提前谢谢 下面是委托方法的全文 - (

连接到我感兴趣的某项特定服务的BLE设备后,为了发现该服务,我打电话:

[self.peripheral discoverServices:@[[self.class serviceUUID]]];
调用
-(void)peripheral:(CBPeripheral*)peripheral didiscoverservices:(NSError*)error
委托方法时没有错误,但为该外设返回的服务数为0,因此没有进一步发现任何特征。有人知道为什么会这样吗?提前谢谢

下面是委托方法的全文

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
    if (error) {
        NSLog(@"didDiscoverServices failed: %@", error);
        return;
    }

    NSLog(@"didDiscoverServices succeeded for peripheral: %@.", peripheral.name);
    NSLog(@"Number of services: %d", peripheral.services.count);

    for (CBService *s in peripheral.services) {
        NSLog (@"Discovered service UUID: %@", s.UUID);
        if ([s.UUID isEqual:[self.class serviceUUID]]) {
            NSLog(@"Discover characteristics...");
            [self.peripheral discoverCharacteristics:@[[self.class controlPointCharacteristicUUID], [self.class packetCharacteristicUUID]] forService:s];
        }
    }
}
控制台显示:

2014-11-27 15:54:51.933 k[197:13362] didDiscoverServices succeeded for peripheral: BootK
2014-11-27 15:54:51.934 k[197:13362] Number of services: 0

我唯一能想到的是
[self.class serviceuid]
与您正在寻找的服务的UUID不匹配。启动扫描时,是否按服务UUID进行过滤

[self.centralManager scanForPeripheralsWithServices:[self.class serviceUUID] options:nil];

如果没有,这可能解释了为什么您能够发现并连接到它,但无法发现特定的服务。

您的外设是什么?您是否尝试过应用商店中的LightBlue应用程序,看看它是否可以发现服务?您是否尝试过扫描
nil
而不是特定的服务来查看发生了什么?它适用于LightBlue。扫描
nil
无法解决问题。我已经尝试使用Nordic提供的一些最新的示例代码,而不是使用上面的块的旧示例代码,现在它可以工作了:)谢谢