nRF5 SDK for Mesh v5.0.0
light_lc_setup_server.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 LIGHT_LC_SETUP_SERVER_H__
39 #define LIGHT_LC_SETUP_SERVER_H__
40 
41 #include <stdint.h>
42 #include "access.h"
43 #include "model_common.h"
44 #include "fsm.h"
45 
46 #include "generic_onoff_server.h"
47 #include "light_lc_common.h"
48 #include "timer_scheduler.h"
49 
64 #define LIGHT_LC_SERVER_MODEL_ID 0x130F
65 
67 #define LIGHT_LC_SETUP_SERVER_MODEL_ID 0x1310
68 
69 /* Forward declaration */
70 typedef struct __light_lc_server_t light_lc_server_t;
71 
72 /* Forward declaration */
73 typedef struct __light_lc_setup_server_t light_lc_setup_server_t;
74 
85 typedef void (*light_lc_persist_state_set_cb_t)(const light_lc_setup_server_t * p_s_server,
86  const light_lc_state_t lc_state,
87  const void *p_set_value);
88 
98 typedef void (*light_lc_persist_state_get_cb_t)(const light_lc_setup_server_t * p_s_server,
99  const light_lc_state_t lc_state,
100  void * p_get_value);
101 
110 typedef void (*light_lc_actual_set_cb_t)(const light_lc_setup_server_t * p_s_server,
111  uint16_t actual_lightness);
112 
121 typedef void (*light_lc_actual_get_cb_t)(const light_lc_setup_server_t * p_s_server,
122  uint16_t * p_actual_lightness);
123 
127 typedef struct
128 {
129  light_lc_persist_state_set_cb_t light_lc_persist_set_cb;
130  light_lc_persist_state_get_cb_t light_lc_persist_get_cb;
131  light_lc_actual_set_cb_t light_lc_actual_set_cb;
132  light_lc_actual_get_cb_t light_lc_actual_get_cb;
134 
138 typedef struct
139 {
141  uint8_t element_index;
148 
152 
155 {
158 
161 
163  generic_onoff_server_t generic_onoff_srv;
164 
167 };
168 
169 
187 uint32_t light_lc_server_mode_status_publish(const light_lc_server_t * p_server,
188  const light_lc_mode_status_params_t * p_params);
189 
207 uint32_t light_lc_server_occ_mode_status_publish(light_lc_server_t * p_server,
208  const light_lc_occupancy_mode_status_params_t * p_params);
209 
227 uint32_t light_lc_server_light_onoff_status_publish(light_lc_server_t * p_server,
228  const light_lc_light_onoff_status_params_t * p_params);
229 
233 typedef struct
234 {
238 
240 typedef struct
241 {
242  /* states not stored in flash */
248  uint32_t luxlevel_out;
250  uint16_t lightness_out;
251 
253  uint8_t handle;
255 
259 typedef struct
260 {
262  uint8_t element_index;
269 
273 
278 typedef struct
279 {
288 
295 
296  /* The lightness output is in the transition, and both of these
297  * lightness values are linear */
302 
303  /* The lux level output is in the transition, too */
307  uint32_t target_luxlevel;
309 
312 {
315 
317  light_lc_server_t lc_srv;
318 
321 
323  light_lc_transition_info_t transition_info;
324 
326  timer_event_t onoff_timer;
327 
329  fsm_t fsm;
330 
332  model_timer_t fsm_timer;
333 
335  model_timer_t light_pi_timer;
336 
338  model_timer_t sensor_delay_timer;
339 
342 };
343 
363 uint32_t light_lc_setup_server_init(light_lc_setup_server_t * p_s_server,
364  uint8_t element_index);
365 
383 uint32_t light_lc_setup_server_property_status_publish(const light_lc_setup_server_t * p_s_server,
384  const light_lc_property_status_params_t * p_params);
385 
386 
406 uint32_t light_lc_setup_server_ponoff_binding_setup(light_lc_setup_server_t * p_s_server,
407  uint8_t onpowerup,
408  bool * p_lc_control);
409 
411 #endif /* LIGHT_LC_SETUP_SERVER_H__ */
void(* light_lc_persist_state_set_cb_t)(const light_lc_setup_server_t *p_s_server, const light_lc_state_t lc_state, const void *p_set_value)
Callback type for storing data to the persistent memory after Set messages affecting the persistent s...
uint16_t access_model_handle_t
Access layer handle type.
Definition: access.h:162
bool requested_light_onoff
Requested light_onoff from incoming message.
void(* light_lc_actual_get_cb_t)(const light_lc_setup_server_t *p_s_server, uint16_t *p_actual_lightness)
Callback type for getting the actual lightness.
bool transition_time_is_provided
Transition time is provided.
uint32_t requested_transition_time_ms
Requested transition from incoming message.
generic_onoff_server_t generic_onoff_srv
Parent model context for - Generic OnOff server.
Structure for tracking TID expiry for the models.
Definition: model_common.h:169
uint32_t light_lc_setup_server_ponoff_binding_setup(light_lc_setup_server_t *p_s_server, uint8_t onpowerup, bool *p_lc_control)
Function to do the OnPowerup binding.
Parameters for the Light LC Property Status message.
Internal structure to hold state and timing information.
uint32_t requested_delay_ms
Requested delay from incoming message.
Parameters for the Light LC Light OnOff Status message.
User provided settings and callbacks for the non-setup server model instance.
Structure for model timers.
Definition: model_common.h:198
light_lc_state_t
Enum for to determine which state data variable is being set/gotten.
Parameters for the Light LC Occupancy Mode Status message.
Transaction callbacks for the Light LC states.
bool force_segmented
If server should force outgoing messages as segmented messages.
nrf_mesh_transmic_size_t transmic_size
TransMIC size used by the outgoing server messages.
uint32_t initial_present_luxlevel
Initial lux level.
Parameters for the Light LC Mode Status message.
The Light OnOff message is the only one that has transition and delay, though we need to keep informa...
uint32_t light_lc_server_occ_mode_status_publish(light_lc_server_t *p_server, const light_lc_occupancy_mode_status_params_t *p_params)
Publishes unsolicited Status message.
uint8_t element_index
Element Index.
light_lc_server_settings_t settings
Settings and callbacks for this instance.
uint32_t target_luxlevel
Target lux level.
uint8_t present_light_onoff
Current light_onoff state for currently active command.
uint16_t target_lightness
Target lightness (linear)
uint32_t light_lc_server_light_onoff_status_publish(light_lc_server_t *p_server, const light_lc_light_onoff_status_params_t *p_params)
Publishes unsolicited Status message.
tid_tracker_t tid_tracker
Tid tracker structure.
bool ambient_luxlevel_valid
if true, ble ambient lux level is valid (written since boot time)
light_lc_setup_server_state_cbs_t light_lc_cbs
Transaction callbacks for the Light LC states.
User provided settings and callbacks for the model instance.
light_lc_server_t lc_srv
Parent model context for - LC server.
bool force_segmented
If server should force outgoing messages as segmented messages.
access_model_handle_t model_handle
Model handle assigned to this instance.
void(* light_lc_actual_set_cb_t)(const light_lc_setup_server_t *p_s_server, uint16_t actual_lightness)
Callback type for setting the actual lightness.
uint16_t lightness_out
lightness output from FSM
uint8_t handle
flash handle - only used by flash system
uint32_t light_lc_setup_server_init(light_lc_setup_server_t *p_s_server, uint8_t element_index)
Initializes Light LC Setup server.
nrf_mesh_transmic_size_t
Message MIC size selection.
Definition: nrf_mesh.h:385
uint32_t light_lc_server_mode_status_publish(const light_lc_server_t *p_server, const light_lc_mode_status_params_t *p_params)
Publishes unsolicited Status message.
uint8_t target_light_onoff
Target light_onoff state for currently active command.
uint32_t transition_time_ms
Current transition time for currently active command.
light_lc_setup_server_settings_t settings
Model settings and callbacks for this instance.
void(* light_lc_persist_state_get_cb_t)(const light_lc_setup_server_t *p_s_server, const light_lc_state_t lc_state, void *p_get_value)
Callback type for getting data from the persistent memory after Get messages are received.
uint32_t ambient_luxlevel
Data Received from ambient light sensor.
uint16_t initial_present_lightness
Initial present lightness (linear)
nrf_mesh_transmic_size_t transmic_size
TransMIC size used by the outgoing server messages.
const light_lc_setup_server_callbacks_t * p_callbacks
Callback list.
access_model_handle_t model_handle
Model handle assigned to this instance.
Light LC setup server callback list.
light_lc_setup_server_state_t state
LC server state variables (not FSM state)
uint32_t luxlevel_out
lux level output from FSM
uint32_t light_lc_setup_server_property_status_publish(const light_lc_setup_server_t *p_s_server, const light_lc_property_status_params_t *p_params)
Publishes unsolicited Status message.

Documentation feedback | Developer Zone | Subscribe | Updated