Microchip® Advanced Software Framework

hr_sensor.h File Reference

Heart Rate Sensor Profile declarations.

Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.

Macros

#define ADV_DATA_LEN   (18)
 ADV_DATA_LEN. More...
 
#define ADV_TYPE_LEN   (0x01)
 ADV_TYPE_LEN. More...
 
#define DEVICE_INFORMATION_SERVICE_UUID   (0x180A)
 DEVICE_INFORMATION_SERVICE_UUID. More...
 
#define FLAG_ENERGY_EXP   (0x1 << 3)
 
#define HR_APP_CONNECTION_STATE   (1)
 APP_CONNECTION_STATE indicates application is in connected state. More...
 
#define HR_APP_DISCONNECT_STATE   (0)
 APP_DISCONNECT_STATE indicates application is in disconnected state. More...
 
#define HR_CONTROL_POINT_RESET_VAL   (1)
 
#define HR_SENSOR_ADV_DATA_COMP_16_UUID_TYPE   (0x03)
 HR_SENSOR_ADV_DATA_UUID_TYPE is complete 16 bit uuid type. More...
 
#define HR_SENSOR_ADV_DATA_NAME_DATA   ("ATMEL-HRP")
 
#define HR_SENSOR_ADV_DATA_NAME_LEN   (9)
 HR_SENSOR_ADV_DATA_NAME_LEN the length of the device name. More...
 
#define HR_SENSOR_ADV_DATA_NAME_TYPE   (0x09)
 HR_SENSOR_ADV_DATA_NAME_TYPE the gap ad data type. More...
 
#define HR_SENSOR_ADV_DATA_UUID_LEN   (4)
 HR_SENSOR_ADV_DATA_UUID_LEN the total length for hr uuid and dis uuid. More...
 
#define HR_SENSOR_ADV_TIMEOUT   (655)
 APP_HR_SENSOR_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x028F in seconds, 0x0000 disables time-out. More...
 
#define HR_SENSOR_FAST_ADV   (1600)
 APP_HR_SENSOR_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s). More...
 
#define SCAN_RESP_LEN   (10)
 scan_resp_len is the length of the scan response data More...
 
#define UUID_16_BIT_LEN   (0x02)
 

Typedefs

typedef void(* hr_notification_callback_t )(uint8_t)
 
typedef void(* hr_reset_callback_t )(void)
 

Functions

at_ble_status_t hr_notification_confirmation_handler (void *params)
 register_hr_notification_handler registers the notification handler passed by the application More...
 
void hr_sensor_adv (void)
 hr_sensor_adv adds the advertisement data of the profile and starts advertisement More...
 
at_ble_status_t hr_sensor_char_changed_handler (void *char_params)
 hr_sensor_char_changed_handler called by the ble manager after a change in the characteristic More...
 
at_ble_status_t hr_sensor_char_write_request (void *params)
 hr_sensor_char_write_request handles the write request for heart rate control point characteristic. More...
 
at_ble_status_t hr_sensor_connected_state_handler (void *params)
 hr_sensor_connected_state_handler called by ble manager after a change in characteristic More...
 
void hr_sensor_disconnect (void)
 hr_sensor_disconnect disconnects with the peer device called by the application More...
 
at_ble_status_t hr_sensor_disconnect_event_handler (void *disconnect)
 hr_sensor_disconnect_event_handler called by ble manager after disconnection event recieved More...
 
void hr_sensor_init (void *param)
 hr_sensor_init initializes and defines the services of the hr profile More...
 
at_ble_status_t hr_sensor_notification_cfm_handler (void *params)
 hr_sensor_notification_cfm_handler called on notification confirmation event by the ble manager More...
 
bool hr_sensor_send_notification (uint8_t *hr_data, uint8_t length)
 hr_sensor_send_notification adds the new characteristic value and sends the notification More...
 
void hr_sensor_service_define (void)
 hr_sensor_service_define defines the services of the profile More...
 
void hr_sensor_service_init (void)
 hr_sensor_service_init initializes the services of the profile More...
 
void register_hr_notification_handler (hr_notification_callback_t hr_notificaton_handler)
 register_hr_notification_handler registers the notification handler passed by the application param[in] hr_notification_callback_t address of the notification handler function to be called More...
 
void register_hr_reset_handler (hr_reset_callback_t hr_reset_handler)
 register_hr_reset_handler registers the reset handler passed by the application More...
 

#define ADV_DATA_LEN   (18)

ADV_DATA_LEN.

#define ADV_TYPE_LEN   (0x01)

ADV_TYPE_LEN.

#define DEVICE_INFORMATION_SERVICE_UUID   (0x180A)

DEVICE_INFORMATION_SERVICE_UUID.

#define FLAG_ENERGY_EXP   (0x1 << 3)
#define HR_APP_CONNECTION_STATE   (1)

APP_CONNECTION_STATE indicates application is in connected state.

#define HR_APP_DISCONNECT_STATE   (0)

APP_DISCONNECT_STATE indicates application is in disconnected state.

#define HR_CONTROL_POINT_RESET_VAL   (1)
#define HR_SENSOR_ADV_DATA_COMP_16_UUID_TYPE   (0x03)

HR_SENSOR_ADV_DATA_UUID_TYPE is complete 16 bit uuid type.

#define HR_SENSOR_ADV_DATA_NAME_DATA   ("ATMEL-HRP")
#define HR_SENSOR_ADV_DATA_NAME_LEN   (9)

