Hello,
I made a project based on the usbd_ble_uart_freertos example and added peer manager for secure connections.
It works in a way that someone can open the uart port and send data o r a ble connection can be made if an advertising peripheral is available.
But USB CDC dies after initiating the ble connection: After a ble connection is made my serial app on the pc hangs when opening the com port and I don't see any messages in the debugger.
I know that this is difficult but I don't know which code snippet to post here.
Maybe someone has an idea why initiating an ble connection leads to fail usb cdc acm?
I am using nrf sdk 17.0.1.
A small update: the app itself still works when pc tries to open the UART. BLE devices are found and connected. But USB CDC ACM module seems to be dead? I enabled logging APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED:
<debug> nrf_sdh_freertos: Creating a SoftDevice task. <debug> nrf_ble_lesc: Initialized nrf_crypto. <debug> nrf_ble_lesc: Initialized nrf_ble_lesc. <debug> nrf_ble_lesc: Generating ECC key pair <info> app: USB power detected <debug> nrf_sdh_freertos: Enter softdevice_task. <debug> ble_scan: Added filter on UUID 1 <info> app: START SCAN <debug> ble_scan: Scanning <info> app: USB ready // here PC opens port <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> app: CDC ACM port opened <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 0, databits: 0, format: 0, parity: 0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 0, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0 <info> cdc_acm: REQ_SET_LINE_CODING: baudrate: 115200, databits: 8, format: 0, parity: 0 <info> cdc_acm: REQ_SET_CONTROL_LINE_STATE: 0x0
This log is when no BLE is connected. After ble gets connected no "cdc_acm" logs are added when trying to send, receive data or close the uart on pc.
Thanks!
Andreas
Update 2:
I narrowed it down to following lines:
void usb_new_event_isr_handler(app_usbd_internal_evt_t const *const p_event, bool queued) { NRF_LOG_INFO("in %i",p_event->type); BaseType_t xHigherPriorityTaskWoken = pdFALSE; UNUSED_PARAMETER(p_event); UNUSED_PARAMETER(queued); ASSERT(m_usbd_thread != NULL); /* Release the semaphore */ vTaskNotifyGiveFromISR(m_usbd_thread, &xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken); NRF_LOG_INFO("out"); NRF_LOG_FLUSH(); }
In the log I see that in is called but not out once ble connection is made:
<info> app: in 8 <info> app: out <info> app: USB power detected <debug> nrf_sdh_freertos: Enter softdevice_task. <debug> ble_scan: Added filter on UUID 1 <info> app: START SCAN <debug> ble_scan: Scanning <info> app: in 10 <info> app: out <info> app: USB ready <info> app: in 129 <info> app: out <info> app: in 2 // is this an usb suspend? Why