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

BLE lost messages

Hi, as part of my project i have 2 nordic 52dks one as a pheripheral (sending) and on as a client (recieving). where i am sening a buffer of 8, in the order

buffer[0] = 10

buffer[1}= X gyro lsb

buffer[2] = X gyro msb

buffer[3] = y gyro lsb

buffer[4] = y gyro msb

buffer[5] = z gyro lsb

buffer[6] = z gyro msb

buffer[7] = 36   //terminator $

however sometimes i seem to lose a byte over ble such that the next byte received will be less and hence the order is correupted thus making processing rather and unpredictable for a large sample size like 1000000 samples.

how may i ensure that my ble settings are correct such that i ensure to limit this issue.

my code was based of the examples ble_app_uart and ble_app_uart_c for the peripheral and client respectivly.

thank u in advance 

Parents
  • Hello,

    however sometimes i seem to lose a byte over ble such that the next byte received will be less and hence the order is correupted thus making processing rather and unpredictable

    No byte is lost over the BLE link, it is not possible as the protocol uses the CRC field to verify that the contents of the packet is uncorrupted and received as it was sent. If the CRC does not match, the packet is discarded and not acknowledged - leading to a re-transmission of the same packet.
    If you would like to confirm the communication happening on-air between the devices you could use the nRF Sniffer tool to trace the communication and read the individual packet contents.

    How is your handling / processing of the received data? How are you alerted to the seemingly corrupted data? Have you checked whether the corrupted values could be what the peripheral intended to send?

    Looking forward to resolving this issue together!

    Best regards,
    Karl

  • Firstly i would like to thank you for your reply, and for the sniffer, is there any documentation on how to install this please?

    The way im checking that the data is being missed is through the uart terminal of the client (recieving) board and also i have a matllab script that is reading serially aswell. to check this i sent known data meaning sending 8 bytes (hex) 10-16 and a terminator 36.

    and as u can see in the first colomn its fine but then in the second colom the 12 didnt send or be recieved which will therefore mess up my data 

  • so you are not doing what the throughput documentation has told you to do,

    so for the below config i set the con interval of both pheripheral and client to 50ms 

    Client

     :

    Pheripheral

    i dont think theres amything else to change right  please? 

    i cant seem to manage to do it... im unsure why 

    im opening the cmd in the above seen path

  • Hello again,

    NikTheNordicUser said:
    so for the below config i set the con interval of both pheripheral and client to 50ms 

    Great! Now your devices will communicate with a 50 ms connection interval.

    NikTheNordicUser said:
    i dont think theres amything else to change right  please? 

    Have you changed the MTU size and PHY (you need to use 2 Mbps PHY for maximum throughput)? Have you set the connection event length to the same value as the connection interval, as previously mentioned? 
    If you have, please show that as well for completeness. If you have not, please do so.

    NikTheNordicUser said:
    i cant seem to manage to do it... im unsure why 

    It seems it does not find pip3 as a command. Which python version do you have installed on your computer? In the command prompt, type python -V to see the python version. You will need to have python 3.6 or later installed, to complete the installation.
    This is clearly mentioned as one of the first things in the installation guide:

    Before you start setting up the nRF Sniffer, make sure that you have the following prerequisites installed on your computer:

    • Wireshark v2.4.6 or later (v3.0.7 or later recommended on Windows). Wireshark is a free software tool that captures wireless traffic and reproduces it in a readable format.
    • Python v3.6 or later.

    Please make sure that you meet these prerequisites before continuing with the installation.

    Best regards,
    Karl

  • MTU size

    from both pheripheral and client they are set as 247

    as for the PHy is can only be set in the client right?

    meet these prerequisites before continuing with the installation

    yes i had them downloded but using the phyton-V command didnt work so i unstalled both wireshark and phyton and reinstalled them and it seem to work

    i followed the next steps and got till here:

    then i went to press F5 to see the snffer but its not in the interfaces as can be seen below

    also do i need to have another board for the sniffer ? or can i use the pheripheral or the client?

  • update: I managed to successfully install the sniffer and program another nrf52dk with the hex file and im seeing packets being transfered. i still have 2 questions however..

    1. How can i know for sure which is my device as im seeing packets from multiple devices

    2. Howcome the lengths of packets varry between 21-37 if i should be sending 242 bytes from the pheripheral ( confirmed by the uart of the client) 

    is there something im missing please?

  • i hope that its visable but as should be seen the speed is set at 1MBPS and i set it in both codes as 2 howcome i still get 1 MBPS. also howcome i dont always recive the same amount of data (should i not always recieve 242 bytes at once)

    thank you :)

Reply
  • i hope that its visable but as should be seen the speed is set at 1MBPS and i set it in both codes as 2 howcome i still get 1 MBPS. also howcome i dont always recive the same amount of data (should i not always recieve 242 bytes at once)

    thank you :)

