3

在 iOS 7 中,一些核心蓝牙的东西现在被弃用了,比如 CBUUIDGenericAccessProfileString 和 CBUUIDDeviceNameString。苹果文档状态

"(Deprecated. There are no replacements for these constants.)"

我想知道我们应该做些什么来替换这些 GAP 东西,因为苹果文档和示例没有帮助。整个互联网似乎也对此保持沉默。我的代码很像Heart Rate Monitor 示例,它仍然有已弃用的代码

/* GAP (Generic Access Profile) for Device Name */
if ( [aService.UUID isEqual:[CBUUID UUIDWithString:CBUUIDGenericAccessProfileString]] )
{
    [aPeripheral discoverCharacteristics:nil forService:aService];
}
4

1 回答 1

9

直接使用通用访问服务 UUID 怎么样?

if ( [aService.UUID isEqual:[CBUUID UUIDWithString:@"1800"]] )//0x1800 is the Generic Access Service Identifier
{
    [aPeripheral discoverCharacteristics:nil forService:aService];
}

在此处查看有关通用访问服务的详细信息。

于 2013-11-14T21:49:06.640 回答