iOS只宣传一项服务作为外围BTLE



IOS只发布一个服务,尽管我指定了两个服务UUID和服务,但我没有收到任何错误,并且添加服务错误函数被调用了两次,两次都没有错误,这是我的代码

for UUIDs in advertisingUUIDs
{
    self.mainServicesArray.append(CBMutableService(type: UUIDs, primary: true))
}
for services in mainServicesArray
{
    self.peripheralManager.addService(services)
}
self.peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [mainServicesArray[0].UUID,mainServicesArray[1].UUID]])

其余的代码运行良好,在我放在那里的例子中,它将公布两个服务中的第一个,顺序无关紧要,第一个总是公布,第二个不公布,所以UUID和服务一样有效,它只是不会同时公布它们,我确信这很简单,但我被卡住了。

感谢

原因是第二个UUID不适合广告数据包。

当我扫描连接的设备时,第二项服务仍然没有显示,但这是另一个问题。

最新更新