Children
  • Hello again,

    NikTheNordicUser said:
    update: I managed to successfully install the sniffer and program another nrf52dk with the hex file and im seeing packets being transfered.

    I am happy to hear that you were able to resolve your issues setting up the sniffer, and that you now have it working! :) 

    NikTheNordicUser said:
    1. How can i know for sure which is my device as im seeing packets from multiple devices

    I suppose you have already figured this out, but you need to select your device in the device dropdown menu. You need to do this prior to establishing a connection to make the sniffer follow into the connection.

    NikTheNordicUser said:
    2. Howcome the lengths of packets varry between 21-37 if i should be sending 242 bytes from the pheripheral ( confirmed by the uart of the client) 
    NikTheNordicUser said:
    howcome i dont always recive the same amount of data (should i not always recieve 242 bytes at once)

    Please send the trace, and illustrate this with specific packets in the trace.

    NikTheNordicUser said:
    the speed is set at 1MBPS and i set it in both codes as 2 howcome i still get 1 MBPS.

    You can send an PHY update request if your connection is not using the PHY you would like See how the BLE_GAP_EVT_PHY_UPDATE_REQUEST (received request) is handled in the central's ble_evt_handler.

    Brief googling also yielded this very good third party tutorial on how to achieve maximum throughput for BLE 5. I highly recommend that you have a read through this, to better understand the meaning of the different parameters, and how to set them for maximum throughout. The tutorial also links to our throughput and long range demo, which could be very useful for you to have a look at at this point in your project.

    NikTheNordicUser said:
    i hope that its visable but

    Sorry, I am not able to see anything in the video you have provided.
    Please share the trace file instead, and make comments with references to packet numbers etc.
    For example, "The behavior can be seen in the exchange starting on packet 112256, and lasts until packet 112300", or similar.

    Best regards,
    Karl

  • wsh.pcapng

    ive attached the wireshark hope that it can be opened form your end... if we look at for example number 226 the packets are being fragmented, should i not be recvieng 242 bytes + any overheads creating by ble (which i think totals to 249 bytes) is this fragmentation normal ? 

    also as can be seen in the PHY colomn it says 1M but i configured both sdks (central and pheripheral) as 2Mbps and you have told me to update request, should it not alwasy be 2Mpbs if i configured them as 2Mbps if not how do i update the request please?

    also one final thing please, how am i apple to calculate th exact speed cause i know ill never achieve the 2Mbps mark so i would like to include the actual speed im transfering at.

    Thank you and good day

  • also as i told you previously, i have set both peripheral and client to 50ms conn interval as can be seen below

    Pheripheral:

    client

    why is that if i change the event length seen below i do not get a connection between the devices can you explain please?

  • Hello,

    NikTheNordicUser said:
    ive attached the wireshark hope that it can be opened form your end...

    Yes, I am able to open the wireshark capture, thank you.

    NikTheNordicUser said:
    if we look at for example number 226 the packets are being fragmented, should i not be recvieng 242 bytes + any overheads creating by ble (which i think totals to 249 bytes) is this fragmentation normal ? 

    Fragmentation is normal, yes. Your total frame length is 249.
    See the initial packets in your trace. Your MTU is set to 247.
    You are correct that it adds 7 bytes overhead total - 3 byte ATT header, 4 byte L2CAP header.
    Please have a look at this ticket for a more detailed explanation.

    NikTheNordicUser said:
    also as can be seen in the PHY colomn it says 1M but i configured both sdks (central and pheripheral) as 2Mbps and you have told me to update request, should it not alwasy be 2Mpbs if i configured them as 2Mbps if not how do i update the request please?

    This is exactly why having the sniffer trace is a great tool. We can here see that there is never any PHY update request for 2 Mbps. So we know that this procedure is never initiated, and thus the PHY will not change from its original PHY, which in all SDK examples are 1 Mbps.
    Could you tell me exactly what you have done to change your PHY to 2 Mbps?
    As I understand it, you have only changed the SCAN_PHY define that you shared a screenshot of earlier - i.e which PHY the central will scan on, and not actually implemented the PHY update procedure that I asked you to earlier?
    If there is no PHY Update request, the PHY will be the same as the peripheral was advertising with. It appears from your provided trace that this is 1 Mbps.

    Please have a look at this other ticket, which discusses PHY's and how configuring them work.
    The link provided by Vidar is broken, but this is the message sequence chart he is referring to.

    NikTheNordicUser said:
    i have set both peripheral and client to 50ms conn interval as can be seen below

    This is successful, and we can see from packet #76 that your devices are communicating with 50 ms connection interval.

    NikTheNordicUser said:
    why is that if i change the event length seen below i do not get a connection between the devices can you explain please?

    What do you change it to? Is this on the peripheral or central side?
    What does the trace say when you have changed this? Are you able to see the peripheral advertise, but not connect? Or do you not see it advertise at all when you've made this change? Is there an error generated?
    The more specific information you provide, the easier it will be for us to resolve the issue.

    NikTheNordicUser said:
    also one final thing please, how am i apple to calculate th exact speed cause i know ill never achieve the 2Mbps mark so i would like to include the actual speed im transfering at.
    Karl Ylvisaker said:
    Brief googling also yielded this very good third party tutorial on how to achieve maximum throughput for BLE 5. I highly recommend that you have a read through this, to better understand the meaning of the different parameters, and how to set them for maximum throughout. The tutorial also links to our throughput and long range demo, which could be very useful for you to have a look at at this point in your project.

    Please have a look at the examples referenced in this tutorial - especially the throughput example. Have a look at how they implement the throughput calculations to see how you may proceed with this yourself.

    Best regards,
    Karl

Related