Hello Dialog,
I asked this in an earlier thread of mine but it was flagged as solved and may not have been revisited - I am using the DA14580 with the SPS profile and am trying to use to to relay 20 bytes every 80ms. The DA gets the data over UART from the main uC and sends it to a portable device that displays the data. The problem I am having is that the data packets that my portable receives are not consistent in size - sometimes the packet has 20 bytes as desired, but other times single 20 byte transmission comes as two packets or the data is 20 bytes wide, but shifted.
I send the 20 bytes over UART over the duration of ~2 ms, so there should be plenty of time for the DA to receive the data and send it away before the next cycle of data comes in.
I need the data packets to be the same size always because my portable's application expects them to be consistent. Do you know what could be causing this issue?
Thank you,
svl0822型

你好,你在用硬件流量控制吗?哪个设备被配置为中央设备(我假设是通过UART从主机MCU获取数据的设备)?
Thanks JE_Dialog
你好,我的对话,
I am not using HW flow control. I presumed that this wasn't necessary because i get all the bytes that I send (over BLE) but what varies is the packet size that they come in.
I am using the "device" SPS project on my DA14580. The central is my main chip, the DA14580 is only acting as bluetooth-serial interface.
svl0822型
Hi svl0822,
您正在观察对话框串行端口服务的预期行为。串行端口链路与UART完全异步,数据包完整性得不到保证,这当然不是有意的。DSPS实现针对流数据进行了优化,并不适合您的应用程序。
From your description, you are actually attempting to send discrete data packages - which is exactly how BT Smart was intended. You should implement a custom service with a 20byte sized characteristic. Every time you have 20 bytes ready for BT transmission, you should go ahead and load them into the characteristic(in the GATT database). The smartdevice (tablet/smart phone) implementation is far simpler this way, and the packet integrity is ensured. You would use GATT Notify to make sure that the 20byte data chunk is send to the smartdevice every time you update the data.
如果您需要有关实现自定义服务的更多信息,请告诉我。它并不像听起来那么可怕,而且它肯定更适合您所描述的用例。代码占用也会小得多。
MHv_Dialog,
Thank you for the detailed explanation. What you described sounds like it would work.
Is there any documentation available on implementing a custom service? I looked at the software development guide but it does not go into detail on this.
Is it possible for me to use the SPS service and just add a new characteristic in the "sps_server_task.c" file? Also, when you say "20 byte wide characteristic" do you mean having an attribute called "size" which would have length 20? I am looking at the declarations for the TX data characteristic and it has attributes of fixed lengths, so I do not see where the variability is coming from. Could you explain this for me?
谢谢你的耐心。我是一个新的BLE编程和不确定的基础知识。
嗨,也许你应该参考一下the sample128 or spotar service.
你好,我也面临同样的情况,与一个发送/接收13字节数据包的micro通信。在两个方向上,对于单个数据包来说,一切都很好,但最终事情会分崩离析,当只有部分数据包被放入UART-to-BLE缓冲区时,我会收到通知。如果有一种简单的方法来暂停notify,直到在UART上接收到完整的13个字节,那么问题就解决了。TX\u WAIT\u LEVEL似乎暗示了这一点,但它被注释为//3个数据包(20+2*27),没有进一步的解释。你知道这是不是正确的方法吗?
嗨,克里姆,我能在一个很高的时候问你吗level what you are trying to acheive ? the DSPS has been designed for a pure streaming app : there isn't anything in the way of preserving packet integrity - it just fills buffers and transmits. I was just wondering if there was a simpler approach that might help, like using AN-B-029 to build a simple custom profile to meet your needs. If DSPS is the way to go, we can look at your question about adding the TX_WAIT_LEVEL (its not somethign we've tried yet). BR JE_Dialog
Hi JE_Dialog,
My solution was to continue to stream the data, but within the app I disassemble/assemble the packet.
I included a timeout handler on packet reassembly so that if a given packet takes too long to assemble, then I *assume* that there was a problem maintaining the BLE connection.
In this case I reattempt to send/receive the packet, and eventually fail out to a "communication lost" exception handler.
Works good so far, if later I need to make any more changes then I will post them here.
干杯,--克里姆
Hi Klim, thanks for letting us know it worked ok for you... apprecaite the feedback, BR JE_DIalog