Contiki-NG
ipso-objects.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Yanzi Networks 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 apps
33 * @{
34 */
35
36/**
37 * \defgroup ipso-objects An implementation of IPSO Objects
38 * @{
39 *
40 * This is an implementation of IPSO Objects for OMA LWM2M.
41 */
42
43/**
44 * \file
45 * Header file for the Contiki IPSO Objects for OMA LWM2M
46 * \author
47 * Joakim Eriksson <joakime@sics.se>
48 * Niclas Finne <nfi@sics.se>
49 */
50
51#ifndef IPSO_OBJECTS_H_
52#define IPSO_OBJECTS_H_
53
54#include "contiki.h"
55
56void ipso_temperature_init(void);
57void ipso_button_init(void);
58void ipso_light_control_init(void);
59void ipso_leds_control_init(void);
60
61/* the init function to register the IPSO objects */
62void ipso_objects_init(void);
63
64struct ipso_objects_actuator {
65 /**
66 * \brief Initialize the driver.
67 */
68 void (* init)(void);
69
70 /**
71 * \brief Check if the actuator is on or off.
72 *
73 * \return Zero if the actuator is off and non-zero otherwise.
74 */
75 int (* is_on)(void);
76
77 /**
78 * \brief Set the actuator to on or off.
79 *
80 * \param onoroff Zero to set the actuator to off and non-zero otherwise.
81 * \return Zero if ok and a non-zero error code otherwise.
82 */
83 int (* set_on)(int onoroff);
84
85 /**
86 * \brief Set the actuator to on or off.
87 *
88 * \param onoroff Zero to set the actuator to off and non-zero otherwise.
89 * \return Zero if ok and a non-zero error code otherwise.
90 */
91 int (* get_dim_level)(void);
92
93 /**
94 * \brief Set the dim level of the actuator.
95 *
96 * \param level The dim level between 0% and 100%.
97 * \return Zero if ok and a non-zero error code otherwise.
98 */
99 int (* set_dim_level)(int level);
100};
101
102struct ipso_objects_sensor {
103 /**
104 * \brief Initialize the driver.
105 */
106 void (* init)(void);
107
108 /**
109 * \brief Read the sensor value in 1/1000 units.
110 *
111 * \param value A pointer to the variable to hold the sensor value.
112 * \return Zero if ok and a non-zero error code otherwise.
113 */
114 int (* read_value)(int32_t *value);
115};
116
117#endif /* IPSO_OBJECTS_H_ */
118/**
119 * @}
120 * @}
121 */