This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How the nus mode is automatically subcontracted and sent efficiently?

Hi, there

  1. NRF51822
  2. SDK9.0.0 and S110

How to subcontract in uart nus mode to ensure that each packet does not exceed 20 bytes and is sent as quickly as possible? The official demo must pass the special character to distinguish the last packet. If i do not use special characters to determine the last package, are there other good ways to do this thing ?

Parents
  • What do you mean by "subcontract" and "nus mode"? If you want to say that you are using Nordic BLE UART Service (NUS) example and want to be sure that you always pass 20 bytes to it well then simply implement some logic on top of NUS data transfer function to be sure that longer data get fragmented properly. Of course there are plenty ways of making fragmentation, you can get inspiration from any networking protocol. All depends on your priorities: do you need to have the protocol easy to parse (= small code size) or you don't care if it's few bytes bigger FW image but you want to have as minimal overhead? And for what sizes you want to optimize your protocol (= will you be sending mostly small packets <20B or mostly some medium 20-200B or mostly long 200B+)?

  • Well NUS is unstructured serial line without flow control. So the question is: how would you handle the same transfer if that would be wire and not BLE? Minimum is to implement some FIFO mechanism which keeps track about offset in data buffer from where data already went over BLE link. Link Layer in the stack has typically several buffers (6+) so you can stack your 20-byte packets there and once lower layer says that no more Tx buffers are available then you need to wait for Tx completed event and continue in your state machine. This will be pretty easy to implement (many Q&S on this forum and similar things are shown in nRF5 SDK examples) but it will work only if higher layer will be able to interpret such stream of data. If not then you can either add some header to each packet (e.g. one byte which codes if that is start of the packet, middle or the end) or... (1/2)

Reply
  • Well NUS is unstructured serial line without flow control. So the question is: how would you handle the same transfer if that would be wire and not BLE? Minimum is to implement some FIFO mechanism which keeps track about offset in data buffer from where data already went over BLE link. Link Layer in the stack has typically several buffers (6+) so you can stack your 20-byte packets there and once lower layer says that no more Tx buffers are available then you need to wait for Tx completed event and continue in your state machine. This will be pretty easy to implement (many Q&S on this forum and similar things are shown in nRF5 SDK examples) but it will work only if higher layer will be able to interpret such stream of data. If not then you can either add some header to each packet (e.g. one byte which codes if that is start of the packet, middle or the end) or... (1/2)

Children
No Data
Related