iOS13使用bluetooth作为peripheral发送广播问题

iOS13在使用蓝牙发送广播时,会额外携带0x0A也就是TXPowerLevel字段,会导致数据中多出2位(type和value),中心设备按位解析就会提前两位,导致解析失败。

代码和配图如下:

1 [self.peripheralManager startAdvertising:@{
2                                                CBAdvertisementDataServiceUUIDsKey :@[serviceUUID],
3                                                CBAdvertisementDataLocalNameKey :localName
4                                                }];

在iOS12中,发送的广播数据是这样的:

而iOS13中,发送的广播数据是这样的:

我们可以看到,多出了0x0A字段。

蓝牙Type和value表

猜你喜欢

转载自www.cnblogs.com/coderkongbin/p/11590091.html