nRF5 SDK for Mesh v4.2.0
app_light_lightness.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_LIGHTNESS_H__
39 #define APP_LIGHT_LIGHTNESS_H__
40 
41 #include <stdint.h>
42 
43 #include "light_lightness_setup_server.h"
44 #include "app_timer.h"
45 #include "app_transition.h"
46 #include "list.h"
47 
94 #define APP_LIGHT_LIGHTNESS_SETUP_SERVER_DEF(_name, _force_segmented, _mic_size, _set_cb, _get_cb, _transition_cb) \
95  APP_TIMER_DEF(_name ## _timer); \
96  static app_light_lightness_setup_server_t _name = \
97  { \
98  .light_lightness_setup_server.settings.force_segmented = _force_segmented, \
99  .light_lightness_setup_server.settings.transmic_size = _mic_size, \
100  .app_add_notify.app_add_publish_cb = NULL, \
101  .app_add_notify.app_notify_set_cb = NULL, \
102  .state.transition.timer.p_timer_id = &_name ## _timer, \
103  .app_light_lightness_set_cb = _set_cb, \
104  .app_light_lightness_get_cb = _get_cb, \
105  .app_light_lightness_transition_cb = _transition_cb \
106  };
107 
112 typedef struct
113 {
120 
124  uint16_t target_snapshot;
125 
127  bool new_tid;
128 
129  /* Elapsed time at last publication. */
130  uint32_t published_ms;
131 
133  app_transition_t transition;
135 
136 /* Forward declaration */
137 typedef struct __app_light_lightness_setup_server_t app_light_lightness_setup_server_t;
138 
153 typedef void (*app_light_lightness_set_cb_t)(const app_light_lightness_setup_server_t * p_app,
154  uint16_t lightness);
155 
156 
165 typedef void (*app_light_lightness_get_cb_t)(const app_light_lightness_setup_server_t * p_app,
166  uint16_t * p_present_lightness);
167 
178 typedef void (*app_light_lightness_transition_cb_t)(const app_light_lightness_setup_server_t * p_app,
179  uint32_t transition_time_ms, uint16_t target_lightness);
180 
193 typedef void (*app_additional_publish_cb_t)(const void * p_app_v,
194  light_lightness_status_params_t * p_pub_data);
195 
208 typedef void (*app_notify_set_cb_t)(const void * p_app_v, uint16_t lightness);
209 
212 typedef struct
213 {
223 
227 {
229  light_lightness_setup_server_t light_lightness_setup_server;
230 
233 
236 
239 
242 
250  list_node_t node;
251 };
252 
273 uint32_t app_light_lightness_model_init(app_light_lightness_setup_server_t * p_app, uint8_t element_index);
274 
287 uint32_t app_light_lightness_binding_setup(app_light_lightness_setup_server_t * p_app);
288 
314 uint32_t app_light_lightness_current_value_publish(app_light_lightness_setup_server_t * p_app);
315 
332 uint32_t app_light_lightness_direct_actual_set(app_light_lightness_setup_server_t * p_app, uint16_t lightness_value);
333 
334 
336 #endif /* APP_LIGHT_LIGHTNESS_H__*/
void(* app_notify_set_cb_t)(const void *p_app_v, uint16_t lightness)
Application notify callback prototype.
void(* app_light_lightness_set_cb_t)(const app_light_lightness_setup_server_t *p_app, uint16_t lightness)
Application Light Lightness state set callback prototype.
uint16_t target_lightness
Target value of the lightness state, as received from the model interface.
app_light_lightness_state_t state
Internal variable.
app_light_lightness_get_cb_t app_light_lightness_get_cb
Get the device lightness value.
app_transition_t transition
Structure for using transition module functionality.
app_additional_light_lightness_notify_t app_add_notify
Additional publishing/notifying requirements structure.
uint16_t init_present_snapshot
Present value when message was received.
void * p_app_publish_v
Context pointer for the publish callback.
uint32_t app_light_lightness_binding_setup(app_light_lightness_setup_server_t *p_app)
Informs the model that the system is ready to have the powerup onoff bindings.
uint16_t initial_present_lightness
Initial present lightness required for handling Set/Delta Set message.
void(* app_light_lightness_transition_cb_t)(const app_light_lightness_setup_server_t *p_app, uint32_t transition_time_ms, uint16_t target_lightness)
Application Light Lightness transition time callback prototype.
void(* app_light_lightness_get_cb_t)(const app_light_lightness_setup_server_t *p_app, uint16_t *p_present_lightness)
Application Light Lightness state read callback prototype.
app_light_lightness_set_cb_t app_light_lightness_set_cb
Set the device lightness value.
uint32_t app_light_lightness_model_init(app_light_lightness_setup_server_t *p_app, uint8_t element_index)
Initializes the behavioral module for the generic Light Lightness model.
void(* app_additional_publish_cb_t)(const void *p_app_v, light_lightness_status_params_t *p_pub_data)
Application publish callback prototype.
uint32_t app_light_lightness_direct_actual_set(app_light_lightness_setup_server_t *p_app, uint16_t lightness_value)
Function to set the lightness value (sending to the hardware) and writing the flash state values...
Internal structure to hold state and timing information.
light_lightness_setup_server_t light_lightness_setup_server
Light lightness setup server context/.
uint32_t app_light_lightness_current_value_publish(app_light_lightness_setup_server_t *p_app)
Initiates value fetch from the user application by calling a get callback, updates internal state...
bool new_tid
To detect if TID is new while processing delta transition.
uint16_t target_snapshot
Requested target.
Application level structure holding the Light Lightness Setup server model context and Light Lightnes...
app_notify_set_cb_t app_notify_set_cb
A notify callback to call after receiving lightness Set messages.
list_node_t node
Internal variable.
Parameters for the light_lightness Status message.
app_light_lightness_transition_cb_t app_light_lightness_transition_cb
The device lightness transition time.
uint16_t present_lightness
Present value of the lightness state.
Structure for holding publish and notification callbacks for other states bound to Light Lightness st...
void * p_app_notify_v
A context pointer for the notify callback.
app_additional_publish_cb_t app_add_publish_cb
Publish callback to call to before publishing lightness status.

Documentation feedback | Developer Zone | Subscribe | Updated