iOS 和 Android 最大 BLE 广告和扫描字节

iOS and Android Max BLE advertise and scan bytes

我一直在通过Whosebug搜索;但是,我似乎发现了与此有关的各种相互矛盾的答案。给定 Android 5.1.1 和 iOS 8.4.1 可以通过无连接 BLE 服务相互发送的最大字节数是多少。根据我的基本理解,它应该是 BLE 规范中的 20 个字节(实际上是 23 个字节);但是,我看到 iOS 能够推送 512 而 android 能够增加其 MTU 的查询。

此外,如果可以在一个连接中发送超过 20 个字节,那么在 iOS 和 android 上的扫描仪在接收时是否可以使用跨平台应用程序正确识别它们?数据包没有直接连接?

根据 Apple 的 Best Practices for Setting Up Your Local Device as a Peripheral

Although advertising packets in general can hold a variety of information about the peripheral device, you may advertise only your device’s local name and the UUIDs of any services you want to advertise. That is, when you create your advertising dictionary, you may specify only the following two keys: CBAdvertisementDataLocalNameKey and CBAdvertisementDataServiceUUIDsKey. You receive an error if you specify any other keys.

There are also limits as to how much space you can use when advertising data. When your app is in the foreground, it can use up to 28 bytes of space in the initial advertisement data for any combination of the two supported advertising data keys. If this space is used up, there are an additional 10 bytes of space in the scan response that can be used only for the local name. Any service UUIDs that do not fit in the allotted space are added to a special “overflow” area; they can be discovered only by an iOS device that is explicitly scanning for them. While your app is in the background, the local name is not advertised and all service UUIDs are place in the overflow area.

Note: These sizes do not include the 2 bytes of header information that are required for each new data type. The exact format of advertising and response data is defined in the Bluetooth 4.0 specification, Volume 3, Part C, Section 11

如果您使用未注册的 16 字节服务 UUID,我认为这将为您提供大约 12 字节的数据。

广告数据包中的可用字节与有效负载数据包中的可用字节不同。