Multiple services in GATT profile with Zephyr OS

I was able to follow the tutorials from academy.nordicsemi.com on bluetooth fundamentals but unfortunately, I could not find an example where more than one custom service is advertised to the client.

I understand that the maximum advertising packet is 31 bytes, but the UUID is 16 bytes so two or more won't fit in the advertising packet - but this could be exposed later. How?

  • Hi, 

    I recommend looking into this sample for multiple service advertising 

    Regards

    Runar

  • Oh, I understand.

    So that 31 bytes is really the limit.

    I would like to know whether there is a different method of discovering the services post connection to the device - much like how the characteristics get discovered. I realized that I don't need the services to be discovered during advertising - but just have them as a structural hierarchy. What do you think?

  • I think our academy can describe this better then I, so I would have a look here

    bem22 said:
    I would like to know whether there is a different method of discovering the services post connection to the device

    At this point you already have the information, you just need to read it out.

    Regards

    Runar

  • I'm sorry to say but your comment passes as very shallow

    I've run through the course myself and it's unclear whether I could expose multiple services. The course/academy does not cover multiple services or even hint at multiple service discovery so this is why I'm coming here.

    To come back to the problem at hand, I'm trying to understand how can I implement this for my development and how Sony managed it to do in those headphones where there appear to be 11 services after connection:

    Am I really asking for too much here?

  • I figured this out by myself.

    If you want to add multiple services to the GATT Profile you don't necessarily need to advertise them. This was unclear to me and it did not make sense.

    You can add any number of services and characteristics and they will be discovered after connection. The advertisement of the UUID for service has the purpose of filtering the scanned devices. Again, very unclear to me from the wording in the BLE Course - or my English is lacking - who knows?

    The answer for coding multiple services without advertising them can be found in ncs/v2.x/zephyr/samples/bluetooth/peripheral

    Here's a screenshot of the peripheral app to which I added the Nordic LBS service

Related