nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
hrs_client.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_HRS_CLIENT_H_
8#define BT_HRS_CLIENT_H_
9
17#include <zephyr/bluetooth/conn.h>
18#include <bluetooth/gatt_dm.h>
19#include <zephyr/bluetooth/gatt.h>
20
21#include <zephyr/sys/atomic.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
34};
35
45};
46
52
55
58
61
64
67
70};
71
76 uint8_t value_format : 1;
77
80
83
86
89};
90
96
99
104 uint16_t rr_intervals[CONFIG_BT_HRS_CLIENT_RR_INTERVALS_COUNT];
105
107 uint16_t hr_value;
108
113};
114
115/* Helper forward structure declaration representing Heart Rate Service Client instance.
116 * Needed for callback declaration that are using instance structure as argument.
117 */
118struct bt_hrs_client;
119
130typedef void (*bt_hrs_client_notify_cb)(struct bt_hrs_client *hrs_c,
131 const struct bt_hrs_client_measurement *meas,
132 int err);
133
142 enum bt_hrs_client_sensor_location location,
143 int err);
144
151typedef void (*bt_hrs_client_write_cb)(struct bt_hrs_client *hrs_c,
152 uint8_t err);
153
158 uint16_t handle;
159
161 uint16_t ccc_handle;
162
164 struct bt_gatt_subscribe_params notify_params;
165
168};
169
174 uint16_t handle;
175
177 struct bt_gatt_read_params read_params;
178
181};
182
187 uint16_t handle;
188
190 struct bt_gatt_write_params write_params;
191
194};
195
201 struct bt_conn *conn;
202
205
208
211
213 atomic_t state;
214};
215
227
240 bt_hrs_client_notify_cb notify_cb);
241
253
264
274
285 enum bt_hrs_client_cp_value value,
287
297
311int bt_hrs_client_handles_assign(struct bt_gatt_dm *dm, struct bt_hrs_client *hrs_c);
312
313#ifdef __cplusplus
314}
315#endif
316
321#endif /* BT_HRS_CLIENT_H_ */
void(* bt_hrs_client_write_cb)(struct bt_hrs_client *hrs_c, uint8_t err)
Heart Rate Control Point write callback.
Definition: hrs_client.h:151
bool bt_hrs_client_has_sensor_location(struct bt_hrs_client *hrs_c)
Check if Heart Rate Service has the Body Sensor Location characteristic.
int bt_hrs_client_measurement_unsubscribe(struct bt_hrs_client *hrs_c)
Remove subscription to the Heart Rate Measurement notification.
bt_hrs_client_error
Heart Rate Service error codes.
Definition: hrs_client.h:31
@ BT_HRS_CLIENT_ERROR_CP_NOT_SUPPORTED
Definition: hrs_client.h:33
bt_hrs_client_sensor_location
Body sensor location values.
Definition: hrs_client.h:49
@ BT_HRS_CLIENT_SENSOR_LOCATION_FINGER
Definition: hrs_client.h:60
@ BT_HRS_CLIENT_SENSOR_LOCATION_OTHER
Definition: hrs_client.h:51
@ BT_HRS_CLIENT_SENSOR_LOCATION_HAND
Definition: hrs_client.h:63
@ BT_HRS_CLIENT_SENSOR_LOCATION_WRIST
Definition: hrs_client.h:57
@ BT_HRS_CLIENT_SENSOR_LOCATION_CHEST
Definition: hrs_client.h:54
@ BT_HRS_CLIENT_SENSOR_LOCATION_EAR_LOBE
Definition: hrs_client.h:66
@ BT_HRS_CLIENT_SENSOR_LOCATION_FOOT
Definition: hrs_client.h:69
int bt_hrs_client_sensor_location_read(struct bt_hrs_client *hrs_c, bt_hrs_client_read_sensor_location_cb read_cb)
Read Body Sensor Location characteristic.
int bt_hrs_client_handles_assign(struct bt_gatt_dm *dm, struct bt_hrs_client *hrs_c)
Function for assigning handles to Heart Rate Service Client instance.
int bt_hrs_client_measurement_subscribe(struct bt_hrs_client *hrs_c, bt_hrs_client_notify_cb notify_cb)
Subscribe to Heart Rate Measurement notification.
int bt_hrs_client_init(struct bt_hrs_client *hrs_c)
Function for initializing the Heart Rate Service Client.
bt_hrs_client_cp_value
Heart Rate Control Point values.
Definition: hrs_client.h:40
@ BT_HRS_CLIENT_CP_VALUE_RESET_EE
Definition: hrs_client.h:44
bool bt_hrs_client_has_control_point(struct bt_hrs_client *hrs_c)
Check if Heart Rate Service has the Heart Rate Control Point characteristic.
void(* bt_hrs_client_read_sensor_location_cb)(struct bt_hrs_client *hrs_c, enum bt_hrs_client_sensor_location location, int err)
Heart Rate Body Sensor Location read callback.
Definition: hrs_client.h:141
int bt_hrs_client_control_point_write(struct bt_hrs_client *hrs_c, enum bt_hrs_client_cp_value value, bt_hrs_client_write_cb write_cb)
Write Heart Rate Control Point characteristic.
void(* bt_hrs_client_notify_cb)(struct bt_hrs_client *hrs_c, const struct bt_hrs_client_measurement *meas, int err)
Heart Rate Measurement notification callback.
Definition: hrs_client.h:130
uint16_t handle
Definition: hrs_client.h:174
bt_hrs_client_read_sensor_location_cb read_cb
Definition: hrs_client.h:180
struct bt_gatt_read_params read_params
Definition: hrs_client.h:177
Body Sensor Location characteristic structure.
Definition: hrs_client.h:172
struct bt_gatt_write_params write_params
Definition: hrs_client.h:190
uint16_t handle
Definition: hrs_client.h:187
bt_hrs_client_write_cb write_cb
Definition: hrs_client.h:193
Heart Rate Control Point characteristic structure.
Definition: hrs_client.h:185
uint16_t ccc_handle
Definition: hrs_client.h:161
struct bt_gatt_subscribe_params notify_params
Definition: hrs_client.h:164
bt_hrs_client_notify_cb notify_cb
Definition: hrs_client.h:167
uint16_t handle
Definition: hrs_client.h:158
Heart Rate Measurement characteristic structure.
Definition: hrs_client.h:156
uint16_t energy_expended
Definition: hrs_client.h:112
uint16_t hr_value
Definition: hrs_client.h:107
uint8_t rr_intervals_count
Definition: hrs_client.h:98
uint16_t rr_intervals[CONFIG_BT_HRS_CLIENT_RR_INTERVALS_COUNT]
Definition: hrs_client.h:104
struct bt_hrs_flags flags
Definition: hrs_client.h:95
Data structure of the Heart Rate Measurement characteristic.
Definition: hrs_client.h:93
struct bt_conn * conn
Definition: hrs_client.h:201
struct bt_hrs_client_control_point cp_char
Definition: hrs_client.h:210
atomic_t state
Definition: hrs_client.h:213
struct bt_hrs_client_hr_meas measurement_char
Definition: hrs_client.h:204
struct bt_hrs_client_body_sensor_location sensor_location_char
Definition: hrs_client.h:207
Heart Rate Service Client instance structure. This structure contains status information for the clie...
Definition: hrs_client.h:199
uint8_t energy_expended_present
Definition: hrs_client.h:85
uint8_t sensor_contact_detected
Definition: hrs_client.h:79
uint8_t rr_intervals_present
Definition: hrs_client.h:88
uint8_t value_format
Definition: hrs_client.h:76
uint8_t sensor_contact_supported
Definition: hrs_client.h:82
Heart Measurement flags structure.
Definition: hrs_client.h:74