esp-nimble-cpp icon indicating copy to clipboard operation
esp-nimble-cpp copied to clipboard

Secondary Services

Open justintconroy opened this issue 4 years ago • 8 comments

Is there any way to add a secondary service? It looks like I can only add primary services. I may need to reuse a secondary service as part of another primary service on the same device.

justintconroy avatar Sep 07 '21 22:09 justintconroy

Hi, there is currently no support for that but it should be easy to add. I've never had a request for it or even seen this used anywhere before.

h2zero avatar Sep 07 '21 23:09 h2zero

A few of the standard BLE services say they can be or should be implemented as secondary services.

are a few of the one's I've encountered. Right now, I'm specifically looking at Object Transfer Service. I've implemented a scaled down version of that (Connection Oriented Channels aren't supported on the ESP32 as far as I can tell, so I had to improvise a bit). I have another, distinct set of objects that I might want to throw this on top of. In that case, I want both services to be secondary services included in separate primary services.

justintconroy avatar Sep 08 '21 00:09 justintconroy

Thanks for the info, I guess bluetooth had to have a reason for secondary services somewhere and I haven't seen those before. As a user, how would you like to see the interface for this work?

Connection Oriented Channels aren't supported on the ESP32 as far as I can tell

I believe they are, there are options in menuconfig for them (for NimBLE I thought I saw them at least).

h2zero avatar Sep 08 '21 01:09 h2zero

There's a config for "max number of CoCs", but I couldn't find the APIs to actually access them. Nor could I find any examples. Maybe I just didn't look hard enough...

justintconroy avatar Sep 08 '21 01:09 justintconroy

Sorry, I didn't actually answer your question. I think maybe just something like NimBLEService::addService(...) or NimBLEService::createService(...) similar to how characteristics are added to a service.

justintconroy avatar Sep 08 '21 22:09 justintconroy

Thanks, I'll have a look at adding this. NimBLE internals might dictate a different interface but I'll see what I can do.

h2zero avatar Sep 08 '21 23:09 h2zero

I've created PR #59, If you could test it and provide feedback it would be greatly appreciated 😄

h2zero avatar Sep 12 '21 03:09 h2zero

@justintconroy Any feedback on this yet?

mickeyl avatar Apr 28 '23 15:04 mickeyl