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 

Parents Reply Children
  • Hello again Vishnu,

    Vishnu Pradeep said:
    It is not resetting. We disconnect the Bluetooth and stop advertising too when USB is connected. 
    Vishnu Pradeep said:
    Will try to do this. In fact the issue is happening without any Bluetooth packet exchange. I just connected the device to our app or nrf uart app and disconnected.

    I am sorry, but I am not sure I understand what you mean by this. Are you saying that the issue ( added CR character at the end of a transmission ) appears regardless of BLE connection status?
    If so, I do not understand the part in which you say it happens without Bluetooth packet exchange, while also saying you are connected to the device through an app or nRF UART app?
    Please bear in mind that empty packets are constantly being exchanged in a connection where no communication is happening on the application layer.

    Best regards,
    Karl

  • We disconnect the Bluetooth and stop advertising too when USB is connected. 

    On USB power detect event, we call sd_ble_gap_disconnect and sd_ble_gap_adv_stop.

    Are you saying that the issue ( added CR character at the end of a transmission ) appears regardless of BLE connection status?

    I am sorry I meant, the packets send by our application, not the empty packets. 

  • 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