Heart Rate Sensor Profile.
Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <string.h>
#include "timer_hw.h"
#include "at_ble_api.h"
#include "ble_manager.h"
#include "device_info.h"
#include "heart_rate.h"
#include "hr_sensor.h"
#include "ble_utils.h"
Functions | |
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 *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_notification_confirmation_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) |
Initialization of profile services. 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... | |
Variables | |
at_ble_handle_t | connection_handle |
contains the connection handle functions More... | |
dis_gatt_service_handler_t | dis_service_handler |
device information service handler More... | |
static const ble_gap_event_cb_t | hr_sensor_gap_handle |
static const ble_gatt_server_event_cb_t | hr_sensor_gatt_server_handle |
hr_gatt_service_handler_t | hr_service_handler |
heart rate measurement service handler More... | |
hr_notification_callback_t | notification_cb |
callback functions pointers contains the address of application functions More... | |
bool | notification_confirm = true |
hr_reset_callback_t | reset_cb |
uint8_t | scan_rsp_data [SCAN_RESP_LEN] = {0x09, 0xff, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8} |
Scan response data. More... | |
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
[in] | at_ble_characteristic_changed_t | which contains handle of characteristic and new value |
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 | ) |
hr_sensor_char_write_request handles the write request for heart rate control point characteristic.
[in] | at_ble_characteristic_write_request_t | parameters containing the value written |
References AT_BLE_ATT_APP_ERROR, AT_BLE_SUCCESS, at_ble_write_authorize_reply(), at_ble_characteristic_write_request_t::char_handle, at_ble_characteristic_t::char_val_handle, DBG_LOG, DBG_LOG_DEV, HR_CONTROL_POINT_RESET_VAL, reset_cb, hr_gatt_service_handler::serv_chars, and at_ble_characteristic_write_request_t::value.
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
[in] | at_ble_connected_t | which 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
[in] | at_ble_disconnected_t | which has connection handle and reason for disconnection |
References ALL_UNUSED, and AT_BLE_SUCCESS.
void hr_sensor_init | ( | void * | param | ) |
hr_sensor_init initializes and defines the services of the hr profile
[in] | params | are unused. |
References ALL_UNUSED, AT_BLE_SUCCESS, ble_advertisement_data_set(), BLE_GAP_EVENT_TYPE, BLE_GATT_SERVER_EVENT_TYPE, ble_mgr_events_callback_handler(), at_ble_characteristic_t::char_val_handle, at_ble_characteristic_t::client_config_handle, DBG_LOG, DBG_LOG_PTS, hr_sensor_service_define(), hr_sensor_service_init(), REGISTER_CALL_BACK, hr_gatt_service_handler::serv_chars, dis_gatt_service_handler::serv_chars, hr_gatt_service_handler::serv_handle, and dis_gatt_service_handler::serv_handle.
Referenced by main().
at_ble_status_t hr_sensor_notification_cfm_handler | ( | void * | params | ) |
hr_notification_confirmation_handler called on notification confirmation event by the ble manager
hr_sensor_notification_cfm_handler called on notification confirmation event by the ble manager
[in] | at_ble_status_t | AT_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
[in] | hr_data | the new hr characteristic value needs to be updated |
[in] | length | length 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 | ) |
Initialization of profile services.
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 | ) |
at_ble_handle_t connection_handle |
contains the connection handle functions
dis_gatt_service_handler_t dis_service_handler |
device information service handler
|
static |
|
static |
hr_gatt_service_handler_t hr_service_handler |
heart rate measurement service handler
hr_notification_callback_t notification_cb |
callback functions pointers contains the address of application functions
hr_reset_callback_t reset_cb |
Referenced by hr_sensor_char_changed_handler(), hr_sensor_char_write_request(), and register_hr_reset_handler().
uint8_t scan_rsp_data[SCAN_RESP_LEN] = {0x09, 0xff, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8} |
Scan response data.