ble icon indicating copy to clipboard operation
ble copied to clipboard

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

Open pan- opened this issue 9 years ago • 3 comments

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).

pan- avatar Nov 25 '15 17:11 pan-

thanks for raising this.

rgrover avatar Nov 25 '15 18:11 rgrover

ARM Internal Ref: IOTSFW-1331

ciarmcom avatar Nov 25 '15 23:11 ciarmcom

I'm not particular fond of the current onDataRead, onDataWritten and onDataSent callbacks because all subscribers get notified whether or not the event is relevant for them.

For example, if I have multiple services running at the same time I'm only interested in the data read/write callback for that particular characteristic.

On the watch, I only use readAuthorization and writeAuthorization instead of onDataRead and onDataWritten.

marcuschangarm avatar Dec 09 '15 15:12 marcuschangarm