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