nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
sensor_event.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _SENSOR_EVENT_H_
8#define _SENSOR_EVENT_H_
9
17#include <app_event_manager.h>
19#include <zephyr/drivers/sensor.h>
20#include <stdlib.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26
49
62 struct app_event_header header;
64 const char *descr;
66};
67
69
87 struct app_event_header header;
89 const char *descr;
90 struct event_dyndata dyndata;
91};
92
106 struct app_event_header header;
107
109 const char *descr;
112};
113
115
122static inline size_t sensor_event_get_data_cnt(const struct sensor_event *event)
123{
124 __ASSERT_NO_MSG((event->dyndata.size % sizeof(struct sensor_value)) == 0);
125
126 return (event->dyndata.size / sizeof(struct sensor_value));
127}
128
135static inline struct sensor_value *sensor_event_get_data_ptr(const struct sensor_event *event)
136{
137 return (struct sensor_value *)event->dyndata.data;
138}
139
140#ifdef __cplusplus
141}
142#endif
143
148#ifdef __cplusplus
149extern "C" {
150#endif
151
153
154#ifdef __cplusplus
155}
156#endif
157
158#endif /* _SENSOR_EVENT_H_ */
Application Event Manager header.
Application Event Manager profiler tracer header.
#define APP_EVENT_TYPE_DECLARE(ename)
Declare an event type.
Definition app_event_manager.h:143
#define APP_EVENT_TYPE_DYNDATA_DECLARE(ename)
Declare an event type with dynamic data size.
Definition app_event_manager.h:154
sensor_state
Sensor states.
Definition sensor_event.h:28
@ SENSOR_STATE_DISABLED
Definition sensor_event.h:32
@ SENSOR_STATE_ACTIVE
Definition sensor_event.h:38
@ SENSOR_STATE_ERROR
Definition sensor_event.h:41
@ SENSOR_STATE_COUNT
Definition sensor_event.h:44
@ SENSOR_STATE_SLEEP
Definition sensor_event.h:35
@ APP_EM_ENFORCE_ENUM_SIZE
Definition sensor_event.h:47
static struct sensor_value * sensor_event_get_data_ptr(const struct sensor_event *event)
Get pointer to the sensor data.
Definition sensor_event.h:135
static size_t sensor_event_get_data_cnt(const struct sensor_event *event)
Get size of sensor data.
Definition sensor_event.h:122
struct app_event_header header
Definition sensor_event.h:87
const char * descr
Definition sensor_event.h:89
struct event_dyndata dyndata
Definition sensor_event.h:90
Sensor event.
Definition sensor_event.h:86
enum sensor_state state
Definition sensor_event.h:65
const char * descr
Definition sensor_event.h:64
struct app_event_header header
Definition sensor_event.h:62
Sensor state event.
Definition sensor_event.h:61
struct app_event_header header
Definition sensor_event.h:106
int sampling_period
Definition sensor_event.h:111
const char * descr
Definition sensor_event.h:109
Set sensor period event.
Definition sensor_event.h:104