summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/app-framework/sensor/app/wa-inc/sensor.h
blob: 109f895d381d016203024b8e6c863a9a5752ffb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright (C) 2019 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#ifndef _AEE_SENSOR_H_
#define _AEE_SENSOR_H_

#include "bi-inc/attr_container.h"

#ifdef __cplusplus
extern "C" {
#endif

/* board producer define sensor */
struct _sensor;
typedef struct _sensor *sensor_t;

/**
 * @typedef sensor_event_handler_f
 *
 * @brief Define the signature of callback function for API
 * sensor_open() to handle sensor event.
 *
 * @param sensor the sensor which the event belong to
 * @param sensor_event the sensor event
 * @param user_data user data associated with the sensor which is set when
 * calling sensor_open().
 *
 * @see sensor_open
 */
typedef void (*sensor_event_handler_f)(sensor_t sensor,
                                       attr_container_t *sensor_event,
                                       void *user_data);

/*
 *****************
 * Sensor APIs
 *****************
 */

/**
 * @brief Open sensor.
 *
 * @param name sensor name
 * @param index sensor index
 * @param handler callback function to handle the sensor event
 * @param user_data user data
 *
 * @return the sensor opened if success, NULL otherwise
 */
sensor_t
sensor_open(const char *name, int index, sensor_event_handler_f handler,
            void *user_data);

/**
 * @brief Configure sensor with interval/bit_cfg/delay values.
 *
 * @param sensor the sensor to be configured
 * @param interval sensor event interval
 * @param bit_cfg sensor bit config
 * @param delay sensor delay
 *
 * @return true if success, false otherwise
 */
bool
sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay);

/**
 * @brief Configure sensor with attr_container_t object.
 *
 * @param sensor the sensor to be configured
 * @param cfg the configuration
 *
 * @return true if success, false otherwise
 */
bool
sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg);

/**
 * @brief Close sensor.
 *
 * @param sensor the sensor to be closed
 *
 * @return true if success, false otherwise
 */
bool
sensor_close(sensor_t sensor);

#ifdef __cplusplus
}
#endif

#endif