BOOL L2CAP_destroy() { INT i = 0; if (NULL != gpsL2CAPCB) { for (i = 0; i < L2CAP_MAX_CHANNELS; ++i) { if(NULL != gpsL2CAPCB->pasChannel[i]) { BT_free(gpsL2CAPCB); } } BT_free(gpsL2CAPCB); gpsL2CAPCB = NULL; } return TRUE; }
bool SDP_destroy() { if (NULL != gpsSDPCB) { BT_free(gpsSDPCB); } return true; }
BOOL L2CAP_API_sendData(UINT16 uPSM, const BYTE *pData, UINT16 uLen) { BYTE *pL2CAPData = NULL; UINT16 i, uL2CAPLength; L2CAP_CHANNEL *pChannel = NULL; ASSERT(NULL != gpsL2CAPCB); ASSERT(gpsL2CAPCB->isInitialised); pChannel = _L2CAP_getChannelByPSM(uPSM); if (NULL == pChannel) { DBG_INFO("Non-existant channel\n"); return FALSE; } /*Generate an L2CAP data frame*/ /*Set the length*/ uL2CAPLength = uLen + L2CAP_HDR_LEN; /*Allocate the memory (mind the L2CAP HDR)*/ pL2CAPData = (BYTE *) BT_malloc(uL2CAPLength); if(NULL == pL2CAPData) { DBG_ERROR("Not enough memory!\n"); return FALSE; } /*Set the L2CAP frame header*/ /*Length*/ BT_storeLE16(uLen, pL2CAPData, 0); /*Channel*/ BT_storeLE16(pChannel->uRemoteCID, pL2CAPData, 2); /*Do a simple memcopy to get the payload*/ for (i=0; i<uLen; ++i) { pL2CAPData[i + L2CAP_HDR_LEN] = pData[i]; } /*Send the local frame*/ if (!gpsL2CAPCB->HCIsendData(pL2CAPData, uL2CAPLength)) { DBG_ERROR("Unexpected error\n"); return FALSE; } /*Free the memory*/ BT_free(pL2CAPData); DBG_INFO("L2CAP Data sent\n"); return TRUE; }