nRF5 SDK for Mesh v5.0.0
app_transition.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_TRANSITION_H__
39 #define APP_TRANSITION_H__
40 
41 #include <stdint.h>
42 
43 #include "app_timer.h"
44 #include "model_common.h"
45 #include "fsm.h"
46 #include "timer_scheduler.h"
47 
70 typedef enum
71 {
81 
82 /* Transition parameters */
83 typedef struct
84 {
88  int32_t required_delta;
90  uint32_t minimum_step_ms;
94 
95 
97 typedef struct __app_transition_t app_transition_t;
98 
105 typedef void (*app_transition_delay_start_cb_t)(const app_transition_t * p_transition);
106 
114 typedef void (*app_transition_transition_start_cb_t)(const app_transition_t * p_transition);
115 
124 typedef void (*app_transition_transition_tick_cb_t)(const app_transition_t * p_transition);
125 
135 typedef void (*app_transition_transition_complete_cb_t)(const app_transition_t * p_transition);
136 
139 {
148 
153 
155  uint32_t delay_ms;
156 
160  timer_event_t delay_timer;
162  void * p_context;
164  fsm_t fsm;
165 };
166 
176 uint32_t app_transition_remaining_time_get(app_transition_t * p_transition);
177 
186 uint32_t app_transition_elapsed_time_get(app_transition_t * p_transition);
187 
196 bool app_transition_time_complete_check(app_transition_t * p_transition);
197 
202 void app_transition_trigger(app_transition_t * p_transition);
203 
208 void app_transition_abort(app_transition_t *p_transition);
209 
220 uint32_t app_transition_init(app_transition_t * p_transition);
221 
228 static inline app_transition_params_t * app_transition_requested_get(app_transition_t * p_transition)
229 {
230  return &p_transition->requested_params;
231 }
232 
239 static inline app_transition_params_t * app_transition_ongoing_get(app_transition_t * p_transition)
240 {
241  return &p_transition->ongoing_params;
242 }
243 
245 #endif /* APP_TRANSITION_H__ */
indicating MOVE SET message
void(* app_transition_delay_start_cb_t)(const app_transition_t *p_transition)
Delay start callback prototype.
uint32_t minimum_step_ms
The minimum time for a transition step.
void(* app_transition_transition_tick_cb_t)(const app_transition_t *p_transition)
Transition tick callback prototype.
int32_t required_delta
Computed transition delta.
indicating no transition
fsm_t fsm
Internal.
indicating SET message
Structure for model timers.
Definition: model_common.h:198
void * p_context
Context to be passed to triggered callbacks.
app_transition_transition_tick_cb_t transition_tick_cb
Callback to call on every transition tick.
uint32_t app_transition_elapsed_time_get(app_transition_t *p_transition)
Gets the elapsed transition time in milliseconds.
app_transition_params_t ongoing_params
Ongoing transition parameters.
model_timer_t timer
Transition timer.
void(* app_transition_transition_start_cb_t)(const app_transition_t *p_transition)
Transition start callback prototype.
app_transition_params_t requested_params
Requested transition parameters.
uint32_t transition_time_ms
Remaining time to reach target_level.
app_transition_transition_start_cb_t transition_start_cb
Callback to call when transition beings.
void(* app_transition_transition_complete_cb_t)(const app_transition_t *p_transition)
Transition complete callback prototype.
void app_transition_abort(app_transition_t *p_transition)
Aborts the transition if any in progress.
Internal structure to hold transition cbs and timing information.
app_transition_delay_start_cb_t delay_start_cb
Callback to call when transition delay beings.
static app_transition_params_t * app_transition_requested_get(app_transition_t *p_transition)
Gets a pointer to the structure with parameters for the requested transition.
timer_event_t delay_timer
Delay timer.
app_transition_transition_complete_cb_t transition_complete_cb
Callback to call on transition time complete.
app_transition_type_t transition_type
Transition Type.
uint32_t app_transition_init(app_transition_t *p_transition)
Initializes the transition module.
static app_transition_params_t * app_transition_ongoing_get(app_transition_t *p_transition)
Gets a pointer to the structure with parameters of the ongoing transition.
uint32_t app_transition_remaining_time_get(app_transition_t *p_transition)
Gets the remaining transition time in milliseconds.
void app_transition_trigger(app_transition_t *p_transition)
Starts the transition with specified transition parameters.
uint32_t delay_ms
Time to delay the requested transition.
app_transition_type_t
Transition types.
bool app_transition_time_complete_check(app_transition_t *p_transition)
Checks if the transition time has been complete.
indicating DELTA SET message

Documentation feedback | Developer Zone | Subscribe | Updated