-
Notifications
You must be signed in to change notification settings - Fork 733
/
esp_hrs.h
114 lines (99 loc) · 4.16 KB
/
esp_hrs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/* 16 Bit Heart Rate Service UUID */
#define BLE_HRS_UUID16 0x180D
/* 16 Bit Heart Rate Service Characteristic UUIDs */
#define BLE_HRS_CHR_UUID16_MEASUREMENT 0x2A37
#define BLE_HRS_CHR_UUID16_BODY_SENSOR_LOC 0x2A38
#define BLE_HRS_CHR_UUID16_HEART_RATE_CNTL_POINT 0x2A39
/* The maximum number of RR-Interval Values */
#define BLE_HRS_CHR_MERSUREMENT_RR_INTERVAL_MAX_NUM 7
/**
* @brief Heart Rate Measurement Characteristic
*/
typedef struct {
struct {
uint8_t format: 1; /*!< Heart rate value format flag */
uint8_t detected: 1; /*!< Sensor contact detected flag */
uint8_t supported: 1; /*!< Sensor contact cupported flag */
uint8_t energy: 1; /*!< Energy expended present flag */
uint8_t interval: 1; /*!< RR-Interval present flag */
uint8_t reserved: 3; /*!< Reserved for future use flag */
} flags; /*!< Flags of heart rate measurement */
union {
uint8_t u8; /*!< 8 bit resolution */
uint16_t u16; /*!< 16 bit resolution */
} heartrate; /*!< Heart rate measurement value */
uint16_t energy_val; /*!< Expended energy value */
uint16_t interval_buf[BLE_HRS_CHR_MERSUREMENT_RR_INTERVAL_MAX_NUM]; /*!< The RR-Interval value represents the time between two R-Wave detections */
} __attribute__((packed)) esp_ble_hrs_hrm_t;
/* Body Sensor Location Characteristic */
#define BLE_HRS_CHR_BODY_SENSOR_LOC_OTHER 0
#define BLE_HRS_CHR_BODY_SENSOR_LOC_CHEST 1
#define BLE_HRS_CHR_BODY_SENSOR_LOC_WRIST 2
#define BLE_HRS_CHR_BODY_SENSOR_LOC_FINGER 3
#define BLE_HRS_CHR_BODY_SENSOR_LOC_HAND 4
#define BLE_HRS_CHR_BODY_SENSOR_LOC_EAR_LOBE 5
#define BLE_HRS_CHR_BODY_SENSOR_LOC_FOOT 6
#define BLE_HRS_CHR_BODY_SENSOR_LOC_RFU 7
#define BLE_HRS_CHR_BODY_SENSOR_LOC_MAX 8
/**
* @brief Get the sensor location value of the device.
*
* @param[in] location The pointer to store the sensor location value
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong location
*/
esp_err_t esp_ble_hrs_get_location(uint8_t *location);
/**
* @brief Set the sensor location value of the device.
*
* @param[in] location The sensor location value
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong location
*/
esp_err_t esp_ble_hrs_set_location(uint8_t location);
/**
* @brief Get the value of the heart rate measurement of the device.
*
* @param[in] hrm The pointer to store the value of the heart rate measurement
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong heart rate measurement
*/
esp_err_t esp_ble_hrs_get_hrm(esp_ble_hrs_hrm_t *hrm);
/**
* @brief Set the value of the heart rate measurement of the device.
*
* @param[in] hrm The pointer to store the value of the heart rate measurement
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong heart rate measurement
*/
esp_err_t esp_ble_hrs_set_hrm(esp_ble_hrs_hrm_t *hrm);
/**
* @brief Initialization Heart Rate Service
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong initialization
* - ESP_FAIL on error
*/
esp_err_t esp_ble_hrs_init(void);
#ifdef __cplusplus
}
#endif