LP-EM-CC2340R5: L2CAP cannot be established after the peripheral is restarted

Part Number: LP-EM-CC2340R5

Tool/software:

Hi, Ti

After the BLE connection was established, I restarted the peripheral and failed to establish L2CAP when the BLE connection was established again.

After debugging, I found that after rebooting the peripheral, the central device failed to execute L2CAP_DisconnectReq(), returning INVALIDPARAMETER: Channel id is invalid.

What is the reason for this? I can re-establish L2CAP by rebooting the central device.

static bStatus_t L2CAPCOC_closeCoc(uint16_t connHandle)
{
  bStatus_t ret = SUCCESS;

  ret = L2CAP_DisconnectReq(gL2CAPCOC_AppData.CID);

//  MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE1, 0,
//                    "L2CAP: COC disconnected "
//                    "PSM "               MENU_MODULE_COLOR_YELLOW "%d " MENU_MODULE_COLOR_RESET
//                    "Peer PSM "          MENU_MODULE_COLOR_YELLOW "%d " MENU_MODULE_COLOR_RESET
//                    "CID "               MENU_MODULE_COLOR_YELLOW "0x%x " MENU_MODULE_COLOR_RESET
//                    "Peer CID "          MENU_MODULE_COLOR_YELLOW "0x%x " MENU_MODULE_COLOR_RESET,
//                    gL2CAPCOC_AppData.PSM,
//                    gL2CAPCOC_AppData.peerPSM,
//                    gL2CAPCOC_AppData.CID,
//                    gL2CAPCOC_AppData.peerCID);
  PHSCA_ESELOG_PRINTF("L2CAP: COC disconnected!!!PSM:%d PeerPSM:%d CID:0x%x PeerCID:0x%x ret=0x%2x\r\n",
                      gL2CAPCOC_AppData.PSM, gL2CAPCOC_AppData.peerPSM, gL2CAPCOC_AppData.CID,
                      gL2CAPCOC_AppData.peerCID, ret);

  ret |=  L2CAP_DeregisterPsm( gL2CAPCOC_AppData.taskId, gL2CAPCOC_AppData.PSM);

//  MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE, 0,
//                    "De-Register PSM " MENU_MODULE_COLOR_YELLOW "%d " MENU_MODULE_COLOR_RESET,
//                    gL2CAPCOC_AppData.PSM);
  PHSCA_ESELOG_PRINTF("De-Register PSM [%d] taskid[0x%2x] ret=0x%2x\r\n", gL2CAPCOC_AppData.PSM, gL2CAPCOC_AppData.taskId, ret);

  memset(&gL2CAPCOC_AppData, 0, sizeof(gL2CAPCOC_AppData));

  return ret;
}

log:

[17:18:05.831] Conn status: Established
[17:18:05.833] L2CAPCOC_openCoc
[17:18:05.833] Register PSM 1 SUCCEDED
[17:18:05.836] Connection request sent to PSM ID 1 taskid[0x80]
[17:18:06.617] Pairing status: Encrypted
[17:18:06.720] L2CAP: COC established!!!PSM:1 PeerPSM:1 CID:0x40 PeerCID:0x40 mtu:0x1400 mps:0x1024
[17:18:07.822] Conn status: Terminated
[17:18:31.331] L2CAP: COC disconnected!!!PSM:1 PeerPSM:1 CID:0x40 PeerCID:0x40 ret=0x 2
[17:18:31.332] De-Register PSM [1] taskid[0x80] ret=0x 2

Best regards

Preston

  • Hi Preston,

    Thank you for reaching out. Can you specify which SDK version this behavior is being seen in? We have just released the 8.20 SDK which contains some additional features and fixes. Can you see if that behavior is present in the latest SDK as well? If so, then could you also share details on how you are rebooting the device?

    Best Regards,

    Jan

  • Hi, Jan

    I used simplelink_lowpower_f3_sdk_8_10_01_02 for my earlier tests, and I just updated to simplelink_lowpower_f3_sdk_8_20_00_119 and still had this problem.

    I first establish BLE connection using two CC2340 boards and establish L2CAP. After the L2CAP is established, the central device will send a test command through Bluetooth and output it through the serial port on the peripheral device. Then I press the reset button to reset the peripheral device and wait for Bluetooth to disconnect automatically, I will see that the ID is invalid when the central device disconnects the L2CAP (L2CAP_DisconnectReq() returned 0x02), and the L2CAP is not established after the reconnection (I guess the psm is not cleared).

    I found that when the central device was restarted, the peripheral device disconnected Bluetooth and returned invalid ID, but it could re-establish L2CAP. I think it is because the central device, as the initiator, cleared the psm information after reset.

    Best regards

    Preston

  • Hi Preston,

    I would like to try to reproduce this on my side. Can you share the minimum amount of changes required to reproduce this behavior on basic_ble?

    Best Regards,

    Jan

  • Hi, Jan

    This is my code, which contains both the central and peripheral.

    CC2340_L2CAP_test.zip

    I enabled the use of L2CAP Connection Oriented Channels, and then added the ability to scan and connect automatically.

    Please use my example to test, if you have unexpected situation, please reply.

    Best regards

    Preston

  • Hi Preston,

    I flashed two devices with the images provided and followed the steps below:

    1. Reset both devices

    2. Wait for connection to form and test message to send "aaaa..."

    3. Once test message is received, reset peripheral

    4. Wait for central to detect disconnection

    After these steps, the connection forms again, but the log is as follows:

    Based on the log, i am interpreting this as the connection forming, but no L2CAP processes kicking off afterwards. Is this correct? I just want to ensure I have reproduced the issue exactly as you see it.

    Best Regards,

    Jan

  • Hi, Jan

    Yes, the issue you are reproducing matches what I have saw.

    Best regards

    Preston

  • Hi Preston,

    Thank you for confirming. I have taken some sniffer logs and filed a ticket for R&D to address this as soon as possible. If you would like to track this ticket, then the ticket ID is BLE_LOKI-2549.

    Best Regards,

    Jan

  • Hi, Jan

    Sorry, I tried to click the Reply button, but mistakenly clicked the resolve issue button. And then I want to ask how do I track this ticket? I tried to search for this ID in E2E, but nothing was found

    Best regards

    Preston

  • Hi Preston,

    No worries! You may reach out to your TI field representative for updates on this. Once the R&D team is able to look into this, they will add the ticket to the list of known or fixed issues included in the SDK release notes.

    Best Regards,

    Jan