SmartSnippets DA1459x SDK
Files | Data Structures | Typedefs | Enumerations | Functions

Heart Rate Service Client. More...

Files

file  hrs_client.h
 Heart Rate Service Client header file.
 

Data Structures

struct  hrs_client_measurement_t
 Heart rate measurement information. More...
 
struct  hrs_client_callbacks_t
 HRS application callbacks. More...
 

Typedefs

typedef void(* hrs_client_heart_rate_measurement_notif_cb_t) (ble_client_t *hrs_client, hrs_client_measurement_t *measurement)
 Heart Rate Measurement notification callback. More...
 
typedef void(* hrs_client_get_event_state_completed_cb_t) (ble_client_t *hrs_client, hrs_client_event_t event, att_error_t status, bool enabled)
 Get event state completed callback. More...
 
typedef void(* hrs_client_set_event_state_completed_cb_t) (ble_client_t *hrs_client, hrs_client_event_t event, att_error_t status)
 Set event state completed callback. More...
 
typedef void(* hrs_client_read_body_sensor_location_cb_t) (ble_client_t *hrs_client, att_error_t status, hrs_client_body_sensor_location_t location)
 Read value of Body Sensor Location callback. More...
 
typedef void(* hrs_client_reset_energy_expended_completed_cb_t) (ble_client_t *hrs_client, att_error_t status)
 Reset the value of the Energy Expended callback. More...
 

Enumerations

enum  hrs_client_body_sensor_location_t {
  HRS_CLIENT_BODY_SENSOR_LOC_OTHER = 0, HRS_CLIENT_BODY_SENSOR_LOC_CHEST = 1, HRS_CLIENT_BODY_SENSOR_LOC_WRIST = 2, HRS_CLIENT_BODY_SENSOR_LOC_FINGER = 3,
  HRS_CLIENT_BODY_SENSOR_LOC_HAND = 4, HRS_CLIENT_BODY_SENSOR_LOC_EAR_LOBE = 5, HRS_CLIENT_BODY_SENSOR_LOC_FOOT = 6
}
 Body Sensor Location. More...
 
enum  hrs_client_cap_t { HRS_CLIENT_CAP_BODY_SENSOR_LOCATION = 0x01, HRS_CLIENT_CAP_HEART_RATE_CONTROL_POINT = 0x02 }
 Client capabilities bit mask. More...
 
enum  hrs_client_event_t { HRS_CLIENT_EVENT_HEART_RATE_MEASUREMENT_NOTIF = 0x01 }
 

Functions

ble_client_thrs_client_init (const hrs_client_callbacks_t *cb, const ble_evt_gattc_browse_svc_t *evt)
 Register Heart Rate Client instance. More...
 
hrs_client_cap_t hrs_client_get_capabilities (ble_client_t *hrs_client)
 Get client capabilities. More...
 
bool hrs_client_get_event_state (ble_client_t *hrs_client, hrs_client_event_t event)
 Get event characteristic indication/notification state. More...
 
bool hrs_client_set_event_state (ble_client_t *hrs_client, hrs_client_event_t event, bool enable)
 Set event characteristic indication/notification state. More...
 
bool hrs_client_read_body_sensor_location (ble_client_t *hrs_client)
 Read body sensor location. More...
 
bool hrs_client_reset_energy_expended (ble_client_t *hrs_client)
 Reset Energy Expended value to 0. More...
 
ble_client_thrs_client_init_from_data (uint16_t conn_idx, const hrs_client_callbacks_t *cb, const void *data, size_t length)
 Initialize HRS Client instance from buffered (cached) data and register application callbacks. More...
 

Detailed Description

Heart Rate Service Client.

Typedef Documentation

◆ hrs_client_get_event_state_completed_cb_t

typedef void(* hrs_client_get_event_state_completed_cb_t) (ble_client_t *hrs_client, hrs_client_event_t event, att_error_t status, bool enabled)

Get event state completed callback.

Parameters
[in]hrs_clientHRS Client instance
[in]eventindication/notification characteristic
[in]statusoperation status
[in]enabledstate flag

◆ hrs_client_heart_rate_measurement_notif_cb_t

typedef void(* hrs_client_heart_rate_measurement_notif_cb_t) (ble_client_t *hrs_client, hrs_client_measurement_t *measurement)

Heart Rate Measurement notification callback.

Called when the HRS Client receives Heart Rate Measurement notification from server. The rr_values have variable length in the received data. To prevent the memory leak caused by OS_MALLOC (measurement) this callback uses OS_FREE()

Parameters
[in]hrs_clientHRS Client instance
[in]measurementheart rate measurements

◆ hrs_client_read_body_sensor_location_cb_t

typedef void(* hrs_client_read_body_sensor_location_cb_t) (ble_client_t *hrs_client, att_error_t status, hrs_client_body_sensor_location_t location)

Read value of Body Sensor Location callback.

Indicates status of read Body Sensor Location value procedure.

Parameters
[in]hrs_clientHRS Client instance
[in]statusoperation status
[in]locationbody sensor location

◆ hrs_client_reset_energy_expended_completed_cb_t

