ARMmbed / ARMmbed/ble

GattCharacteristic size can be optimized by removing read and write authorization callback

Open
#115 3 comments 0 reactions 0 assignees View on GitHub
enhancement mirrored
Dominant language
C++
Stars
81
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Each `GattCharacteristic` store two FunctionPointersWithContext, one for the readAuthorization callback and one for the writeAuthorization callback. This waste some space given that:
- In practice these authorizations are not always used (especially the readAuthorization)
- The implementation of GattServer has to keep track of all GattCharacteristics registered

One way to get rid of these callbacks in Characteristic is to move these callbacks to the GattServer exactly like its already done for onDataRead, onDataWritten or onDataSent.

With this change, only the callbacks requiring authorization are stored in memory and the developer can optimize the amount of authorization callbacks use by grouping some authorization together instead of instantiating one callback by characteristic (for instance, it can be done service wide).

Contributor guide

Open the contributing guide

Research direction

Locate the GattCharacteristic and GattServer declarations and implementations, then compare their authorization callbacks with onDataRead, onDataWritten, and onDataSent. Trace how characteristics are registered and how readAuthorization and writeAuthorization are invoked. Done means authorization callbacks are retained only where needed by GattServer while existing authorization behavior and API expectations remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.