蓝牙BLE Android以最大吞吐量写入外围设备 [英] Bluetooth BLE Android write to peripheral with max throughput

查看:322
本文介绍了蓝牙BLE Android以最大吞吐量写入外围设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们公司开发了一种具有Bluetooth BLE的硬件单元,并且在Nexus 7(2013)中提供了一个服务应用程序,我们希望通过该应用程序将固件文件发送到该单元.文件可以最大为500kb.

Our company develops a hardware unit that has Bluetooth BLE and we have a service app in a Nexus 7 (2013) that we want to send firmware files to the unit with. The files can be as large as 500kb.

BT芯片是德州仪器(TI)CC2540.

The BT chip is a Texas Instruments CC2540.

我浏览了成千上万的网页,并浏览了Stack溢出信息,以了解如何加快从Android设备到CC2540的数据传输,但是还没有找到任何真正的好例子.

I have gone through tons of we pages, and scanned Stack overflow for information how to speed up the transfer of data from the Android device to the CC2540, but haven´t found any really good example.

在Nordic半导体主页上,我找到了一个示例,说明了它们如何计算Android单元的最大吞吐量: ( https://devzone.nordicsemi.com/index .php/how-do-i-calculate-throughput-for-ble-link )

On Nordic semiconductors homepage I found an example of how they calculate the maximum throughput for a Android unit: (https://devzone.nordicsemi.com/index.php/how-do-i-calculate-throughput-for-a-ble-link)

Nexus 4 with nRF51822: 4 * 20 B * 1/0.0075 s = 10.6 kB/s = 84 kbps

它说一个Android单元可以每个连接间隔发送4个20字节的数据包,并且Android可以处理7.5ms的连接间隔.

It says that an Android unit can send 4 packets of 20 bytes per connection interval, and that Android can handle connection intervals of 7.5ms.

在我们的应用中,我们当前正在使用 writeCharateristics 发送数据,并等待 onWriteCharateristics 回调,然后再发送下一个数据块.但是,由于回调大约需要2秒钟才能被调用,因此发送速度非常慢.这使得数据传输速率为10字节/秒,与上面的示例计算中的10.6kb/s相距甚远.

In our app we are currently sending data with writeCharateristics and wait for onWriteCharateristics callback before we send the next chunk of data. However, that sending rate is painfully slow as the callback takes about 2 seconds to be called(!!). That makes a data transfer rate of 10 bytes/s which is far away from the 10.6kb/s in the example calculation above.

我们尝试在两个iOS设备之间传输50kb的数据(使用iOS版KeyFob演示的修改版),并获得3.4kb/s的传输速率.但这使用了 CBPeripheralManager UpdateValue ,据我了解,这是从外围设备向中央发送通知的一种方式.

We have tried transferring 50kb of data between two iOS devices (with a modified version of the KeyFob demo for iOS) and got a transfer rate of 3.4kb/s. But that was using the CBPeripheralManager UpdateValue which I understand is a way of sending a notification from peripheral to central.

我所阅读的内容暂时无法使Android设备作为外围设备工作.这是否意味着CC2540无法将通知发送到Nexus 7?并且是最大化通过通知发送数据的吞吐量的唯一方法吗?

What I have read there is no way right now to have an Android device working as peripheral. Does this mean it's impossible for a CC2540 to send notifications to the Nexus 7? And is the only way to maximize the throughput to send the data through notifications?

是TI设备中的堆栈使它变慢了,还是有任何方法可以更改任何参数以使Nexus和CC单元之间的数据传输更快?

Is it the stack in the TI device that makes it all slow, or is there any way to change any parameters to make the data transfer faster between the Nexus and the CC-unit?

我们想到了在Nexus 7设备中实现GATT服务器的方法,并让CC2540订阅来自其的通知.那可能吗?这意味着Nexus首先必须扫描CC2540,并在找到服务后将其连接.建立连接后,CC2540开始从Nexus 7订阅通知.此后,从Nexus以较高的传输速率向CC2540发送通知.

We had an idea of implementing a GATT server in the Nexus 7 device and make the CC2540 subscribe for notifications from it. Is that possible? That means the Nexus first have to scan for the CC2540 and connect to it when it finds the service. When the connection is established, the CC2540 starts to subscribe for notifications from the Nexus 7. After that sending notifications from the Nexus to the CC2540 with a higher transfer rate.

希望有人尝试做与我们尝试做的事情相同的事情!

Hopefully someone else has been trying to do the same thing as we are trying to do!

推荐答案

几个月前,我使用CC2540从事一个项目,不幸的是,该项目涉及另一个应用领域.

Some months ago I worked to a project using the CC2540, unfortunately the project was about another application field.

无论如何,我记得您可以设置连接参数,例如 Connection_Interval Slave_Latency ,以提高吞吐量,即使功耗会比以前大. 也许您已经尝试过这样做,但是我认为这是获得良好结果的唯一方法.

Anyway I remember that you can set your connection parameters like the Connection_Interval or the Slave_Latency in order to improve your throughput, even if the power consumption will be greater than before. Probably you have already tried to do that but I think this is the only way to obtain a good result.

这篇关于蓝牙BLE Android以最大吞吐量写入外围设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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