HRS Exported Functions
- group HRS_Exported_Functions
Functions
-
uint8_t hrs_add_service(void *p_func)
Add heart rate service to the Bluetooth Host.
Example usage
void profile_init() { server_init(service_num); hrs_id = hrs_add_service(app_handle_profile_message); }
- Parameters:
p_func – [in] Callback when service attribute was read, written, or CCCD updated.
- Return values:
0xFF – Operation failure.
others – Service ID assigned by Bluetooth Host.
- Returns:
Service ID generated by the Bluetooth Host: T_SERVER_ID.
-
bool hrs_set_parameter(T_HRS_PARAM_TYPE param_type, uint8_t len, void *p_value)
Set a heart rate service parameter.
This function can be called upon receiving the body sensor location read callback. If the application accepts the read request, the cause of the HRS read callback should be set to APP_RESULT_PENDING. Then call this API to send the read confirmation with the cause APP_RESULT_SUCCESS.
Example usage
void test(void) { T_HEART_RATE_MEASUREMENT_VALUE_FLAG flag; flag.heart_rate_value_format_bit = 1; flag.sensor_contact_status_bits = 3; if (p_parse_value->param_count >= 1) { flag.sensor_contact_status_bits = p_parse_value->dw_param[1]; } flag.energy_expended_status_bit = 1; flag.rr_interval_bit = 1; flag.rfu = 0; hrs_set_parameter(HRS_HEART_RATE_MEASUREMENT_PARAM_FLAG, 1, &flag); }
- Parameters:
param_type – [in] Health rate service parameter type: T_HRS_PARAM_TYPE.
len – [in] Length of data to write.
p_value – [in] Pointer to data to write. This is dependent on the parameter type and will be cast to the appropriate data type (For example: if data type of param is uint16_t, p_value will be cast to pointer of uint16_t).
- Return values:
true – Operation success.
false – Operation failure.
- Returns:
Operation result.
-
bool hrs_heart_rate_measurement_value_notify(uint8_t conn_id, T_SERVER_ID service_id)
Send heart rate measurement value notification data. Applications shall call hrs_set_parameter to set heart rate measurement value first, and the call this api to send the notification value.
Example usage
void test(void) { bool result = hrs_heart_rate_measurement_value_notify(conn_id, service_id); }
- Parameters:
conn_id – [in] Connection ID.
service_id – [in] Service ID.
- Return values:
true – Operation success.
false – Operation failure.
- Returns:
Operation result.
-
uint8_t hrs_add_service(void *p_func)