This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

different calls to add characteristics to a service

Module model: nrf52832

SDK: 15.2

Hi,

I am trying to add custom characteristics to a custom service.

There are two ways that I am aware of:

a. sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles) //from \sdk\components\softdevice\s132\headers\ble_gatts.h

b. uint32_t characteristic_add(uint16_t service_handle, ble_add_char_params_t * p_char_props, ble_gatts_char_handles_t * p_char_handle) //from sdk\components\ble\common\ble_srv_common.h

My questions are:

1. What are the differences between the two calls?

2. I noticed that (a) the read_perm from ble_gatts_attr_t.p_attr_md has this definition:

/**@brief GAP connection security modes.
 *
 * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
 * Security Mode 1 Level 1: No security is needed (aka open link).\n
 * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
 * Security Mode 1 Level 3: MITM protected encrypted link required.\n
 * Security Mode 1 Level 4: LESC MITM protected encrypted link using a 128-bit strength encryption key required.\n
 * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
 * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
 */
typedef struct
{
  uint8_t sm : 4;                     /**< Security Mode (1 or 2), 0 for no permissions at all. */
  uint8_t lv : 4;                     /**< Level (1, 2, 3 or 4), 0 for no permissions at all. */

} ble_gap_conn_sec_mode_t;

(b) the read_access from ble_add_char_params_t can be set by an enum value from security_req_t:

/**@brief Security Access enumeration.
 * @details This enumeration gives the possible requirements for accessing a characteristic value.
 */
typedef enum
{
    SEC_NO_ACCESS    = 0,            /**< Not possible to access. */
    SEC_OPEN         = 1,            /**< Access open. */
    SEC_JUST_WORKS   = 2,            /**< Access possible with 'Just Works' security at least. */
    SEC_MITM         = 3,            /**< Access possible with 'MITM' security at least. */
    SEC_SIGNED       = 4,            /**< Access possible with 'signed' security at least. */
    SEC_SIGNED_MITM  = 5             /**< Access possible with 'signed and MITM' security at least. */
}security_req_t;

What is the difference between the read_perm and the read_access? 

3. Any more ways to add characteristics in a sensible way?

Many thanks

Parents
  • Hi

    1. The sd_ble_gatts_characteristic_add() is the SoftDevices call to add a characteristic, usable just by flashing the SoftDevice and a simple app compiled against its headers. This call is rather generically written to cover every single use case and configuration option you might have.

    The characteristic_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 with some abstraction to make it easier to use. This does however increase the size and code space of the data holders for input parameters that are re-used in the library.

    You can use whatever function you like, as they essentially do the same thing.

    2. The read_access is a security requirement for reading a characteristic value, while read_perm is the permissions set for a set security mode.

    Best regards,

    Simon

Reply
  • Hi

    1. The sd_ble_gatts_characteristic_add() is the SoftDevices call to add a characteristic, usable just by flashing the SoftDevice and a simple app compiled against its headers. This call is rather generically written to cover every single use case and configuration option you might have.

    The characteristic_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 with some abstraction to make it easier to use. This does however increase the size and code space of the data holders for input parameters that are re-used in the library.

    You can use whatever function you like, as they essentially do the same thing.

    2. The read_access is a security requirement for reading a characteristic value, while read_perm is the permissions set for a set security mode.

    Best regards,

    Simon

Children
No Data
Related