LCOV - code coverage report
Current view: top level - zephyr/bluetooth/services - hrs.h Hit Total Coverage
Test: new.info Lines: 7 8 87.5 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           0 : /*
       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             : /**
      29             :  * @brief Server shall restart the accumulation of energy expended from zero
      30             :  */
      31           1 : #define BT_HRS_CONTROL_POINT_RESET_ENERGY_EXPANDED_REQ 0x01
      32             : 
      33             : /** @brief Heart rate service callback structure */
      34           1 : struct bt_hrs_cb {
      35             :         /** @brief Heart rate notifications changed
      36             :          *
      37             :          * @param enabled Flag that is true if notifications were enabled, false
      38             :          *                if they were disabled.
      39             :          */
      40           1 :         void (*ntf_changed)(bool enabled);
      41             : 
      42             :         /**
      43             :          * @brief Heart rate control point write callback
      44             :          *
      45             :          * @note if Server supports the Energy Expended feature then application
      46             :          * shall implement and support @ref BT_HRS_CONTROL_POINT_RESET_ENERGY_EXPANDED_REQ
      47             :          * request code
      48             :          *
      49             :          * @param request control point request code
      50             :          *
      51             :          * @return 0 on successful handling of control point request
      52             :          * @return -ENOTSUP if not supported. It can be used to pass handling to other
      53             :          *         listeners in case of multiple listeners
      54             :          * @return other negative error codes will result in immediate error response
      55             :          */
      56           1 :         int (*ctrl_point_write)(uint8_t request);
      57             : 
      58             :         /** Internal member to form a list of callbacks */
      59             :         sys_snode_t _node;
      60             : };
      61             : 
      62             : /** @brief Heart rate service callback register
      63             :  *
      64             :  * This function will register callbacks that will be called in
      65             :  * certain events related to Heart rate service.
      66             :  *
      67             :  * @param cb Pointer to callbacks structure. Must point to memory that remains valid
      68             :  * until unregistered.
      69             :  *
      70             :  * @return 0 on success
      71             :  * @return -EINVAL in case @p cb is NULL
      72             :  */
      73           1 : int bt_hrs_cb_register(struct bt_hrs_cb *cb);
      74             : 
      75             : /** @brief Heart rate service callback unregister
      76             :  *
      77             :  * This function will unregister callback from Heart rate service.
      78             :  *
      79             :  * @param cb Pointer to callbacks structure
      80             :  *
      81             :  * @return 0 on success
      82             :  * @return -EINVAL in case @p cb is NULL
      83             :  * @return -ENOENT in case the @p cb was not found in registered callbacks
      84             :  */
      85           1 : int bt_hrs_cb_unregister(struct bt_hrs_cb *cb);
      86             : 
      87             : /** @brief Notify heart rate measurement.
      88             :  *
      89             :  * This will send a GATT notification to all current subscribers.
      90             :  *
      91             :  *  @param heartrate The heartrate measurement in beats per minute.
      92             :  *
      93             :  *  @return Zero in case of success and error code in case of error.
      94             :  */
      95           1 : int bt_hrs_notify(uint16_t heartrate);
      96             : 
      97             : #ifdef __cplusplus
      98             : }
      99             : #endif
     100             : 
     101             : /**
     102             :  * @}
     103             :  */
     104             : 
     105             : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_ */

Generated by: LCOV version 1.14