QN902x 传输速率
0赞BLE 本身传输速率不高,物理层的速率为1Mbps,应用层的传输速率会受到很多因素的影响,最主要的因素有:
Connection interval(连接间隔),Packet size和 Attribute protocol operation used。
Connection interval:连接间隔定义了传输数据的频率,即多久传输一次数据,典型的时间间隔为7.5ms-4000ms,(必须是1.25ms的整数倍)。
Packet size:一次传输的包大小
BluetoothSmart technology supports the following ATT operations and application data payloads:
ATT operation |
Max Data payload |
Acknowledged |
Read |
22 bytes |
Yes |
Write |
20 bytes |
Yes |
Write without response |
20 bytes |
No |
Notification |
20 bytes |
No |
Indication |
20 bytes |
Yes |
Attribute protocol operation used:
使用的ATT 协议不同也会影响速率,比如Notification和Indication就会相差一半,因为Indication需要Acknowledge。
假设连接间隔为20ms,使用Notification方式发送数据,一次连接事件中可以发送6包数据,则速率为:
1 sec / 20ms * 20 *6 bytes = 6000 bytes/sec 6K字节每秒
使用QPPS工程,手机端配合QPP APP,可以测得速率为6.7K Bytes/s
另外也可以测试两个QN9020之间的传输速率,其中一个做主一个做从,分别使用QPPC和QPPS工程,注意将QPPC工程中的:
#define GAP_CONN_MIN_CE 0x0000
改为:
#define GAP_CONN_MIN_CE 0xFFFF
这样才可以达到最高的传输速率,我测的结果也是大约6.7K字节每秒
否则不改的话,速率只有1K 字节每秒。
GAP_CONN_MIN_CE 这个参数的含义如下:
The Minimum_CE_Length and Maximum_CE_Length are information parameters providing the Controller with a hint about the expected minimum and maximum length of the connection events. The Minimum_CE_Length shall be less than or equal to the Maximum_CE_Length.
这样改完之后就将连接事件的时间改为了最大值。
另外测试时主要不能加入printf否则会影响测试速率。
参考:
https://bluegiga.zendesk.com/entries/22400867--HOW-TO-Maximize-throughput-with-BLE-modules