typedef void(* hrs_client_reset_energy_expended_completed_cb_t) (ble_client_t *hrs_client, att_error_t status)

Reset the value of the Energy Expended callback.

Indicates status of reset Energy Expended value procedure.

Parameters
[in]hrs_clientHRS Client instance
[in]statusoperation status

◆ hrs_client_set_event_state_completed_cb_t

typedef void(* hrs_client_set_event_state_completed_cb_t) (ble_client_t *hrs_client, hrs_client_event_t event, att_error_t status)

Set event state completed callback.

Parameters
[in]hrs_clientHRS Client instance
[in]eventindication/notification characteristic
[in]statusoperation status

Enumeration Type Documentation

◆ hrs_client_body_sensor_location_t

Body Sensor Location.

As defined by HRS specification.

Enumerator
HRS_CLIENT_BODY_SENSOR_LOC_OTHER 

Other

HRS_CLIENT_BODY_SENSOR_LOC_CHEST 

Chest

HRS_CLIENT_BODY_SENSOR_LOC_WRIST 

Wrist

HRS_CLIENT_BODY_SENSOR_LOC_FINGER 

Finger

HRS_CLIENT_BODY_SENSOR_LOC_HAND 

Hand

HRS_CLIENT_BODY_SENSOR_LOC_EAR_LOBE 

Ear Lobe

HRS_CLIENT_BODY_SENSOR_LOC_FOOT 

Foot

◆ hrs_client_cap_t

Client capabilities bit mask.

Enumerator
HRS_CLIENT_CAP_BODY_SENSOR_LOCATION 

Body Sensor Location Characteristic

HRS_CLIENT_CAP_HEART_RATE_CONTROL_POINT 

Heart Rate Control Point Characteristic

◆ hrs_client_event_t

Event Characteristics (those which have indications/notifications as property)

Enumerator
HRS_CLIENT_EVENT_HEART_RATE_MEASUREMENT_NOTIF 

Heart Rate Measurement Characteristic

Function Documentation

◆ hrs_client_get_capabilities()

hrs_client_cap_t hrs_client_get_capabilities ( ble_client_t hrs_client)

Get client capabilities.

Function returns client capabilities enum

Parameters
[in]hrs_clientHRS Client instance
Returns
Bit mask with client capabilities

◆ hrs_client_get_event_state()

bool hrs_client_get_event_state ( ble_client_t hrs_client,
hrs_client_event_t  event 
)

Get event characteristic indication/notification state.

Function reads CCC descriptor of selected event. After successful operation get_event_state callback will be called.

Parameters
[in]hrs_clientHRS Client instance
[in]eventselected notification/indication characteristic
Returns
true if read request has been sent successfully, false if server doesn't support selected event characteristic or if operation is already in progress.

◆ hrs_client_init()

ble_client_t* hrs_client_init ( const hrs_client_callbacks_t cb,
const ble_evt_gattc_browse_svc_t evt 
)

Register Heart Rate Client instance.

Function registers new Heart Rate Client instance.

Parameters
[in]cbHRS Client application callbacks
[in]evtbrowse svc event with HR svc details
Returns
client instance if success, otherwise NULL

◆ hrs_client_init_from_data()

ble_client_t* hrs_client_init_from_data ( uint16_t  conn_idx,
const hrs_client_callbacks_t cb,
const void *  data,
size_t  length 
)

Initialize HRS Client instance from buffered (cached) data and register application callbacks.

Function semantics is very similar to hrs_client_init(). The difference is that internal data is initialized by the buffered context and the HRS Client is automatically added to active clients collection.

Parameters
[in]conn_idxconnection index
[in]cbHRS Client application callbacks
[in]databuffered data
[in]lengthbuffer's length
Returns
HRS Client instance when initialized properly, NULL otherwise

◆ hrs_client_read_body_sensor_location()

bool hrs_client_read_body_sensor_location ( ble_client_t hrs_client)

Read body sensor location.

Function triggers read Body Sensor Location characteristic. Once operation is completed, callback hrs_client_read_body_sensor_location_cb_t will be called.

Parameters
[in]hrs_clientHRS Client instance
Returns
true if request has been sent successfully, otherwise false

◆ hrs_client_reset_energy_expended()

bool hrs_client_reset_energy_expended ( ble_client_t hrs_client)

Reset Energy Expended value to 0.

Function reset Energy Expended field in HR Measurement characteristic to 0 by writing 0x01 value to heart rate control point. Once operation is completed, callback hrs_client_reset_energy_expended_completed_cb_t will be called.

Parameters
[in]hrs_clientHRS Client instance
Returns
true if request has been sent successfully, otherwise false

◆ hrs_client_set_event_state()

bool hrs_client_set_event_state ( ble_client_t hrs_client,
hrs_client_event_t  event,
bool  enable 
)

Set event characteristic indication/notification state.

Function writes CCC descriptor of selected event. After successful operation set_event_state callback will be called.

Parameters
[in]hrs_clientHRS Client instance
[in]eventselected notification/indication characteristic
[in]enablestate flag
Returns
true if write request has been sent successfully, false if server doesn't support selected event characteristic or if operation is already in progress.