This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What are the differences between "sd_ble_gatts_characteristic_add()" and "characteristic_add()"

I am using SD132 V5 and SDK 14.1 I found the sd_ble_gatts_characteristic_add() is being used in most of the example projects, but I suddenly found the characteristic_add() in throughput example. The configurations of the characteristic_add() is clearer than the other one in my points of view.

What are the differences of them? and if they are the same, why the sdk has both and the sample codes are all using the more complex one?

Parents
  • The sd_* functions are SoftDevice functions. They are usable just by flashing the SoftDevice and a simple app compiled against its headers. The sd_ble_* functions are related to Bluetooth, and further naming follows the same pattern with layer_noun_verb. These functions are quite generically written, to cover every single use-case and configuration option you might have (and they have to).

    The second function you refer to, characterstic_add(), is a function provided by the SDK, which acts as a wrapper function for the SoftDevice function. It still does the same thing on the lowest level, but with some abstraction to make it easier to use in the typical SDK use-cases. This comes at some cost, which is the size and code space of the data holders for input parameters that are re-used in the library. There are also some things you cannot do with the SDK function, e.g. setting vloc, to choose if the characteristic should be placed in stack or user space. There could be other limitations in place too.

    You are free to use whatever function that is the best for you, of course - if you plan to keep using the SDK. Advanced use-cases might lead to moving away from the SDK core, and instead working directly on top of the SoftDevice (and use a library for e.g. bond management and DFU). If that is something you consider, going forward, then it is likely safer to understand and use the SoftDevice functions directly.

Reply
  • The sd_* functions are SoftDevice functions. They are usable just by flashing the SoftDevice and a simple app compiled against its headers. The sd_ble_* functions are related to Bluetooth, and further naming follows the same pattern with layer_noun_verb. These functions are quite generically written, to cover every single use-case and configuration option you might have (and they have to).

    The second function you refer to, characterstic_add(), is a function provided by the SDK, which acts as a wrapper function for the SoftDevice function. It still does the same thing on the lowest level, but with some abstraction to make it easier to use in the typical SDK use-cases. This comes at some cost, which is the size and code space of the data holders for input parameters that are re-used in the library. There are also some things you cannot do with the SDK function, e.g. setting vloc, to choose if the characteristic should be placed in stack or user space. There could be other limitations in place too.

    You are free to use whatever function that is the best for you, of course - if you plan to keep using the SDK. Advanced use-cases might lead to moving away from the SDK core, and instead working directly on top of the SoftDevice (and use a library for e.g. bond management and DFU). If that is something you consider, going forward, then it is likely safer to understand and use the SoftDevice functions directly.

Children
No Data
Related