Ios 如何在CoreBluetooth框架中传递设备UUID,以便客户端稍后重新连接

Ios 如何在CoreBluetooth框架中传递设备UUID,以便客户端稍后重新连接,ios,core-bluetooth,bluetooth-lowenergy,cbperipheral,Ios,Core Bluetooth,Bluetooth Lowenergy,Cbperipheral,我刚刚编写了一个简单的应用程序,可以扫描并连接到外围设备(也是IOS设备)。但是,我从ConnectPeripheral函数返回的CBPeripheral对象没有设备UUID,并且它总是空的。现在我想知道我应该在哪里设置它,这样它才能通过。 这就是我正在做的 为我的服务做广告 NSDictionary *advertisingDict=[NSDictionary dictionaryWithObject: services forKey:CBAdvertisementDataServiceUUI

我刚刚编写了一个简单的应用程序,可以扫描并连接到外围设备(也是IOS设备)。但是,我从ConnectPeripheral函数返回的CBPeripheral对象没有设备UUID,并且它总是空的。现在我想知道我应该在哪里设置它,这样它才能通过。 这就是我正在做的

为我的服务做广告

NSDictionary *advertisingDict=[NSDictionary dictionaryWithObject: services forKey:CBAdvertisementDataServiceUUIDsKey]
[manager startAdvertising:advertisingDicts];
(根据框架,我理解我无法在广告包中传递设备UUID。如果我在这里出错,请纠正我)

我的客户扫描服务并进入功能

centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral

正如预期的那样,peripheral.uuid为空。如果我在这个外设上调用ConnectPeripal,它也可以正常工作。我不知道当uuid为空时,它如何理解要连接哪个设备。如果我以后想重新连接,我需要做什么。如何填充此uuid?

它有一个解决方法。您可以传递它,而不是设备的本地名称,如下所示:

[self.peripheralManager startAdvertising:@{CBAdvertisementDataLocalNameKey : *the UUID*}];
[advertisementData objectForKey:@"kCBAdvDataLocalName"]
在DidDiscovery外围功能的另一个设备中,您可以得到如下结果:

[self.peripheralManager startAdvertising:@{CBAdvertisementDataLocalNameKey : *the UUID*}];
[advertisementData objectForKey:@"kCBAdvDataLocalName"]

IOS 6仍在苹果开发者论坛上讨论这个问题。谢谢我在上发布。希望有人会回答