HR_SENSOR_ADV_DATA_NAME_LEN the length of the device name.

#define HR_SENSOR_ADV_DATA_NAME_TYPE   (0x09)

HR_SENSOR_ADV_DATA_NAME_TYPE the gap ad data type.

#define HR_SENSOR_ADV_DATA_UUID_LEN   (4)

HR_SENSOR_ADV_DATA_UUID_LEN the total length for hr uuid and dis uuid.

#define HR_SENSOR_ADV_TIMEOUT   (655)

APP_HR_SENSOR_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x028F in seconds, 0x0000 disables time-out.

#define HR_SENSOR_FAST_ADV   (1600)

APP_HR_SENSOR_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s).

Referenced by hr_sensor_adv().

#define SCAN_RESP_LEN   (10)

scan_resp_len is the length of the scan response data

#define UUID_16_BIT_LEN   (0x02)

typedef void(* hr_notification_callback_t)(uint8_t)
typedef void(* hr_reset_callback_t)(void)

at_ble_status_t hr_notification_confirmation_handler ( void *  params)

register_hr_notification_handler registers the notification handler passed by the application

Parameters
[in]hr_notification_callback_taddress of the notification handler function to be called
void hr_sensor_adv ( void  )

hr_sensor_adv adds the advertisement data of the profile and starts advertisement

References AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_SUCCESS, DBG_LOG, HR_SENSOR_FAST_ADV, and NULL.

Referenced by hr_sensor_app_custom_event().

at_ble_status_t hr_sensor_char_changed_handler ( void *  params)

hr_sensor_char_changed_handler called by the ble manager after a change in the characteristic

Parameters
[in]at_ble_characteristic_changed_twhich contains handle of characteristic and new value
Returns
AT_BLE_SUCCESS on success and AT_BLE_FAILURE on failure

References AT_BLE_SUCCESS, HR_CONTROL_POINT_RESET, HR_NOTIFICATION_DISABLE, HR_NOTIFICATION_ENABLE, hr_write_value_handler(), notification_cb, and reset_cb.

at_ble_status_t hr_sensor_char_write_request ( void *  params)
at_ble_status_t hr_sensor_connected_state_handler ( void *  params)

hr_sensor_connected_state_handler called by ble manager after a change in characteristic

Parameters
[in]at_ble_connected_twhich has connection handle and the peer device address

References AT_BLE_SUCCESS, connection_handle, and at_ble_connected_t::handle.

void hr_sensor_disconnect ( void  )

hr_sensor_disconnect disconnects with the peer device called by the application

References at_ble_disconnect(), AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, connection_handle, and DBG_LOG.

Referenced by hr_sensor_app_custom_event().

at_ble_status_t hr_sensor_disconnect_event_handler ( void *  disconnect)

hr_sensor_disconnect_event_handler called by ble manager after disconnection event recieved

Parameters
[in]at_ble_disconnected_twhich has connection handle and reason for disconnection

References ALL_UNUSED, and AT_BLE_SUCCESS.

at_ble_status_t hr_sensor_notification_cfm_handler ( void *  params)

hr_sensor_notification_cfm_handler called on notification confirmation event by the ble manager

Parameters
[in]at_ble_status_tAT_BLE_SUCCESS on success AT_BLE_FAILURE on failure called

hr_sensor_notification_cfm_handler called on notification confirmation event by the ble manager

Parameters
[in]at_ble_status_tAT_BLE_SUCCESS on success AT_BLE_FAILURE on failure called

References AT_BLE_SUCCESS, DBG_LOG_DEV, and at_ble_cmd_complete_event_t::status.

bool hr_sensor_send_notification ( uint8_t *  hr_data,
uint8_t  length 
)

hr_sensor_send_notification adds the new characteristic value and sends the notification

Parameters
[in]hr_datathe new hr characteristic value needs to be updated
[in]lengthlength of new characteristic value
Returns
returns 1 on success and 0 on failure
Parameters
[in]hr_datathe new hr characteristic value needs to be updated
[in]lengthlength of new characteristic value

Updating the new characteristic value

Sending the notification for the updated characteristic

References at_ble_characteristic_value_set(), at_ble_notification_send(), AT_BLE_SUCCESS, at_ble_characteristic_t::char_val_handle, connection_handle, DBG_LOG, and hr_gatt_service_handler::serv_chars.

Referenced by hr_measurment_send().

void hr_sensor_service_define ( void  )

hr_sensor_service_define defines the services of the profile

References AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, dis_primary_service_define(), and hr_primary_service_define().

Referenced by hr_sensor_init().

void hr_sensor_service_init ( void  )

hr_sensor_service_init initializes the services of the profile

hr_sensor_service_init initializes the services of the profile

References dis_init_service(), and hr_init_service().

Referenced by hr_sensor_init().

void register_hr_notification_handler ( hr_notification_callback_t  hr_notificaton_handler)

register_hr_notification_handler registers the notification handler passed by the application param[in] hr_notification_callback_t address of the notification handler function to be called

References notification_cb.

Referenced by main().

void register_hr_reset_handler ( hr_reset_callback_t  hr_reset_handler)

register_hr_reset_handler registers the reset handler passed by the application

Parameters
[in]hr_reset_callback_taddress of the handler function to be called

References reset_cb.

Referenced by main().