如何增加BLE应用程序的吞吐量? [英] How can I increase the throughput of my BLE application?

查看:103
本文介绍了如何增加BLE应用程序的吞吐量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个充当中央设备的android客户端,并且在我的MAC(外围设备)上有一个与该中央设备连接并发送数据的应用程序.

I have an android client that functions as a central and have an app on my MAC (peripheral) that this central connects to and sends data.

这时,我需要在调用writeCharacteristic(..)之后等待近100毫秒,才能接收onCharacteristicWrite(..)回调.我正在发送字符串.如果我发送较小的字符串,则吞吐量非常好(可以理解).当字符串包含大约200个字符并且我发送20个字节的块时,大约需要一秒钟的时间才能在外围设备上看到整个字符串.在写入特征之前将写入类型设置为NO_RESPONSE时,我看不到外围设备上的任何数据.

At this point, I need to wait almost 100ms after I call writeCharacteristic(..) to receive the onCharacteristicWrite(..) callback. I am sending strings. If I send smaller strings, the throughput is great (understandably). When the string contains about 200 characters and I send 20 byte chunks, it takes almost a second before the entire string is seen at the peripheral. When I set the write type to NO_RESPONSE before writing the characteristic, I see no data on the peripheral.

连接后,我做了以下操作以提高吞吐量:

After I connect, I have done the following to improve throughput:

  • 发现服务后停止发现,因为这是一项昂贵的操作
  • 我首先将写入类型设置为默认-执行此操作时,我会在外围设备上看到数据.但是,这有很大的延迟.当我将writeType设置为NO_RESPONSE时,我在外围设备上看不到任何数据.我也没有onCharacteristicWrite(..)的逻辑.有时,我看到外围设备上的数据被截断.
  • 我已在Mac应用程序上将所需的连接延迟设置为较低.有没有办法设置一个值(也许是7.5ms?).
  • 当我将写入类型设置为默认值并发送200个字符的字符串时,我将字符串分成20个字节的块.我现在有10个大块要发送.如果我设置特征值并循环调用writeCharacteristic(..),则看不到任何数据.当我在writeCharacteristic(..)之后添加〜100ms的延迟,然后它执行循环的下一次迭代时,我在外围设备上看到了数据.

我发现iOS中心-iOS外围设备之间的吞吐量有了极大的提高.我不明白为什么Android中央-iOS外围设备不能以同样的方式工作.据我了解,Android和iOS使用同一芯片.

I see a huge increase in throughput between an iOS central - iOS peripheral. I don't see why Android central - iOS peripheral shouldn't work he same way. From my understanding, Android and iOS use the same chip.

为什么性能如此差?我还可以做些其他事情来提高吞吐量吗?

Any reason the performance is so poor? Is there anything else I can do to improve throughput?

推荐答案

请查看MTU大小.我的经验:

Please have a look at the MTU size. My experience:

使用iOS中央系统,中央系统会自动启动具有较大价值的MTU大小协商.我认为它大于200个字节.

Using a iOS central, the central automatically starts the MTU size negotiation with some large value. I think it is larger than 200 bytes.

在我测试过的大多数Android设备上,这不会自动启动,但是您必须通过应用程序(中央)启动MTU大小协商.如果您不这样做,Android会将您的数据切成20个字节.这对您的吞吐量有很大影响.

On most Android devices I tested this does not start automatically but you have to start the MTU size negotiation by your app (central). If you do not do that, Android cuts your data into 20 byte pieces. This has big influence on your throughput.

这篇关于如何增加BLE应用程序的吞吐量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