Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
ipso-sensor-template.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016, SICS Swedish ICT AB
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the copyright holder nor the names of its
14
* contributors may be used to endorse or promote products derived
15
* from this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
18
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
* OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
/**
32
* \addtogroup ipso-objects
33
* @{
34
*
35
*/
36
37
/**
38
* \file
39
* Implementation of OMA LWM2M / IPSO sensor template.
40
* \author
41
* Joakim Eriksson <joakime@sics.se>
42
* Niclas Finne <nfi@sics.se>
43
*/
44
45
#ifndef IPSO_SENSOR_TEMPLATE_H_
46
#define IPSO_SENSOR_TEMPLATE_H_
47
48
#include "
lwm2m-engine.h
"
49
50
typedef
struct
ipso_sensor ipso_sensor_t;
51
52
typedef
lwm2m_status_t (*ipso_sensor_get_value_millis_t)(
const
ipso_sensor_t *sensor, int32_t *v);
53
54
/* Values of the IPSO object */
55
typedef
struct
ipso_sensor_value {
56
lwm2m_object_instance_t reg_object;
57
const
ipso_sensor_t *sensor;
58
uint8_t flags;
59
int32_t last_value;
60
int32_t min_value;
61
int32_t max_value;
62
} ipso_sensor_value_t;
63
64
/* Meta data about an IPSO sensor object */
65
struct
ipso_sensor {
66
/* LWM2M object type */
67
uint16_t object_id;
68
uint16_t instance_id;
69
/* When we read out the value we send in a context to write to */
70
ipso_sensor_get_value_millis_t get_value_in_millis;
71
int32_t min_range;
72
int32_t max_range;
73
char
*unit;
74
/* update interval in seconds */
75
uint16_t update_interval;
76
ipso_sensor_value_t *sensor_value;
77
};
78
79
#define IPSO_SENSOR(name, oid, get_value, ...) \
80
static ipso_sensor_value_t name##_value; \
81
static const ipso_sensor_t name = { \
82
.object_id = oid, \
83
.sensor_value = &name##_value, \
84
.get_value_in_millis = get_value, \
85
__VA_ARGS__ \
86
}
87
88
int
ipso_sensor_add(
const
ipso_sensor_t *sensor);
89
int
ipso_sensor_remove(
const
ipso_sensor_t *sensor);
90
91
#endif
/* IPSO_SENSOR_TEMPLATE_H_ */
92
/** @} */
lwm2m-engine.h
Header file for the Contiki OMA LWM2M engine.
os
services
ipso-objects
ipso-sensor-template.h
Generated on
for Contiki-NG by
1.17.0