修改上一篇文章的程序,client定时发送数据,server把收到的数据写入flash而不发送到串口。测试BLE传输数据能达到的最大吞吐量,结果如下:
1)2.5 KB/s @interval = 40 ms, latency = 0, client每40 ms调用gecko_cmd_gatt_write_characteristic_value发送200字节数据;
2)5 KB/s @interval = 20 ms, latency = 0, client每40 ms调用gecko_cmd_gatt_write_characteristic_value发送200字节数据;
3)10 KB/s @interval = 20 ms, latency = 0, client每20 ms调用gecko_cmd_gatt_write_characteristic_value_without_response发送200字节数据;
4)20 KB/s @interval = 20 ms, latency = 0, client每10 ms调用gecko_cmd_gatt_write_characteristic_value_without_response发送200字节数据;
5)20 KB/s @interval = 20 ms, latency = 0, client每5 ms调用gecko_cmd_gatt_write_characteristic_value_without_response发送200字节数据;
6)20 KB/s @interval = 10 ms, latency = 0, client每5 ms调用gecko_cmd_gatt_write_characteristic_value_without_response发送200字节数据;
7)81 KB/s @interval = 40 ms, latency = 0, client每10 ms调用4遍gecko_cmd_gatt_write_characteristic_value_without_response发送240字节数据。
用write方式,两个interval才能传送一个包(1, 2);而用write_without_response方式,每个interval可以传送多个包,包数由物理层速率和包长度决定。
当把发送间隔减小到5 ms时,吞吐量跟10 ms时一样(5, 6),这是因为soft timer支持的最短间隔是10 ms,所以实际上还是每10 ms才发送了一次。
可以一次调用几遍write_without_response,这样能发送更多的数据(超过MTU),达到接近极限的数据吞吐量。