from bbc microbit library

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Common service definitions

Common service definitions

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

Modules

 Service UUID definitions
 Characteristic UUID definitions
 Definitions for the Alert Level characteristic values

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

static __INLINE bool ble_srv_is_notification_enabled (uint8_t *p_encoded_data)
 Function for decoding a CCCD value, and then testing if notification is enabled.
static __INLINE bool ble_srv_is_indication_enabled (uint8_t *p_encoded_data)
 Function for decoding a CCCD value, and then testing if indication is enabled.
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.
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.
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.
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.

Detailed Description

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


Typedef Documentation

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.

Definition at line 169 of file ble_srv_common.h.


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.

Definition at line 265 of file ble_srv_common.h.


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_utf8UTF-8 structure to be set.
[in]p_asciiASCII string to be referred to.

Definition at line 57 of file ble_srv_common.c.

static __INLINE bool ble_srv_is_indication_enabled ( uint8_t *  p_encoded_data ) [static]

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

Parameters:
[in]p_encoded_dataBuffer where the encoded CCCD is stored.
Return values:
TRUEIf indication is enabled.
FALSEOtherwise.

Definition at line 238 of file ble_srv_common.h.

static __INLINE bool ble_srv_is_notification_enabled ( uint8_t *  p_encoded_data ) [static]

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

Parameters:
[in]p_encoded_dataBuffer where the encoded CCCD is stored.
Return values:
TRUEIf notification is enabled.
FALSEOtherwise.

Definition at line 224 of file ble_srv_common.h.

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_bufferThe buffer of the encoded data.
[in]p_report_refReport Reference value to be encoded.
Returns:
Length of the encoded data.

Definition at line 44 of file ble_srv_common.c.

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_handleHandle of the service to which the characteristic is to be added.
[in]p_char_propsInformation needed to add the characteristic.
[out]p_char_handleHandle of the added characteristic.
Return values:
NRF_SUCCESSIf the characteristic was added successfully. Otherwise, an error code is returned.

Definition at line 101 of file ble_srv_common.c.

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_handleHandle 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_propsInformation needed to add the descriptor.
[out]p_descr_handleHandle of the added descriptor.
Return values:
NRF_SUCCESSIf the characteristic was added successfully. Otherwise, an error code is returned.

Definition at line 182 of file ble_srv_common.c.