Edge AI Add-on API 2.2.0
Loading...
Searching...
No Matches
data_fwd_sensor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef DATA_FORWARDER_SENSOR_H_
8#define DATA_FORWARDER_SENSOR_H_
9
18#include <stddef.h>
19#include <stdint.h>
20
21#include <zephyr/drivers/sensor.h>
22#include <zephyr/sys/util.h>
23
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
40
54int data_fwd_sensor_fetch(proto_value_t *values, const size_t values_size, size_t *count);
55
62
71const char *const *data_fwd_sensor_channel_names(void);
72
79
86
97static inline proto_value_t data_fwd_sensor_value_to_proto_value(const struct sensor_value *val)
98{
99#if IS_ENABLED(CONFIG_DATA_FWD_PROTO_INT32_VALUES)
100 return (proto_value_t)CLAMP(sensor_value_to_micro(val), INT32_MIN, INT32_MAX);
101#else
102 return sensor_value_to_float(val);
103#endif
104}
105
106#ifdef __cplusplus
107}
108#endif
109
114#endif /* DATA_FORWARDER_SENSOR_H_ */
float proto_value_t
Definition protocol_types.h:21
uint8_t data_fwd_sensor_type_id(void)
Get the application-defined sensor type identifier.
const char *const * data_fwd_sensor_channel_names(void)
Get short names for each data channel.
static proto_value_t data_fwd_sensor_value_to_proto_value(const struct sensor_value *val)
Convert a Zephyr sensor value to a protocol sample value.
Definition data_fwd_sensor.h:97
int data_fwd_sensor_fetch(proto_value_t *values, const size_t values_size, size_t *count)
Read one sample from the sensor into values.
int data_fwd_sensor_init(void)
Initialize the selected sensor driver.
uint8_t data_fwd_sensor_channel_count(void)
Get the number of data channels in each sample.
uint16_t data_fwd_sensor_frequency(void)
Get the nominal sampling frequency in Hz.