BLE: Fix index access to attcCb.onDeck in Cordio.

The connection starts at 1, not 0. The entry in the array should be connId - 1
pull/13785/head
Vincent Coubard 2020-10-19 17:23:42 +01:00
parent 542b725545
commit 3cab37793b
3 changed files with 11 additions and 11 deletions

View File

@ -591,9 +591,9 @@ static void attcConnCback(attCcb_t *pCcb, dmEvt_t *pDmEvt)
}
/* free any req on deck */
if (attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE)
if (attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE)
{
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId], status);
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId - 1], status);
}
for (i = 0; i < ATT_BEARER_MAX; i++)
@ -672,7 +672,7 @@ void attcMsgCback(attcApiMsg_t *pMsg)
/* verify no API request already waiting on deck, in progress, or no pending write command
already for this handle */
if (((pCcb->slot == ATT_BEARER_SLOT_ID) &&
(attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE)) ||
(attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE)) ||
(pCcb->outReq.hdr.event > ATTC_MSG_API_MTU) ||
((pMsg->hdr.event == ATTC_MSG_API_WRITE_CMD) &&
attcPendWriteCmd(pCcb, pMsg->handle)))
@ -686,7 +686,7 @@ void attcMsgCback(attcApiMsg_t *pMsg)
if ((pCcb->slot == ATT_BEARER_SLOT_ID) && (pCcb->outReq.hdr.event == ATTC_MSG_API_MTU))
{
/* put request "on deck" for processing later */
attcCb.onDeck[pCcb->connId] = *pMsg;
attcCb.onDeck[pCcb->connId - 1] = *pMsg;
}
/* otherwise ready to send; set up request */
else
@ -706,9 +706,9 @@ void attcMsgCback(attcApiMsg_t *pMsg)
}
/* else free any req on deck */
else if ((pCcb->slot == ATT_BEARER_SLOT_ID) &
(attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE))
(attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE))
{
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId], ATT_ERR_CANCELLED);
attcReqClear(pCcb->connId, &attcCb.onDeck[pCcb->connId - 1], ATT_ERR_CANCELLED);
}
}
/* else if timeout */

View File

@ -410,13 +410,13 @@ void attcProcRsp(attcCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
}
/* else if api is on deck */
else if ((pCcb->slot == ATT_BEARER_SLOT_ID) &&
(attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE))
(attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE))
{
/* set up and send request */
attcSetupReq(pCcb, &attcCb.onDeck[pCcb->connId]);
attcSetupReq(pCcb, &attcCb.onDeck[pCcb->connId - 1]);
/* clear on deck */
attcCb.onDeck[pCcb->connId].hdr.event = ATTC_MSG_API_NONE;
attcCb.onDeck[pCcb->connId - 1].hdr.event = ATTC_MSG_API_NONE;
}
}
}

View File

@ -178,7 +178,7 @@ static void attcSignMsgCback(attcCcb_t *pCcb, attcSignMsg_t *pMsg)
/* verify no API request already waiting on deck or in progress,
* and no signed write already in progress
*/
if ((attcCb.onDeck[pCcb->connId].hdr.event != ATTC_MSG_API_NONE) ||
if ((attcCb.onDeck[pCcb->connId - 1].hdr.event != ATTC_MSG_API_NONE) ||
(pCcb->outReq.hdr.event > ATTC_MSG_API_MTU) ||
(attcSignCbByConnId((dmConnId_t) pMsg->hdr.param) != NULL))
{
@ -238,7 +238,7 @@ static void attcSignMsgCback(attcCcb_t *pCcb, attcSignMsg_t *pMsg)
pCcb->pMainCcb->sccb[ATT_BEARER_SLOT_ID].control & ATT_CCB_STATUS_FLOW_DISABLED)
{
/* put request "on deck" for processing later */
attcCb.onDeck[pCcb->connId] = pCb->msg;
attcCb.onDeck[pCcb->connId - 1] = pCb->msg;
}
/* otherwise ready to send */
else