nRF5 SDK for Mesh v5.0.0
app_scene.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_SCENE_H__
39 #define APP_SCENE_H__
40 
41 #include <stdint.h>
42 
43 #include "scene_setup_server.h"
44 #include "app_transition.h"
45 #include "nrf_mesh_config_examples.h"
46 
89 #define APP_SCENE_SETUP_SERVER_DEF(_name, _force_segmented, _mic_size, _transition_cb, _p_dtt_server); \
90  APP_TIMER_DEF(_name ## _timer); \
91  static app_scene_setup_server_t _name = \
92  { \
93  .scene_setup_server.settings.force_segmented = _force_segmented, \
94  .scene_setup_server.settings.transmic_size = _mic_size, \
95  .state.transition.timer.p_timer_id = &_name ## _timer, \
96  .app_scene_transition_cb = _transition_cb, \
97  .scene_setup_server.p_gen_dtt_server = _p_dtt_server \
98  };
99 
102 #ifndef APP_SCENE_MODEL_COUNT
103 #define APP_SCENE_MODEL_COUNT (1)
104 #endif
105 
111 typedef struct
112 {
117 
119  app_transition_t transition;
121 
122 /* Forward declaration */
123 typedef struct __app_scene_setup_server_t app_scene_setup_server_t;
124 /* Forward declaration */
125 typedef struct __app_scene_model_interface_t app_scene_model_interface_t;
126 
138 typedef void (*app_scene_transition_cb_t)(const app_scene_setup_server_t * p_app,
139  uint32_t transition_time_ms,
140  uint16_t target_scene);
141 
153 typedef void (*app_scene_store_cb_t)(const app_scene_model_interface_t * p_app_model_if,
154  uint8_t scene_index);
155 
156 
171 typedef void (*app_scene_recall_cb_t)(const app_scene_model_interface_t * p_app_model_if,
172  uint8_t scene_index,
173  uint32_t delay_ms,
174  uint32_t transition_time_ms);
175 
187 typedef void (*app_scene_delete_cb_t)(const app_scene_model_interface_t * p_app_model_if,
188  uint8_t scene_index);
189 
190 
191 typedef struct
192 {
193  app_scene_store_cb_t scene_store_cb;
194  app_scene_recall_cb_t scene_recall_cb;
195  app_scene_delete_cb_t scene_delete_cb;
197 
198 /* Interface that is to be used by other App Models. */
200 {
201  const app_scene_callbacks_t * p_callbacks;
202 };
203 
207 {
208  scene_setup_server_t scene_setup_server;
209 
212 
217  app_scene_model_interface_t * scene_models[APP_SCENE_MODEL_COUNT];
220 };
221 
239 uint32_t app_scene_model_init(app_scene_setup_server_t * p_app, uint8_t element_index);
240 
254 uint32_t app_scene_model_add(app_scene_setup_server_t * p_app,
255  app_scene_model_interface_t * p_app_scene_model_interface);
256 
269 void app_scene_model_scene_changed(app_scene_setup_server_t * p_app);
270 
273 #endif /* APP_SCENE_H__ */
uint32_t app_scene_model_init(app_scene_setup_server_t *p_app, uint8_t element_index)
Initializes the behavioral module for the Scene model.
Internal structure to hold state.
Definition: app_scene.h:111
app_scene_transition_cb_t app_scene_transition_cb
The device scene transition time.
Definition: app_scene.h:211
#define APP_SCENE_MODEL_COUNT
Number of Scene Models to support storage.
Definition: app_scene.h:103
app_scene_state_t state
Internal variable.
Definition: app_scene.h:215
void(* app_scene_transition_cb_t)(const app_scene_setup_server_t *p_app, uint32_t transition_time_ms, uint16_t target_scene)
Application transition time callback prototype.
Definition: app_scene.h:138
uint16_t target_scene_number
Target scene number for transition to active scene, as received from the model interface.
Definition: app_scene.h:116
uint32_t app_scene_model_add(app_scene_setup_server_t *p_app, app_scene_model_interface_t *p_app_scene_model_interface)
The API is to be called by application to register a model which is to be stored with scene...
uint32_t next_model_interface
Internal variable.
Definition: app_scene.h:219
Application level structure holding the Scene server model context and sensor state representation...
Definition: app_scene.h:206
uint16_t current_scene_number
Current scene number for the active scene.
Definition: app_scene.h:114
void(* app_scene_store_cb_t)(const app_scene_model_interface_t *p_app_model_if, uint8_t scene_index)
Application Scene state store callback prototype.
Definition: app_scene.h:153
void(* app_scene_recall_cb_t)(const app_scene_model_interface_t *p_app_model_if, uint8_t scene_index, uint32_t delay_ms, uint32_t transition_time_ms)
Application Scene state recall callback prototype.
Definition: app_scene.h:171
void app_scene_model_scene_changed(app_scene_setup_server_t *p_app)
This API is called by the behavioral modules of other models to inform that the current state of the ...
void(* app_scene_delete_cb_t)(const app_scene_model_interface_t *p_app_model_if, uint8_t scene_index)
Application Scene state delete callback prototype.
Definition: app_scene.h:187
app_transition_t transition
Structure for using transition module functionality.
Definition: app_scene.h:119

Documentation feedback | Developer Zone | Subscribe | Updated