nRF5 SDK for Mesh v5.0.0
app_light_ctl.h
1 /* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form, except as embedded into a Nordic
11  * Semiconductor ASA integrated circuit in a product or a software update for
12  * such product, must reproduce the above copyright notice, this list of
13  * conditions and the following disclaimer in the documentation and/or other
14  * materials provided with the distribution.
15  *
16  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17  * contributors may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * 4. This software, with or without modification, must only be used with a
21  * Nordic Semiconductor ASA integrated circuit.
22  *
23  * 5. Any software provided in binary form under this license must not be reverse
24  * engineered, decompiled, modified and/or disassembled.
25  *
26  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef APP_LIGHT_CTL_H__
39 #define APP_LIGHT_CTL_H__
40 
41 #include <stdint.h>
42 
43 #include "light_ctl_setup_server.h"
44 #include "light_lightness_setup_server.h"
45 #include "app_timer.h"
46 #include "app_transition.h"
47 #include "app_light_lightness.h"
48 #include "list.h"
49 #if (SCENE_SETUP_SERVER_INSTANCES_MAX > 0) || (DOXYGEN)
50 #include "app_scene.h"
51 #endif
52 
97 typedef struct
98 {
100  uint32_t temperature32;
102  uint16_t delta_uv;
104 
118 #define APP_LIGHT_CTL_SETUP_SERVER_DEF(_name, _force_segmented, _mic_size, _light_ctl_set_cb, _light_ctl_get_cb, _light_ctl_transition_cb) \
119  APP_TIMER_DEF(_name ## _timer); \
120  static app_light_ctl_setup_server_t _name = \
121  { \
122  .light_ctl_setup_srv.settings.force_segmented = _force_segmented, \
123  .light_ctl_setup_srv.settings.transmic_size = _mic_size, \
124  .state.transition.timer.p_timer_id = &_name ## _timer, \
125  .app_light_ctl_set_cb = _light_ctl_set_cb, \
126  .app_light_ctl_get_cb = _light_ctl_get_cb, \
127  .app_light_ctl_transition_cb = _light_ctl_transition_cb, \
128  };
129 
134 typedef struct
135 {
140 
145 
150 
159 
161  bool new_tid;
162 
163  /* Elapsed time at last publication. */
164  uint32_t published_ms;
165 
167  app_transition_t transition;
169 
170 /* Forward declaration */
171 typedef struct __app_light_ctl_setup_server_t app_light_ctl_setup_server_t;
172 
188 typedef void (*app_light_ctl_set_cb_t)(const app_light_ctl_setup_server_t * p_app, app_light_ctl_temperature_duv_hw_state_t * p_ctl_state);
189 
190 
201 typedef void (*app_light_ctl_get_cb_t)(const app_light_ctl_setup_server_t * p_app, app_light_ctl_temperature_duv_hw_state_t * p_present_ctl_state);
202 
214 typedef void (*app_light_ctl_transition_cb_t)(const app_light_ctl_setup_server_t * p_app,
215  uint32_t transition_time_ms,
217 
222 {
224  light_ctl_setup_server_t light_ctl_setup_srv;
225 
227  app_light_lightness_setup_server_t * p_app_ll;
228 
231 
234 
237 
248  list_node_t node;
249 #if (SCENE_SETUP_SERVER_INSTANCES_MAX > 0) || (DOXYGEN)
250 
252  app_scene_model_interface_t scene_if;
255  app_scene_setup_server_t * p_app_scene;
256 #endif
257 };
258 
281 uint32_t app_light_ctl_model_init(app_light_ctl_setup_server_t * p_app, uint8_t element_index,
282  app_light_lightness_setup_server_t * p_app_ll);
283 
296 uint32_t app_light_ctl_binding_setup(app_light_ctl_setup_server_t * p_app);
297 
320 uint32_t app_light_ctl_current_value_publish(app_light_ctl_setup_server_t * p_app);
321 
322 #if (SCENE_SETUP_SERVER_INSTANCES_MAX > 0) || (DOXYGEN)
323 
335 uint32_t app_light_ctl_scene_context_set(app_light_ctl_setup_server_t * p_app,
336  app_scene_setup_server_t * p_app_scene);
337 #endif
338 
340 #endif /* APP_LIGHT_CTL_H__*/
bool ctl_state_set_active
Internal variable.
app_scene_model_interface_t scene_if
Internal variable.
uint32_t present_temperature32
Present value of the temperature32 state.
void(* app_light_ctl_transition_cb_t)(const app_light_ctl_setup_server_t *p_app, uint32_t transition_time_ms, app_light_ctl_temperature_duv_hw_state_t target_ctl_state)
Application Light CTL transition time callback prototype.
uint32_t init_present_temp32_snapshot
Present temperature32 value when message was received.
int16_t initial_present_delta_uv
Initial present delta_uv required for handling Set/Delta Set message.
int16_t target_duv_snapshot
Requested target DUV.
Light CTL hardware state format for transfer of temperature and delta UV between the mid app and top ...
Definition: app_light_ctl.h:97
bool abort_move
Internal variable.
int16_t present_delta_uv
Present value of the delta uv state.
uint32_t temperature32
Temperature32 value.
list_node_t node
Internal variable.
int16_t init_present_duv_snapshot
Present DUV value when message was received.
app_light_ctl_transition_cb_t app_light_ctl_transition_cb
The device Light CTL transition time.
app_light_ctl_get_cb_t app_light_ctl_get_cb
Get the device temp/duv value .
bool new_tid
To detect if TID is new while processing delta transition.
app_light_ctl_set_cb_t app_light_ctl_set_cb
Set the device temp/duv values.
void(* app_light_ctl_get_cb_t)(const app_light_ctl_setup_server_t *p_app, app_light_ctl_temperature_duv_hw_state_t *p_present_ctl_state)
Application Light CTL state read callback prototype.
void(* app_light_ctl_set_cb_t)(const app_light_ctl_setup_server_t *p_app, app_light_ctl_temperature_duv_hw_state_t *p_ctl_state)
Application Light CTL (temperature/delta UV) state set callback prototype.
app_scene_setup_server_t * p_app_scene
Internal variable.
uint32_t app_light_ctl_model_init(app_light_ctl_setup_server_t *p_app, uint8_t element_index, app_light_lightness_setup_server_t *p_app_ll)
Initializes the behavioral module for the Light CTL and Light Lightness models.
int16_t target_delta_uv
Target value of the delta_uv state, as received from the model interface.
uint32_t app_light_ctl_current_value_publish(app_light_ctl_setup_server_t *p_app)
Initiates value fetch from the user application by calling a get callback, updates internal state...
uint32_t app_light_ctl_scene_context_set(app_light_ctl_setup_server_t *p_app, app_scene_setup_server_t *p_app_scene)
Sets the scene context.
uint32_t target_temperature32
Target value of the temperature32 state, as received from the model interface.
Application level structure holding the Light CTL Setup Server model context, Light Lightness applica...
Internal structure to hold state and timing information.
app_transition_t transition
Structure for using transition module functionality.
app_light_lightness_setup_server_t * p_app_ll
app server for light lightness.
uint32_t target_temp32_snapshot
Requested target temperature32.
bool ctl_temperature_state_set_active
Internal variable.
app_light_ctl_state_t state
Internal variable.
uint32_t initial_present_temperature32
Initial present temperature32 required for handling Set/Delta Set message.
uint32_t app_light_ctl_binding_setup(app_light_ctl_setup_server_t *p_app)
Informs the model that the system is ready to have the powerup onoff bindings.
light_ctl_setup_server_t light_ctl_setup_srv
CTL setup server context.

Documentation feedback | Developer Zone | Subscribe | Updated