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

USBD issue after bluetooth is connected once

Our application stores sensor data in flash and sends the data on request via USB. But if the device is connected to Bluetooth once then it is having issues in USB data transfer. Device receives 21 bytes in place of 20 bytes. Receiving same packet twice even if the host doesn't send. But everything works normal if we power cycle the device.

We wrote application over usbd_ble_uart_pca10056_s140 example. 

Thanks,

Vishnu 

  • Vishnu Pradeep said:
    On USB power detect event, we call sd_ble_gap_disconnect and sd_ble_gap_adv_stop.

    Thank you for clarifying.
    So, you connect your device to your phone through a cabled USB connection, and upon detecting this connection you disconnect any BLE connection and stop advertising.
    Then, you begin a transfer of sensor data over the USB, from the device to the phone.
    In this transfer ( which is entirely independent of BLE communications ) the issue appears, in which a CR character is added to the end of the transfer, when your phone is sending data to the device - but not the other way around. I.e the phone sends 20 bytes, but 21 is received by the device ( added CR character ), but when the device sends 20 bytes to the phone, only 20 bytes are received.
    Have I got this correctly?

    Vishnu Pradeep said:
    I am sorry

    No worries, I am just trying to make sure that I have understood the issue you are facing correctly :) 

    Vishnu Pradeep said:
    I meant, the packets send by our application, not the empty packets. 

    In this case, application here refers to your smartphone application that is sending data to your device over USB. Correct?

    Best regards,
    Karl

Related