My central device is using the GATT_ReadUsingCharUUID() API in order to discover characteristic handles on the peripheral device. This all works great when successful, but the stack behavior is inconsistent when the peripheral device fails the read request.
The normal sequence of events is:
- Application issues GATT_ReadUsingCharUUID() request.
- Application receives GATT_MSG_EVENT, method==ATT_READ_BY_TYPE_RSP, gattStatus==SUCCESS, with the characteristic handle
- Application receives GATT_MSG_EVENT, method==ATT_READ_BY_TYPE_RSP, gattStatus==bleProcedureComplete
When the peripheral fails the read request with status ATT_ERR_UNSUPPORTED_REQ
- Application issues GATT_ReadUsingCharUUID() request.
- Application receives GATT_MSG_EVENT, method==ATT_ERROR_RSP, response error code is 0x2 (ATT_ERR_READ_NOT_PERMITTED)
- Application receives GATT_MSG_EVENT, method==ATT_READ_BY_TYPE_RSP, gattStatus==bleProcedureComplete
When the peripheral fails the read request with status ATT_ERR_INSUFFICIENT_RESOURCES
- Application issues GATT_ReadUsingCharUUID() request.
- Application receives GATT_MSG_EVENT, method==ATT_ERROR_RSP, response error code is 0x11 (ATT_ERR_INSUFFICIENT_RESOURCES)
<the end>
** There are no further GATT_MSG_EVENTS, leaving the application waiting forever for ATT_READ_BY_TYPE_RSP with bleProcedureComplete status
The bug is that GATT_ReadUsingCharUUID() at times fails to send the GATT_MSG_EVENT with status=bleProcedureComplete. The result is that the application is screwed because it can't know for sure when the transaction has been completed and the stack ready for another request.