Hi Ti,
If possible, please reply my message ths time, It is urgent in our product devolopment.
I want to register my own CID to communicate between 2 CC2540/CC2541(s).
For debug, i register CID 0004 that is for ATT, for i can debug easily using USB dongle.
In debug, receive of ATT command works as expect.
But i failed to receive data in BTtools, Always timeout.
Skeleton of sending code is
L2CAP_bm_alloc() -> L2CAP_SendData() -> osal_bm_free();
Following is the event process source code registered to L2CAP layer.
uint16 VTPProcessEvent( uint8 task_id, uint16 events )
{
VOID task_id;
if ( events & SYS_EVENT_MSG )
{
l2capDataEvent_t *pMsg;
l2capPacket_t pPkt;
if ( (pMsg = (l2capDataEvent_t *)osal_msg_receive( 12 )) != NULL )
{
if(pMsg->pkt.pPayload)
{
attMsg_t *attm = (attMsg_t * )(pMsg->pkt.pPayload + 1);
switch(pMsg->pkt.pPayload[0])
{
case ATT_FIND_INFO_REQ:
case ATT_FIND_BY_TYPE_VALUE_REQ:
case ATT_READ_REQ:
case ATT_READ_BY_GRP_TYPE_REQ:
case ATT_READ_BY_TYPE_REQ:
case ATT_WRITE_REQ:
case ATT_EXCHANGE_MTU_REQ:
case ATT_READ_BLOB_REQ:
case ATT_READ_MULTI_REQ:
case ATT_PREPARE_WRITE_REQ:
case ATT_EXECUTE_WRITE_REQ:
case ATT_WRITE_CMD:
case ATT_SIGNED_WRITE_CMD:
case ATT_HANDLE_VALUE_IND://return unsupport
default:
pPkt.pPayload = L2CAP_bm_alloc(32);
pPkt.CID = pMsg->pkt.CID;
pPkt.pPayload[0] = ATT_ERROR_RSP;
pPkt.pPayload[1] = pMsg->pkt.pPayload[0];
pPkt.pPayload[2] = pMsg->pkt.pPayload[1];
pPkt.pPayload[3] = pMsg->pkt.pPayload[2];
pPkt.pPayload[4] = ATT_ERR_UNSUPPORTED_REQ;
pPkt.len = 5;
L2CAP_SendData(pMsg->connHandle, &pPkt);
osal_bm_free(pMsg->pkt.pPayload);
osal_bm_free(pPkt.pPayload);
break;
}
VOID osal_bm_free(attm);
}
// Release the OSAL message
VOID osal_msg_deallocate( (uint8 *)pMsg );
}
// return unprocessed events
return (events ^ SYS_EVENT_MSG);
}
// Discard unknown events
return 0;
}