ref_app_breathing.h
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2023
2 // All rights reserved
3 // This file is subject to the terms and conditions defined in the file
4 // 'LICENSES/license_acconeer.txt', (BSD 3-Clause License) which is part
5 // of this source code package.
6 
7 #ifndef REF_APP_BREATHING_H_
8 #define REF_APP_BREATHING_H_
9 
10 #include <stdbool.h>
11 #include <stdint.h>
12 
13 #include "acc_detector_presence.h"
14 
15 /**
16  * @brief Breathing application context handle
17  */
19 
21 
22 /**
23  * @brief Breathing application config container
24  */
25 typedef struct
26 {
27  /**
28  * Length of time series
29  */
31  /**
32  * Lowest anticipated breathing rate (breaths per minute)
33  */
35  /**
36  * Highest anticipated breathing rate (breaths per minute)
37  */
39  /**
40  * Number of distance to analyze in breathing
41  */
43  /**
44  * Use presence detector to determine distance to motion
45  */
47  /**
48  * Time to determine distance to presence
49  */
51  /**
52  * Presence config
53  */
56 
57 /**
58  * @brief State of the application
59  */
60 typedef enum
61 {
68 
69 /**
70  * @brief Breathing application results container
71  */
72 typedef struct
73 {
74  /**
75  * Indication when a new breathing rate result is produced
76  */
78  /**
79  * Breathing rate in BPM
80  */
82  /**
83  * State of the application
84  */
86  /**
87  * Result of the presence detector
88  */
91 
92 /**
93  * @brief Create a configuration for the ref app breathing
94  *
95  * @return A configuration for the ref app breathing, NULL if creation was not possible
96  */
98 
99 /**
100  * @brief Destory a configuration for the ref app breathing
101  *
102  * @param[in] config The configuration to destroy
103  */
105 
106 /**
107  * @brief Create a handle for the ref app breathing
108  *
109  * @param[in] config The configuration to create the handle with
110  * @return A handle for the ref app breathing, NULL if creation was not possible
111  */
113 
114 /**
115  * @brief Destroy a handle for the ref app breathing
116  *
117  * @param[in] handle The ref app breathing handle to destroy
118  */
120 
121 /**
122  * @brief Get the buffer size needed for the provided ref app breathing handle
123  *
124  * @param[in] handle The ref app breathing handle to to get the buffer size for
125  * @param[out] buffer_size The buffer size
126  * @return true if successful, false otherwise
127  */
129 
130 /**
131  * @brief Prepare the application to do a measurement
132  *
133  * @param[in] handle The ref app breathing handle to prepare for
134  * @param[in] config The configuration to prepare with
135  * @param[in] sensor The sensor instance to prepare
136  * @param[in] sensor_cal_result The calibration result to prepare with
137  * @param[in] buffer Memory used by the application to prepare the sensor for measurements
138  * The buffer will only be used during the duration of this call
139  * @param[in] buffer_size The size in bytes of the buffer, should be at least buffer_size
140  * from @ref ref_app_breathing_get_buffer_size
141  * @return true if successful, false otherwise
142  */
147  void *buffer,
148  uint32_t buffer_size);
149 
150 /**
151  * @brief Process the data
152  *
153  * @param[in] handle The ref app breathing handle for to get the next result for
154  * @param[in] buffer A reference to the buffer (populated by @ref acc_sensor_read) containing the
155  * data to be processed.
156  * @param[out] result Ref app breathing results
157  * @return true if successful, otherwise false
158  */
160 
161 #endif
ref_app_breathing_config_t::time_series_length_s
uint16_t time_series_length_s
Definition: ref_app_breathing.h:30
REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE
@ REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE
Definition: ref_app_breathing.h:66
ref_app_breathing_result_t::result_ready
bool result_ready
Definition: ref_app_breathing.h:77
ref_app_breathing_prepare
bool ref_app_breathing_prepare(ref_app_breathing_handle_t *handle, ref_app_breathing_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare the application to do a measurement.
Definition: ref_app_breathing.c:358
REF_APP_BREATHING_APP_STATE_INIT
@ REF_APP_BREATHING_APP_STATE_INIT
Definition: ref_app_breathing.h:62
buffer
void * buffer
Definition: i2c_example_cargo.c:40
sensor_cal_result
acc_cal_result_t sensor_cal_result
Definition: i2c_example_cargo.c:36
ref_app_breathing_get_buffer_size
bool ref_app_breathing_get_buffer_size(ref_app_breathing_handle_t *handle, uint32_t *buffer_size)
Get the buffer size needed for the provided ref app breathing handle.
Definition: ref_app_breathing.c:353
ref_app_breathing_config_t::highest_breathing_rate
uint16_t highest_breathing_rate
Definition: ref_app_breathing.h:38
acc_cal_result_t
The result from a completed calibration.
Definition: acc_definitions_a121.h:30
ref_app_breathing_create
ref_app_breathing_handle_t * ref_app_breathing_create(ref_app_breathing_config_t *config)
Create a handle for the ref app breathing.
Definition: ref_app_breathing.c:156
ref_app_breathing_result_t
Breathing application results container.
Definition: ref_app_breathing.h:72
ref_app_breathing_destroy
void ref_app_breathing_destroy(ref_app_breathing_handle_t *handle)
Destroy a handle for the ref app breathing.
Definition: ref_app_breathing.c:265
config
cargo_config_t config
Definition: i2c_example_cargo.c:34
REF_APP_BREATHING_APP_STATE_INTRA_PRESENCE
@ REF_APP_BREATHING_APP_STATE_INTRA_PRESENCE
Definition: ref_app_breathing.h:64
ref_app_breathing_result_t::breathing_rate
float breathing_rate
Definition: ref_app_breathing.h:81
ref_app_breathing_config_create
ref_app_breathing_config_t * ref_app_breathing_config_create(void)
Create a configuration for the ref app breathing.
Definition: ref_app_breathing.c:100
acc_detector_presence_result_t
Presence detector results container.
Definition: acc_detector_presence.h:46
buffer_size
uint32_t buffer_size
Definition: i2c_example_cargo.c:41
sensor
acc_sensor_t * sensor
Definition: i2c_example_cargo.c:33
ref_app_breathing_result_t::presence_result
acc_detector_presence_result_t presence_result
Definition: ref_app_breathing.h:89
ref_app_breathing_process
bool ref_app_breathing_process(ref_app_breathing_handle_t *handle, void *buffer, ref_app_breathing_result_t *result)
Process the data.
Definition: ref_app_breathing.c:368
ref_app_breathing_result_t::app_state
ref_app_breathing_app_state_t app_state
Definition: ref_app_breathing.h:85
handle
cargo_handle_t * handle
Definition: i2c_example_cargo.c:35
result
cargo_result_t result
Definition: i2c_example_cargo.c:43
ref_app_breathing_config_t::use_presence_processor
bool use_presence_processor
Definition: ref_app_breathing.h:46
REF_APP_BREATHING_APP_STATE_NO_PRESENCE
@ REF_APP_BREATHING_APP_STATE_NO_PRESENCE
Definition: ref_app_breathing.h:63
ref_app_breathing_config_destroy
void ref_app_breathing_config_destroy(ref_app_breathing_config_t *config)
Destory a configuration for the ref app breathing.
Definition: ref_app_breathing.c:143
acc_detector_presence_config_t
struct acc_detector_presence_config acc_detector_presence_config_t
Definition: acc_detector_presence.h:41
REF_APP_BREATHING_APP_STATE_DETERMINE_DISTANCE
@ REF_APP_BREATHING_APP_STATE_DETERMINE_DISTANCE
Definition: ref_app_breathing.h:65
ref_app_breathing_config_t::num_dists_to_analyze
uint16_t num_dists_to_analyze
Definition: ref_app_breathing.h:42
ref_app_breathing_handle
Definition: ref_app_breathing.c:23
ref_app_breathing_config_t
Breathing application config container.
Definition: ref_app_breathing.h:25
ref_app_breathing_config_t::distance_determination_duration_s
uint16_t distance_determination_duration_s
Definition: ref_app_breathing.h:50
acc_detector_presence.h
ref_app_breathing_config_t::lowest_breathing_rate
uint16_t lowest_breathing_rate
Definition: ref_app_breathing.h:34
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
ref_app_breathing_app_state_t
ref_app_breathing_app_state_t
State of the application.
Definition: ref_app_breathing.h:60
ref_app_breathing_config_t::presence_config
acc_detector_presence_config_t * presence_config
Definition: ref_app_breathing.h:54