Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tdf.h
Go to the documentation of this file.
1
11
12#ifndef INFUSE_SDK_INCLUDE_INFUSE_DATA_LOGGER_HIGH_LEVEL_TDF_H_
13#define INFUSE_SDK_INCLUDE_INFUSE_DATA_LOGGER_HIGH_LEVEL_TDF_H_
14
15#include <stdint.h>
16
17#include <zephyr/device.h>
18#include <zephyr/sys/util.h>
19
20#include <infuse/tdf/tdf.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
32
34
35enum {
37 _TDF_DATA_LOGGER_FLASH_OFFSET = 0,
39 _TDF_DATA_LOGGER_REMOVABLE_OFFSET = 1,
41 _TDF_DATA_LOGGER_SERIAL_OFFSET = 2,
43 _TDF_DATA_LOGGER_UDP_OFFSET = 3,
45 _TDF_DATA_LOGGER_BT_ADV_OFFSET = 4,
47 _TDF_DATA_LOGGER_BT_PERIPHERAL_OFFSET = 5,
48};
49
51
55 TDF_DATA_LOGGER_FLASH = BIT(_TDF_DATA_LOGGER_FLASH_OFFSET),
57 TDF_DATA_LOGGER_REMOVABLE = BIT(_TDF_DATA_LOGGER_REMOVABLE_OFFSET),
59 TDF_DATA_LOGGER_SERIAL = BIT(_TDF_DATA_LOGGER_SERIAL_OFFSET),
61 TDF_DATA_LOGGER_UDP = BIT(_TDF_DATA_LOGGER_UDP_OFFSET),
63 TDF_DATA_LOGGER_BT_ADV = BIT(_TDF_DATA_LOGGER_BT_ADV_OFFSET),
65 TDF_DATA_LOGGER_BT_PERIPHERAL = BIT(_TDF_DATA_LOGGER_BT_PERIPHERAL_OFFSET),
66};
67
84int tdf_data_logger_log_core_dev(const struct device *dev, uint16_t tdf_id, uint8_t tdf_len,
85 uint8_t tdf_num, enum tdf_data_format format, uint64_t time,
86 uint32_t idx_period, const void *data);
87
101void tdf_data_logger_log_core(uint8_t logger_mask, uint16_t tdf_id, uint8_t tdf_len,
102 uint8_t tdf_num, enum tdf_data_format format, uint64_t time,
103 uint32_t idx_period, const void *data);
104
119static inline int tdf_data_logger_log_array_dev(const struct device *dev, uint16_t tdf_id,
120 uint8_t tdf_len, uint8_t tdf_num, uint64_t time,
121 uint32_t period, const void *data)
122{
123 return tdf_data_logger_log_core_dev(dev, tdf_id, tdf_len, tdf_num,
124 TDF_DATA_FORMAT_TIME_ARRAY, time, period, data);
125}
126
138static inline void tdf_data_logger_log_array(uint8_t logger_mask, uint16_t tdf_id, uint8_t tdf_len,
139 uint8_t tdf_num, uint64_t time, uint32_t period,
140 const void *data)
141{
142 tdf_data_logger_log_core(logger_mask, tdf_id, tdf_len, tdf_num, TDF_DATA_FORMAT_TIME_ARRAY,
143 time, period, data);
144}
145
158static inline int tdf_data_logger_log_dev(const struct device *dev, uint16_t tdf_id,
159 uint8_t tdf_len, uint64_t time, const void *data)
160{
161 return tdf_data_logger_log_core_dev(dev, tdf_id, tdf_len, 1, TDF_DATA_FORMAT_SINGLE, time,
162 0, data);
163}
164
174static inline void tdf_data_logger_log(uint8_t logger_mask, uint16_t tdf_id, uint8_t tdf_len,
175 uint64_t time, const void *data)
176{
177 tdf_data_logger_log_core(logger_mask, tdf_id, tdf_len, 1, TDF_DATA_FORMAT_SINGLE, time, 0,
178 data);
179}
180
194#define TDF_DATA_LOGGER_LOG(logger_mask, tdf_id, tdf_time, data) \
195 tdf_data_logger_log(logger_mask, tdf_id, sizeof(TDF_TYPE(tdf_id)), tdf_time, data); \
196 do { \
197 __maybe_unused const TDF_TYPE(tdf_id) *_data = data; \
198 } while (0)
199
215#define TDF_DATA_LOGGER_LOG_ARRAY(logger_mask, tdf_id, tdf_num, tdf_time, period, data) \
216 tdf_data_logger_log_array(logger_mask, tdf_id, sizeof(TDF_TYPE(tdf_id)), tdf_num, \
217 tdf_time, period, data); \
218 do { \
219 __maybe_unused const TDF_TYPE(tdf_id) *_data = data; \
220 } while (0)
221
229int tdf_data_logger_block_bytes_pending(const struct device *dev);
230
238int tdf_data_logger_block_bytes_remaining(const struct device *dev);
239
248int tdf_data_logger_flush_dev(const struct device *dev);
249
258const struct device *tdf_data_logger_from_mask(uint8_t logger_mask);
259
265void tdf_data_logger_flush(uint8_t logger_mask);
266
279int tdf_data_logger_remote_id_set(const struct device *dev, uint64_t remote_id);
280
284
285#ifdef __cplusplus
286}
287#endif
288
289#endif /* INFUSE_SDK_INCLUDE_INFUSE_DATA_LOGGER_HIGH_LEVEL_TDF_H_ */
tdf_data_format
Format of the data in a TDF.
Definition tdf.h:42
@ TDF_DATA_FORMAT_TIME_ARRAY
Time array with period.
Definition tdf.h:46
@ TDF_DATA_FORMAT_SINGLE
Single sample.
Definition tdf.h:44
static void tdf_data_logger_log(uint8_t logger_mask, uint16_t tdf_id, uint8_t tdf_len, uint64_t time, const void *data)
Add a single TDF to multiple data loggers.
Definition tdf.h:174
int tdf_data_logger_log_core_dev(const struct device *dev, uint16_t tdf_id, uint8_t tdf_len, uint8_t tdf_num, enum tdf_data_format format, uint64_t time, uint32_t idx_period, const void *data)
Add multiple TDFs to a data logger.
static void tdf_data_logger_log_array(uint8_t logger_mask, uint16_t tdf_id, uint8_t tdf_len, uint8_t tdf_num, uint64_t time, uint32_t period, const void *data)
Add multiple TDFs to multiple data loggers.
Definition tdf.h:138
void tdf_data_logger_flush(uint8_t logger_mask)
Flush any pending TDFs to multiple backends.
static int tdf_data_logger_log_array_dev(const struct device *dev, uint16_t tdf_id, uint8_t tdf_len, uint8_t tdf_num, uint64_t time, uint32_t period, const void *data)
Add multiple TDFs to a data logger.
Definition tdf.h:119
tdf_data_logger_mask
TDF data logger backends.
Definition tdf.h:53
int tdf_data_logger_remote_id_set(const struct device *dev, uint64_t remote_id)
Set the remote ID associated with the logger.
static int tdf_data_logger_log_dev(const struct device *dev, uint16_t tdf_id, uint8_t tdf_len, uint64_t time, const void *data)
Add a single TDF to a data logger.
Definition tdf.h:158
int tdf_data_logger_block_bytes_remaining(const struct device *dev)
Query the number of bytes remaining until the logger block will be flushed.
int tdf_data_logger_block_bytes_pending(const struct device *dev)
Query the number of bytes pending on the current block.
const struct device * tdf_data_logger_from_mask(uint8_t logger_mask)
Get a TDF logger devices from a mask.
int tdf_data_logger_flush_dev(const struct device *dev)
Flush any pending TDFs to backend.
void tdf_data_logger_log_core(uint8_t logger_mask, uint16_t tdf_id, uint8_t tdf_len, uint8_t tdf_num, enum tdf_data_format format, uint64_t time, uint32_t idx_period, const void *data)
Add multiple TDFs to multiple data loggers.
@ TDF_DATA_LOGGER_FLASH
Permanent flash storage device.
Definition tdf.h:55
@ TDF_DATA_LOGGER_SERIAL
Serial communications interface.
Definition tdf.h:59
@ TDF_DATA_LOGGER_BT_ADV
Bluetooth advertising communications interface.
Definition tdf.h:63
@ TDF_DATA_LOGGER_BT_PERIPHERAL
Bluetooth GATT peripheral communications interface.
Definition tdf.h:65
@ TDF_DATA_LOGGER_UDP
UDP communications interface.
Definition tdf.h:61
@ TDF_DATA_LOGGER_REMOVABLE
Removable flash storage device.
Definition tdf.h:57
TDF payload generation.