This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GATT_Notification



GATT_Notification向central连续发送大约500个数据包,,当发送到268个数据包的时候,GATT_Notification返回0x13错误(bleMemAllocError: Memory allocation error occurred)

后来发现之前连续发送时间间隔设的太短了10ms,改为1s后就没有问题了。

问题1:上述现象产生的原因是不是由于GATT_Notification返回后,数据包实际上只是放在了发送队列,所以占用一部分存储空间,当GATT_Notification调用过于频繁以后导致存储空间分配完毕,造成返回存储空间错误的?

问题2:如果想以最快速度发送完数据,如何避免0x13错误出现?

  • nan,

    1, 对的, 必须缓存啊,然后按顺序发送。

    2., 你可以适当调节connection interval, 1s 也太长了,可以短点。另外,overlap processing 可以帮助你提高速度而且不卡壳: http://processors.wiki.ti.com/index.php/OverlappedProcessing

  • 你可以在网上搜索一下,官方测试吞吐量的程序,人家用的10ms 发送4个notification,每个20个数据,我亲测过,都没有这个现象的。

    你的问题应该处在,分配的空间没有及时释放导致的,应该在每次notification发送完一组数据后,都要清除缓存,重新分配。最简单的用一个20个字节的数组就行了。