1 /* 2 * Copyright (c) 2016 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_ 8 #define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_ 9 10 /** 11 * @brief Heart Rate Service (HRS) 12 * @defgroup bt_hrs Heart Rate Service (HRS) 13 * @ingroup bluetooth 14 * @{ 15 * 16 * [Experimental] Users should note that the APIs can change 17 * as a part of ongoing development. 18 */ 19 20 #include <stdint.h> 21 22 #include <zephyr/sys/slist.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** @brief Heart rate service callback structure */ 29 struct bt_hrs_cb { 30 /** @brief Heart rate notifications changed 31 * 32 * @param enabled Flag that is true if notifications were enabled, false 33 * if they were disabled. 34 */ 35 void (*ntf_changed)(bool enabled); 36 37 /** Internal member to form a list of callbacks */ 38 sys_snode_t _node; 39 }; 40 41 /** @brief Heart rate service callback register 42 * 43 * This function will register callbacks that will be called in 44 * certain events related to Heart rate service. 45 * 46 * @param cb Pointer to callbacks structure. Must point to memory that remains valid 47 * until unregistered. 48 * 49 * @return 0 on success 50 * @return -EINVAL in case @p cb is NULL 51 */ 52 int bt_hrs_cb_register(struct bt_hrs_cb *cb); 53 54 /** @brief Heart rate service callback unregister 55 * 56 * This function will unregister callback from Heart rate service. 57 * 58 * @param cb Pointer to callbacks structure 59 * 60 * @return 0 on success 61 * @return -EINVAL in case @p cb is NULL 62 * @return -ENOENT in case the @p cb was not found in registered callbacks 63 */ 64 int bt_hrs_cb_unregister(struct bt_hrs_cb *cb); 65 66 /** @brief Notify heart rate measurement. 67 * 68 * This will send a GATT notification to all current subscribers. 69 * 70 * @param heartrate The heartrate measurement in beats per minute. 71 * 72 * @return Zero in case of success and error code in case of error. 73 */ 74 int bt_hrs_notify(uint16_t heartrate); 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 /** 81 * @} 82 */ 83 84 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_ */ 85