Skip to content

Commit 8340ea2

Browse files
authored
Merge pull request #14305 from paul-szczepanek-arm/cordio-host-fix-index
BLE: fix indexing of array in Cordio host stack
2 parents 6c08123 + 53cf062 commit 8340ea2

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_csf.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ uint8_t attsCsfIsClientChangeAware(dmConnId_t connId, uint16_t handle)
134134
/*!
135135
* \brief Update client change-aware state based on protocol event.
136136
*
137-
* \param connId Connection handle.
137+
* \param connId Connection ID.
138138
* \param opcode ATT PDU type.
139139
* \param pPacket Data packet from L2CAP.
140140
*
141141
* \return \ref ATT_SUCCESS if client is change-aware, else \ref ATT_ERR_DATABASE_OUT_OF_SYNC.
142142
*/
143143
/*************************************************************************************************/
144-
uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket)
144+
uint8_t attsCsfActClientState(dmConnId_t connId, uint8_t opcode, uint8_t *pPacket)
145145
{
146146
uint8_t err = ATT_SUCCESS;
147147
attsCsfRec_t *pRec;
@@ -152,7 +152,7 @@ uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket)
152152
return err;
153153
}
154154

155-
pRec = &attsCsfCb.attsCsfTable[handle];
155+
pRec = &attsCsfCb.attsCsfTable[connId - 1];
156156

157157
/* If the client is change-unaware */
158158
if (pRec->changeAwareState == ATTS_CLIENT_CHANGE_UNAWARE)
@@ -167,7 +167,7 @@ uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket)
167167
/* Move client change-aware state to pending */
168168
pRec->changeAwareState = ATTS_CLIENT_CHANGE_PENDING_AWARE;
169169

170-
ATT_TRACE_INFO2("ConnId %d change aware state is %d", handle + 1,
170+
ATT_TRACE_INFO2("ConnId %d change aware state is %d", connId,
171171
ATTS_CLIENT_CHANGE_PENDING_AWARE);
172172
}
173173

@@ -189,12 +189,12 @@ uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket)
189189
/* Move client change-aware state to aware */
190190
pRec->changeAwareState = ATTS_CLIENT_CHANGE_AWARE;
191191

192-
ATT_TRACE_INFO2("ConnId %d change aware state is %d", handle + 1, ATTS_CLIENT_CHANGE_AWARE);
192+
ATT_TRACE_INFO2("ConnId %d change aware state is %d", connId, ATTS_CLIENT_CHANGE_AWARE);
193193

194194
/* Callback to application to store updated awareness, if bonded. */
195195
if (attsCsfCb.writeCback != NULL)
196196
{
197-
attsCsfCb.writeCback(handle + 1, pRec->changeAwareState, &pRec->csf);
197+
attsCsfCb.writeCback(connId, pRec->changeAwareState, &pRec->csf);
198198
}
199199
}
200200
else
@@ -227,15 +227,15 @@ uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket)
227227
*/
228228
pRec->changeAwareState = ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING;
229229

230-
ATT_TRACE_INFO2("ConnId %d change aware state is %d", handle + 1,
230+
ATT_TRACE_INFO2("ConnId %d change aware state is %d", connId,
231231
ATTS_CLIENT_CHANGE_AWARE_DB_READ_PENDING);
232232
}
233233
}
234234
}
235235

236236
if (err == ATT_ERR_DATABASE_OUT_OF_SYNC)
237237
{
238-
ATT_TRACE_INFO2("ConnId %d out of sync, PDU with opcode 0x%02x ignored!", handle + 1, opcode);
238+
ATT_TRACE_INFO2("ConnId %d out of sync, PDU with opcode 0x%02x ignored!", connId, opcode);
239239
}
240240

241241
return err;

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_eatt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void eattsL2cCocDataInd(l2cCocEvt_t *pEvt)
166166
}
167167

168168
/* check client's status to see if server is allowed to process this PDU. */
169-
err = attsCsfActClientState(connId - 1, opcode, pEvt->dataInd.pData - L2C_PAYLOAD_START);
169+
err = attsCsfActClientState(connId, opcode, pEvt->dataInd.pData - L2C_PAYLOAD_START);
170170
if (err)
171171
{
172172
BYTES_TO_UINT16(attHandle, pEvt->dataInd.pData + ATT_HDR_LEN);

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static void attsDataCback(uint16_t handle, uint16_t len, uint8_t *pPacket)
182182
}
183183

184184
/* check client's status to see if server is allowed to process this PDU. */
185-
err = attsCsfActClientState(handle, opcode, pPacket);
185+
err = attsCsfActClientState(pCcb->connId, opcode, pPacket);
186186
if (err)
187187
{
188188
BYTES_TO_UINT16(attHandle, pPacket + L2C_PAYLOAD_START + ATT_HDR_LEN);

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/atts_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void attsProcExecWriteReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
164164
void attsProcValueCnf(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
165165
void attsProcReadMultiVarReq(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket);
166166

167-
uint8_t attsCsfActClientState(uint16_t handle, uint8_t opcode, uint8_t *pPacket);
167+
uint8_t attsCsfActClientState(dmConnId_t connId, uint8_t opcode, uint8_t *pPacket);
168168
uint8_t attsCsfIsClientChangeAware(dmConnId_t connId, uint16_t handle);
169169
void attsCsfSetHashUpdateStatus(bool_t isUpdating);
170170
uint8_t attsCsfGetHashUpdateStatus(void);

0 commit comments

Comments
 (0)