工具与软件:
您好、TI
建立 BLE 连接后、我重新启动外设、在再次建立 BLE 连接时未能建立 L2CAP。
调试后、我发现重新引导外设后、中央器件无法执行 L2CAP_DisconnectReq ()、返回 INVALIDPARAMETER:通道 ID 无效。
这是什么原因呢? 我可以通过重新启动中央设备来重新建立 L2CAP。
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;
}
日志:
[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
此致
普雷斯顿
