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