Go to the documentation of this file.
29 #define SENSOR_ID (1U)
30 #define SENSOR_TIMEOUT_MS (1000U)
32 #define DEFAULT_PRESET_CONFIG BREATHING_PRESET_SITTING
85 printf(
"Failed to create config\n");
96 printf(
"Failed to create handle\n");
103 printf(
"ref_app_breathing_get_buffer_size() failed\n");
111 printf(
"Failed to allocate buffer\n");
117 uint32_t sleep_time_ms = (uint32_t)(1000.0f / frame_rate);
126 printf(
"acc_sensor_create() failed\n");
133 printf(
"Sensor calibration failed\n");
140 printf(
"ref_app_breathing_prepare() failed\n");
149 printf(
"enter_hibernate failed\n");
164 printf(
"ref_app_breathing_process() failed\n");
178 prev_app_state =
result.app_state;
186 printf(
"Application finished OK\n");
239 bool cal_complete =
false;
240 const uint16_t calibration_retries = 1U;
243 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
253 if (status && !cal_complete)
257 }
while (status && !cal_complete);
268 printf(
"acc_sensor_calibrate() failed\n");
279 printf(
"exit_hibernate failed\n");
285 printf(
"acc_sensor_measure failed\n");
292 printf(
"Sensor interrupt timeout\n");
299 printf(
"acc_sensor_read() failed\n");
306 printf(
"enter_hibernate failed\n");
319 printf(
"acc_sensor_hibernate_on failed\n");
335 printf(
"acc_sensor_hibernate_off failed\n");
345 switch (
result->app_state)
350 printf(
"NO_PRESENCE_DETECTED\n");
353 printf(
"INTRA_PRESENCE_DETECTED\n");
356 printf(
"DETERMINE_DISTANCE_ESTIMATE\n");
359 printf(
"ESTIMATE_BREATHING_RATE\n");
368 if (prev_app_state !=
result->app_state)
375 printf(
"Breaths: %" PRIu16
" bpm\n", (uint16_t)
result->breathing_rate);
389 printf(
"Data saturated. The detector result is not reliable.\n");
394 printf(
"Frame delayed. Could not read data fast enough.\n");
395 printf(
"Try lowering the frame rate or call 'acc_sensor_read' more frequently.\n");
400 printf(
"Sensor recalibration needed ... \n");
404 printf(
"exit_hibernate failed\n");
410 printf(
"Sensor calibration failed\n");
414 printf(
"Sensor recalibration done!\n");
419 printf(
"acc_detector_presence_prepare() failed\n");
425 printf(
"enter_hibernate failed\n");
@ REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE
static bool enter_hibernate(acc_sensor_t *sensor)
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
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.
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
@ REF_APP_BREATHING_APP_STATE_INIT
static bool sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
static void cleanup(ref_app_breathing_handle_t *handle, ref_app_breathing_config_t *config, acc_sensor_t *sensor, void *buffer)
acc_cal_result_t sensor_cal_result
#define SENSOR_TIMEOUT_MS
static bool exit_hibernate(acc_sensor_t *sensor)
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.
acc_processing_result_t processing_result
The result from a completed calibration.
ref_app_breathing_handle_t * ref_app_breathing_create(ref_app_breathing_config_t *config)
Create a handle for the ref app breathing.
static bool handle_indications(ref_app_breathing_handle_t *handle, ref_app_breathing_config_t *config, acc_sensor_t *sensor, acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_presence_result_t *presence_result)
Breathing application results container.
void ref_app_breathing_destroy(ref_app_breathing_handle_t *handle)
Destroy a handle for the ref app breathing.
static void print_result(ref_app_breathing_result_t *result, ref_app_breathing_app_state_t prev_app_state)
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
int acconeer_main(int argc, char *argv[])
Assembly test example.
@ REF_APP_BREATHING_APP_STATE_INTRA_PRESENCE
void acc_detector_presence_config_intra_detection_threshold_set(acc_detector_presence_config_t *presence_config, float intra_detection_threshold)
Set the detection threshold for the intra-frame presence detection.
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
ref_app_breathing_config_t * ref_app_breathing_config_create(void)
Create a configuration for the ref app breathing.
void acc_integration_set_periodic_wakeup(uint32_t time_msec)
Set up a periodic timer used to wake up the system from sleep.
Presence detector results container.
static bool measure(acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
bool ref_app_breathing_process(ref_app_breathing_handle_t *handle, void *buffer, ref_app_breathing_result_t *result)
Process the data.
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
void acc_detector_presence_config_end_set(acc_detector_presence_config_t *presence_config, float end)
Set the end point of measurement interval in meters.
bool acc_sensor_hibernate_off(const acc_sensor_t *sensor)
Restore sensor after exiting hibernation.
const char * acc_version_get(void)
Get the version of the Acconeer software.
@ REF_APP_BREATHING_APP_STATE_NO_PRESENCE
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
void ref_app_breathing_config_destroy(ref_app_breathing_config_t *config)
Destory a configuration for the ref app breathing.
static void print_app_state(ref_app_breathing_result_t *result)
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
struct acc_detector_presence_config acc_detector_presence_config_t
bool acc_sensor_hibernate_on(acc_sensor_t *sensor)
Prepare sensor for entering hibernation.
void acc_sensor_status(const acc_sensor_t *sensor)
Check the status of the sensor.
@ REF_APP_BREATHING_APP_STATE_DETERMINE_DISTANCE
static void set_config(ref_app_breathing_config_t *config, breathing_preset_t preset)
float acc_detector_presence_config_frame_rate_get(const acc_detector_presence_config_t *presence_config)
Get the frame rate.
#define DEFAULT_PRESET_CONFIG
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
void acc_integration_sleep_until_periodic_wakeup(void)
Put the system in sleep until the periodic timer triggers.
@ BREATHING_PRESET_SITTING
bool acc_sensor_calibrate(acc_sensor_t *sensor, bool *cal_complete, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Calibrate a sensor.
Breathing application config container.
@ BREATHING_PRESET_INFANT
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
struct acc_sensor acc_sensor_t
ref_app_breathing_app_state_t
State of the application.
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
void acc_detector_presence_config_frame_rate_app_driven_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the application should maintain the requested frame rate.
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.