Description
Hi,
First, thanks for a great library (and tools for nRF development)!
Second, a question/thought about the API:
It looks like the only callback mechanism for characteristic events is through c-style functions set by the setEventHandler()
, correct? Or am I missing something?
I was trying to create classes for self-contained services that may have multiple instances. For example, a "light color" service that would support a single tri-color LED. Several instances of the service could be used to support multiple LEDs. A person creating a device just instantiates an object for each LED they have on their device.
The callback mechanism doesn't work very well for completely self-contained instances due to the way events are dispatched (event handlers have to be a static function, so they don't work well when there may be multiple instances of an object). As a workaround I modified the library to allow both BLECharacteristic
s and BLEPeripheral
s to have listeners. Each characteristic can have a single listener and the peripheral can have a chain of BLEDeviceEventListener
s. Does anyone have any suggestions for a better approach? And/or is there any interest in adding this kind of functionality to the BLEPeripheral library?