apache / apache/mynewt-nimble

`ble_gatts_clt_cfg_access(...)` odd return values casted from `BLE_HS_E...` to `BLE_ATT_ERR_...` on storage overflow

Open
#1,729 1 comment 0 reactions 1 assignee Claimed by @sjanc View on GitHub
Dominant language
C
Stars
893
Forks
512
Avg merge
13d 31m
Merged PRs (30d)
7

Description

When the number of CCCD's exceeds `BLE_STORE_MAX_CCCDS`, `ble_store_delete_cccd(...)` and `ble_store_write_cccd(...)` will return error codes from the `BLE_HS_E...` range, such as `BLE_HS_ENOENT`, `BLE_HS_ENOMEM`, and `BLE_HS_ENOTSUP` (dependent on the code in `store_status_cb`).

When an attempt is made to write to the descriptor, these error codes are then directly returned from `ble_gatts_clt_cfg_access(...)`. This causes them to be returned by the stack as the corresponding unrelated attribute errors. This causes strange unexpected attribute access errors such as `BLE_ATT_ERR_INSUFFICIENT_AUTHEN`, `BLE_ATT_ERR_REQ_NOT_SUPPORTED`, and `BLE_ATT_ERR_INSUFFICIENT_AUTHOR` when an overflow occurs.

These unexpected errors can cause some strange follow-up behavior: For example, returning `BLE_ATT_ERR_INSUFFICIENT_AUTHEN` when connected to an iOS device causes that iOS device to re-attempt pairing, regardless of whether the current connection is already bonded and encrypted.

`ble_gatts_clt_cfg_access(...)` should probably check for a non-zero return code and return e.g. `BLE_ATT_ERR_INSUFFICIENT_RES` in that case.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.