Skip to content

Bluetooth: GATT: BT_GATT_PERM_PREPARE_WRITE is misleading #100962

@Thalley

Description

@Thalley

Summary

The enum bt_gatt_perm is generally used to set permissions for GATT attributes, and generally permissions like BT_GATT_PERM_READ and BT_GATT_PERM_WRITE will automatically reject requests in the GATT layer not set for the requested operation by the GATT client.

BT_GATT_PERM_PREPARE_WRITE however stands out among all the other BT_GATT_PERM as it does not reject prepare write (used for long writes) if not set. This effectively means that any write callback of any writable characteristic need to explicitly either implement or reject long writes / prepare writes. The only thing this "permission" field is doing, is determining whether to call the write callback with BT_GATT_WRITE_FLAG_PREPARE as the flag.

Describe the solution you'd like

BT_GATT_WRITE_FLAG_PREPARE is misleading and it should be changed. One or more of the follow points should be done.

  1. We can simply change the behavior of this permission field to do what the name indicates, but that will change the behavior of the GATT layer, and may be considered a breaking change due to the (possible) significant change in behavior.
  2. Make it even clearer what this value does, as well as documenting that long writes always needs to be rejected or implemented manually regardless of BT_GATT_WRITE_FLAG_PREPARE
  3. Deprecate BT_GATT_WRITE_FLAG_PREPARE and add a new permission field to actively disallow long writes unless the permission is set
  4. Add a new permission field that needs to be set to allow long writes, without deprecating this (can also be considered a breaking change)
  5. Add a new permission field that disallow long writes (keep existing behavior, but add a field to reject it at the GATT layer instead of at the application layer)

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions