Trident IoT Zigbee SDK
Loading...
Searching...
No Matches
tr_level_control_server.h
Go to the documentation of this file.
1
10#ifndef TR_LEVEL_CONTROL_SERVER_H
11#define TR_LEVEL_CONTROL_SERVER_H
12
13#include "tr_af.h"
14
18#if defined(TR_LEVEL_CONTROL_SERVER_PLUGIN_PRINT_ENABLE) && (TR_LEVEL_CONTROL_SERVER_PLUGIN_PRINT_ENABLE == 1)
19#define tr_level_control_server_printf(...) tr_zcl_printf(__VA_ARGS__)
20#define tr_level_control_server_println(...) tr_zcl_println(__VA_ARGS__)
21#else
22#define tr_level_control_server_printf(...)
23#define tr_level_control_server_println(...)
24#endif
25
26// *****************************************************************************
27// this section of defines allow for lighting transitions to happen over time.
28// When a transition is in progress, a timer is used to trigger a tick function.
29// The state variables are used by the tick function to determine what to do next.
30// *****************************************************************************
31// we keep the same number of timer slots as we have endpoints
32#define TR_LEVEL_CONTROL_SERVER_MAX_LC_TIMERS_AT_ONCE TR_DEVICE_EP_COUNT
33
34// special index to mean timer index not found
35#define TR_LEVEL_CONTROL_SERVER_TIMER_INDEX_NOT_FOUND 0xFF
36
37// the tick function called by the timer to adjust state
39
40// struct for keeping information on active transitions using timers
41typedef struct
42{
43 // is this slot being used for an active timer
44 zb_bool_t slot_in_use;
45
46 // the mapping of endpoint to timer index
47 zb_uint8_t endpoint;
48
49 // the timer state so level_control_server_tick can decided what to do on the current tick
50 zb_uint32_t current_level_32;
51 zb_uint32_t target_level_32;
53 zb_uint16_t num_tenths_left;
54 zb_uint8_t move_direction;
55 zb_bool_t with_on_off;
56
58
64
68
72zb_bool_t tr_level_control_server_command_received_cb(zb_zcl_parsed_hdr_t *cmd_info);
73
80 zb_uint16_t attr_id,
81 zb_uint8_t *new_value,
82 zb_uint16_t manuf_code);
83
92zb_bool_t tr_level_control_server_move_to_level_cb(zb_zcl_parsed_hdr_t *cmd_info,
93 zb_uint8_t endpoint,
94 zb_uint8_t level,
95 zb_uint16_t transition_time,
96 zb_uint8_t option_mask,
97 zb_uint8_t option_override);
98
107zb_bool_t tr_level_control_server_move_cb(zb_zcl_parsed_hdr_t *cmd_info,
108 zb_uint8_t endpoint,
109 zb_uint8_t move_mode,
110 zb_uint8_t rate,
111 zb_uint8_t option_mask,
112 zb_uint8_t option_override);
113
123zb_bool_t tr_level_control_server_step_cb(zb_zcl_parsed_hdr_t *cmd_info,
124 zb_uint8_t endpoint,
125 zb_uint8_t step_mode,
126 zb_uint8_t step_size,
127 zb_uint16_t transition_time,
128 zb_uint8_t option_mask,
129 zb_uint8_t option_override);
130
137zb_bool_t tr_level_control_server_stop_cb(zb_zcl_parsed_hdr_t *cmd_info,
138 zb_uint8_t endpoint,
139 zb_uint8_t option_mask,
140 zb_uint8_t option_override);
141
150zb_bool_t tr_level_control_server_move_to_level_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info,
151 zb_uint8_t endpoint,
152 zb_uint8_t level,
153 zb_uint16_t transition_time,
154 zb_uint8_t option_mask,
155 zb_uint8_t option_override);
156
165zb_bool_t tr_level_control_server_move_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info,
166 zb_uint8_t endpoint,
167 zb_uint8_t move_mode,
168 zb_uint8_t rate,
169 zb_uint8_t option_mask,
170 zb_uint8_t option_override);
171
181zb_bool_t tr_level_control_server_step_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info,
182 zb_uint8_t endpoint,
183 zb_uint8_t step_mode,
184 zb_uint8_t step_size,
185 zb_uint16_t transition_time,
186 zb_uint8_t option_mask,
187 zb_uint8_t option_override);
188
195zb_bool_t tr_level_control_server_stop_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info,
196 zb_uint8_t endpoint,
197 zb_uint8_t option_mask,
198 zb_uint8_t option_override);
199
200
203 zb_uint8_t new_level);
204
206
211
212void write_new_current_level(zb_uint8_t new_level,
213 zb_uint8_t endpoint,
214 zb_bool_t with_on_off);
215
216// command that prints the status of the level control timer for each endpoint
218
219// function that is called from ZCL common when attr are ready to be used
221
222#endif // TR_LEVEL_CONTROL_SERVER_H
zb_uint8_t step_size
Definition tr_zcl_cmd_structs.h:303
zb_uint8_t step_mode
Definition tr_zcl_cmd_structs.h:302
zb_uint8_t option_override
Definition tr_zcl_cmd_structs.h:287
zb_uint8_t rate
Definition tr_zcl_cmd_structs.h:294
zb_uint8_t move_mode
Definition tr_zcl_cmd_structs.h:293
zb_uint8_t option_mask
Definition tr_zcl_cmd_structs.h:286
zb_uint8_t level
Definition tr_zcl_cmd_structs.h:284
zb_bool_t tr_level_control_server_move_to_level_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t level, zb_uint16_t transition_time, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster move to level command.
void tr_level_control_server_write_attr_cb(zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *new_value, zb_uint16_t manuf_code)
Callback fires when an Level Control server attribute is about to be written.
zb_bool_t tr_level_control_server_step_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t step_mode, zb_uint8_t step_size, zb_uint16_t transition_time, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster step command.
zb_bool_t tr_level_control_server_move_to_level_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t level, zb_uint16_t transition_time, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster move to level with on off command.
void tr_level_control_server_level_changed_cb(zb_uint8_t endpoint, zb_uint8_t new_level)
Callback fires when current level changes.
zb_bool_t tr_level_control_server_move_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t move_mode, zb_uint8_t rate, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster move with on off command.
zb_bool_t tr_level_control_server_stop_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster stop with on off command.
zb_bool_t tr_level_control_server_step_with_on_off_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t step_mode, zb_uint8_t step_size, zb_uint16_t transition_time, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster step with on off command.
zb_bool_t tr_level_control_server_stop_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster stop command.
void tr_level_control_server_init_cb(zb_uint8_t endpoint)
Callback fires when the Level Control server cluster plugin is initialized.
zb_bool_t tr_level_control_server_command_received_cb(zb_zcl_parsed_hdr_t *cmd_info)
Callback that user can declare to handle any Level Control server commands.
zb_bool_t tr_level_control_server_move_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t move_mode, zb_uint8_t rate, zb_uint8_t option_mask, zb_uint8_t option_override)
Callback that user can declare to handle level control cluster move command.
Definition tr_level_control_server.h:42
zb_bool_t with_on_off
Definition tr_level_control_server.h:55
zb_uint8_t move_direction
Definition tr_level_control_server.h:54
zb_uint32_t move_rate_per_tenth_32
Definition tr_level_control_server.h:52
zb_uint8_t endpoint
Definition tr_level_control_server.h:47
zb_uint16_t num_tenths_left
Definition tr_level_control_server.h:53
zb_uint32_t target_level_32
Definition tr_level_control_server.h:51
zb_uint32_t current_level_32
Definition tr_level_control_server.h:50
zb_bool_t slot_in_use
Definition tr_level_control_server.h:44
Trident application framework include.
void tr_level_control_server_init(void)
void level_control_server_timer_tick(zb_uint8_t endpoint)
void tr_level_control_server_attributes_ready(void)
void level_control_server_check_timers(void)
void write_new_current_level(zb_uint8_t new_level, zb_uint8_t endpoint, zb_bool_t with_on_off)
zb_uint8_t endpoint
Definition tr_nvram_attr.h:176
zb_uint16_t manuf_code
Definition tr_nvram_attr.h:180
zb_uint16_t attr_id
Definition tr_nvram_attr.h:178
zb_uint16_t transition_time
Definition tr_scenes_common.h:49