This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Check NUS paket is sent ( Data > 23 bytes ) and redy for new transmission

Hello,

we have two custom boards with nRF51822.

We use NUS.

If our pakets under 23 Bytes everthing is fine ....

If we want to sent paket with 140bytes, the central hangs ...

We know the problem is the MTU of 23bytes.

Because of future compability to cell phones, we don't want to increase the MTU.

So our idea is to split the 140bytes into chunks of 20 bytes.

But it seems that we have to wait until the paket ist sent over the air before we send the next chunk

with the ble_nus_c_string_send ...

How can we detect , that the paket is sent ?

Andreas

  • Hi

    you need to wait for the BLE_EVT_TX_COMPLETE event, in addition hold a variable which has the buffer length.

    then every time you send a package, you substract to know the offset to sent the next bytes from and increment the offset.
    and do it all over until the connection breaks or the buffer is empty.

            case BLE_EVT_TX_COMPLETE:
            	if(m_DataOffset < m_DataSize){ // have we reached the end of buffer
            		m_ble_nus_c.conn_handle = p_ble_evt->evt.common_evt.conn_handle; // Multi connection handling
            		SendNUSData(&m_ble_nus_c); // here the data is sent
            	}
            	break;

    Hope this helps

    Martin

Related