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