Common service definitions

nRF5 SDK v13.1.0

Constants, type definitions, and functions that are common to all services. More...

Data Structures

struct ble_srv_report_ref_t
Value of a Report Reference descriptor. More...
struct ble_srv_utf8_str_t
UTF-8 string data type. More...
struct ble_srv_security_mode_t
Security settings structure. More...
struct ble_srv_cccd_security_mode_t
Security settings structure. More...
struct ble_add_char_user_desc_t
Characteristic User Descriptor parameters. More...
struct ble_add_char_params_t
Add characteristic parameters structure. More...
struct ble_add_descr_params_t
Add descriptor parameters structure. More...

Typedefs

typedef void(* ble_srv_error_handler_t )(uint32_t nrf_error)
Type definition for error handler function that will be called in case of an error in a service or a service library module.

Enumerations

enum security_req_t {
SEC_NO_ACCESS = 0,
SEC_OPEN = 1,
SEC_JUST_WORKS = 2,
SEC_MITM = 3,
SEC_SIGNED = 4,
SEC_SIGNED_MITM = 5
}
Security Access enumeration. More...

Functions

bool ble_srv_is_notification_enabled (uint8_t const *p_encoded_data)
Function for decoding a CCCD value, and then testing if notification is enabled. More...
bool ble_srv_is_indication_enabled (uint8_t const *p_encoded_data)
Function for decoding a CCCD value, and then testing if indication is enabled. More...
uint8_t ble_srv_report_ref_encode (uint8_t *p_encoded_buffer, const ble_srv_report_ref_t *p_report_ref)
Function for encoding a Report Reference Descriptor. More...
void ble_srv_ascii_to_utf8 ( ble_srv_utf8_str_t *p_utf8, char *p_ascii)
Function for making a UTF-8 structure refer to an ASCII string. More...
uint32_t characteristic_add (uint16_t service_handle, ble_add_char_params_t *p_char_props, ble_gatts_char_handles_t *p_char_handle)
Function for adding a characteristic to a given service. More...
uint32_t descriptor_add (uint16_t char_handle, ble_add_descr_params_t *p_descr_props, uint16_t *p_descr_handle)
Function for adding a characteristic's descriptor to a given characteristic. More...

Detailed Description

Constants, type definitions, and functions that are common to all services.

Macro Definition Documentation

#define BLE_CCCD_VALUE_LEN   2

The length of a CCCD value.

#define BLE_SRV_ENCODED_REPORT_REF_LEN   2

The length of an encoded Report Reference Descriptor.

Enumeration Type Documentation

Security Access enumeration.

This enumeration gives the possible requirements for accessing a characteristic value.

Enumerator
SEC_NO_ACCESS

Not possible to access.

SEC_OPEN

Access open.

SEC_JUST_WORKS

Access possible with 'Just Works' security at least.

SEC_MITM

Access possible with 'MITM' security at least.

SEC_SIGNED

Access possible with 'signed' security at least.

SEC_SIGNED_MITM

Access possible with 'signed and MITM' security at least.

Function Documentation

void ble_srv_ascii_to_utf8 ( ble_srv_utf8_str_t * p_utf8 ,
char * p_ascii
)

Function for making a UTF-8 structure refer to an ASCII string.

Parameters
[out] p_utf8 UTF-8 structure to be set.
[in] p_ascii ASCII string to be referred to.
bool ble_srv_is_indication_enabled ( uint8_t const * p_encoded_data )

Function for decoding a CCCD value, and then testing if indication is enabled.

Parameters
[in] p_encoded_data Buffer where the encoded CCCD is stored.
Return values
TRUE If indication is enabled.
FALSE Otherwise.
bool ble_srv_is_notification_enabled ( uint8_t const * p_encoded_data )

Function for decoding a CCCD value, and then testing if notification is enabled.

Parameters
[in] p_encoded_data Buffer where the encoded CCCD is stored.
Return values
TRUE If notification is enabled.
FALSE Otherwise.
uint8_t ble_srv_report_ref_encode ( uint8_t * p_encoded_buffer ,
const ble_srv_report_ref_t * p_report_ref
)

Function for encoding a Report Reference Descriptor.

Parameters
[in] p_encoded_buffer The buffer of the encoded data.
[in] p_report_ref Report Reference value to be encoded.
Returns
Length of the encoded data.
uint32_t characteristic_add ( uint16_t service_handle ,
ble_add_char_params_t * p_char_props ,
ble_gatts_char_handles_t * p_char_handle
)

Function for adding a characteristic to a given service.

If no pointer is given for the initial value, the initial length parameter will be ignored and the initial length will be 0.

Parameters
[in] service_handle Handle of the service to which the characteristic is to be added.
[in] p_char_props Information needed to add the characteristic.
[out] p_char_handle Handle of the added characteristic.
Return values
NRF_SUCCESS If the characteristic was added successfully. Otherwise, an error code is returned.
uint32_t descriptor_add ( uint16_t char_handle ,
ble_add_descr_params_t * p_descr_props ,
uint16_t * p_descr_handle
)

Function for adding a characteristic's descriptor to a given characteristic.

Parameters
[in] char_handle Handle of the characteristic to which the descriptor is to be added, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
[in] p_descr_props Information needed to add the descriptor.
[out] p_descr_handle Handle of the added descriptor.
Return values
NRF_SUCCESS If the characteristic was added successfully. Otherwise, an error code is returned.