android - iOS 和 Android Max BLE 通告和扫描字节

标签 android ios bluetooth-lowenergy

我一直在stackoverflow上搜索;然而,我似乎发现了有关此问题的各种相互矛盾的答案。考虑到 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 字节的数据。

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

关于android - iOS 和 Android Max BLE 通告和扫描字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36754682/

相关文章:

ios - collectionView 单元格宽度不会因不同的 Nib 而改变

bluetooth-lowenergy - --char-desc 和 --characteristics 之间的 gatttool 区别

bluetooth - 如何使用 "Service Changed"特征使属性缓存失效?

android - 传递包时获取空指针

android - Xamarin Android : Cannot create an android archive '' because the project does not have a package name

java - 对话框 fragment 无法转换为 android.app.activity

iphone - iOS打印图像和文本

基于最大倾斜度的 iOS 设备屏幕磁性方向?

iOS 到 FTDI 芯片通信

android - android studio 底部工具栏中的运行选项卡已消失