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? 

  • Hi Ayu,

    Any data sending over BLE is a byte array. 

    So you can either make different characteristic for each of the data you want to send. Or you can use one single characteristic and send all data via this characteristic. 
    You can simply use the first byte in the array to tell which type of data containing in the array. 

  • Ok, but you missed first question, that 

    How to add add, insert and remove BLE services dynamically at run time

  • 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. 

Related