Hello,
I'm working on the implementation of some custom services and I started to question why the SDK implements the service modules as instance managers (as of SDK 15).
What I mean with instance manager is that the module itself doesn't actually instantiate a service. The instantiation must be done elsewhere using the BLE_XXX_DEF() macros. For example, if you want to add the battery service to your application, you have to enable the module in the SDK config header file, instantiate the service somewhere using the macro, and initialize the service by providing the module with a pointer to the instance.
I understand this functionality with some peripherals like TWI and SPI. Since there can be multiple instances, it makes sense that there's a module that accepts a pointer to the instance to perform operations. But from the BLE service point-of-view it doesn't make much sense to me. Why would someone instantiate multiple battery services in a peripheral? Or multiple device information services? And is it even possible to add multiple services with the same UUID?
I want to understand why the instantiation isn't done directly within the module as soon as you "enable" the module in sdk_config.h. I just don't understand its purpose.