How to add add, insert and remove BLE services dynamically at run time and if I have to send multiple data under one service

if I have to send multiple data under one service 

like: Service 1(Information)

Hardware Revision String

Model Number String, the

Regulatory Certification Data List 

Then what should be the proper format (like string, array, individually or something else) of sending data? 

Parents Reply Children
  • Hi again, 
    If you use nRF5 SDK and softdevice, then it's not possible to remove a BLE service. You can add more service after initializing the softdevice but you can not remove. 
    If you want to remove a service/characteristic you would need to disable softdevice and initialize it again. 

    When you add more service/characteristic, you need to request the peer to do a new service discovery to update the new service/characteristic. 

  • Ok got it thanks.  Kindly clear one thing in multiple services if let's say two services have the same characteristics but have a different function then the custom UUID will be the same or different.

    E.g.:-  Service 1 (Distributed System Information)

                 Characteristics:  Node 1 (properties: Read) 

                                             Node 2 (properties: Read)

    Service 2 (Control)

                 Characteristics:  Node 1 (properties: Write) 

                                             Node 2 (properties: write)

    Then Node 1 and Node 2 of both services will have the same uuid or different?

  • Hi Ayu, 

    There is no problem for two identical services or characteristics in the attribute table. 
    The service discovery process will go through and read the handle ID (the index of them in the attribute table) to identify them, not the UUID.  Handle ID will then be used by the client to access the server. 

  • Hi thanks for you response. Can you provide any source from where I can refer that how to add services or characteristics dynamically?

  • Hi Ayu, 
    We currently don't have an example of doing so. But you can add more service by simply define the service and call sd_ble_gatts_service_add() , sd_ble_gatts_characteristic_add. The same as how you normally define a service/characteristic. 

Related