Welcome to mirror list, hosted at ThFree Co, Russian Federation.

zcl.window.h « zcl « include « stack « zigbee « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c9ea4f7af9b95b27fcc6e98f66a6f71fed564eee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/**
 * @file zcl.window.h
 * @brief ZCL Window Covering cluster header
 * ZCL 7 section 7.4
 * ZCL 8 section 7.4
 * @copyright Copyright [2009 - 2020] Exegin Technologies Limited. All rights reserved.
 */

#ifndef ZCL_WINDOW_H
# define ZCL_WINDOW_H

/* IMPORTANT INFORMATION:
 *
 * The Window Covering Cluster uses scene data to save and restore configurations
 * and therefore needs 2 additional callback functions.
 * Instead of writing attributes directly from the callback functions:
 * windowServerSetSceneData, this function serves a as helper function instead to
 * check if the tilt and lift pecentage attributes exist and unpack the scene data.
 *
 * The additional callback functions must be implemented and used in the application layer
 * to read and write the attributes.
 */

/* PICS.ZCL.Window
 * WNCV.S | True
 * WNCV.S.Lift | True
 * WNCV.S.Tilt | True
 * WNCV.S.ClosedLoop | False
 * WNCV.C | True
 *
 * Server Attributes
 * WNCV.S.Afffd | True
 * WNCV.S.A0000 | True
 * WNCV.S.A0001 | False
 * WNCV.S.A0002 | False
 * WNCV.S.A0003 | False
 * WNCV.S.A0004 | False
 * WNCV.S.A0005 | False
 * WNCV.S.A0006 | False
 * WNCV.S.A0007 | True
 * WNCV.S.A0008 | False
 * WNCV.S.A0008.Scene | False
 * WNCV.S.A0008.Report.DefaultConfig | False
 * WNCV.S.A0008.Report.Tx | False
 * WNCV.S.A0009 | False
 * WNCV.S.A0009.Scene | False
 * WNCV.S.A0009.Report.DefaultConfig | False
 * WNCV.S.A0009.Report.Tx | False
 * WNCV.S.A0010 | False
 * WNCV.S.A0012 | False
 * WNCV.S.A0013 | False
 * WNCV.S.A0014 | False
 * WNCV.S.A0015 | False
 * WNCV.S.A0016 | False
 * WNCV.S.A0017 | True
 * WNCV.S.A0018 | False
 * WNCV.S.A0019 | False
 *
 * Commands Received
 * WNCV.S.C00.Rsp | True
 * WNCV.S.C01.Rsp | True
 * WNCV.S.C02.Rsp | True
 * WNCV.S.C04.Rsp | False
 * WNCV.S.C05.Rsp | False
 * WNCV.S.C07.Rsp | False
 * WNCV.S.C08.Rsp | False
 *
 *
 * Client Attributes
 * WNCV.C.Afffd | True
 * WNCV.C.A0008.Report.Rsp | False
 * WNCV.C.A0009.Report.Rsp | False
 *
 * Commands Generated
 * WNCV.C.C00.Tx | True
 * WNCV.C.C01.Tx | True
 * WNCV.C.C02.Tx | True
 * WNCV.C.C04.Tx | False
 * WNCV.C.C05.Tx | False
 * WNCV.C.C07.Tx | False
 * WNCV.C.C08.Tx | False
 */

#include "zcl/zcl.h"

/** Window Covering Server Attribute Ids */
enum ZbZclWncvServerAttrT {
    /* Information Attribute Set */
    ZCL_WNCV_SVR_ATTR_COVERING_TYPE = 0x0000, /**< WindowCoveringType */
    ZCL_WNCV_SVR_ATTR_PHY_CLOSE_LIMIT_LIFT = 0x0001, /**< PhysicalClosedLimitLift (Optional) */
    ZCL_WNCV_SVR_ATTR_PHY_CLOSE_LIMIT_TILT = 0x0002, /**<  PhysicalClosedLimitTilt (Optional) */
    ZCL_WNCV_SVR_ATTR_CURR_POSITION_LIFT = 0x0003, /**< CurrentPositionLift (Optional) */
    ZCL_WNCV_SVR_ATTR_CURR_POSITION_TILT = 0x0004, /**< CurrentPositionTilt (Optional) */
    ZCL_WNCV_SVR_ATTR_ACTUATION_NUMBER_LIFT = 0x0005, /**< NumberOfActuationsLift (Optional) */
    ZCL_WNCV_SVR_ATTR_ACCUATION_NUMBER_TILT = 0x0006, /**< NumberOfActuationsTilt (Optional) */
    ZCL_WNCV_SVR_ATTR_CONFIG_STATUS = 0x0007, /**< ConfigStatus */
    ZCL_WNCV_SVR_ATTR_CURR_POS_LIFT_PERCENT = 0x0008, /**< CurrentPositionLiftPercentage */
    ZCL_WNCV_SVR_ATTR_CURR_POS_TILT_PERCENT = 0x0009, /**< CurrentPositionTiltPercentage */
    /* Settings Attribute Set */
    ZCL_WNCV_SVR_ATTR_INSTALLED_OPENED_LIMIT_LIFT = 0x0010, /**< InstalledOpenLimitLift */
    ZCL_WNCV_SVR_ATTR_INSTALLED_CLOSED_LIMIT_LIFT = 0x0011, /**< InstalledClosedLimitLift */
    ZCL_WNCV_SVR_ATTR_INSTALLED_OPENED_LIMIT_TILT = 0x0012, /**< InstalledOpenLimitTilt */
    ZCL_WNCV_SVR_ATTR_INSTALLED_CLOSED_LIMIT_TILT = 0x0013, /**< InstalledClosedLimitTilt */
    ZCL_WNCV_SVR_ATTR_VELOCITY_LIFT = 0x0014, /**< VelocityLift (Optional) */
    ZCL_WNCV_SVR_ATTR_ACCELERATION_TIME_LIFT = 0x0015, /**< AccelerationTimeLift (Optional) */
    ZCL_WNCV_SVR_ATTR_DECELERATION_TIME_LIFT = 0x0016, /**< DecelerationTimeLift (Optional) */
    ZCL_WNCV_SVR_ATTR_MODE = 0x0017, /**< Mode */
    ZCL_WNCV_SVR_ATTR_INTERMEDIATE_SETPOINTS_LIFT = 0x0018, /**< Intermediate Setpoints - Lift (Optional) */
    ZCL_WNCV_SVR_ATTR_INTERMEDIATE_SETPOINTS_TILT = 0x0019 /**< Intermediate Setpoints - Tilt (Optional) */
};

/** Window Covering Type enumerations */
enum ZbZclWncvTypes {
    ZCL_WNCV_TYPE_ROLLERSHADE = 0x00, /**< Rollershade */
    ZCL_WNCV_TYPE_ROLLERSHADE_2_MOTOR, /**< Rollershade - 2 Motor */
    ZCL_WNCV_TYPE_ROLLERSHADE_EXTERIOR, /**< Rollershade – Exterior */
    ZCL_WNCV_TYPE_ROLLERSHADE_EXTERIOR_2_MOTOR, /**< Rollershade - Exterior - 2 Motor */
    ZCL_WNCV_TYPE_DRAPERY, /**< Drapery */
    ZCL_WNCV_TYPE_AWNING, /**< Awning */
    ZCL_WNCV_TYPE_SHUTTER, /**< Shutter */
    ZCL_WNCV_TYPE_TILT_BLIND_TILT_ONLY, /**< Tilt Blind - Tilt Only */
    ZCL_WNCV_TYPE_TILT_BLIND_LIFT_TILT, /**< Tilt Blind - Lift and Tilt */
    ZCL_WNCV_TYPE_PROJECTOR_SCREEN /**< Projector Screen */
};

/* Window Covering Commands */
#define ZCL_WNCV_COMMAND_UP                      0x00
#define ZCL_WNCV_COMMAND_DOWN                    0x01
#define ZCL_WNCV_COMMAND_STOP                    0x02
#define ZCL_WNCV_COMMAND_GOTO_LIFT_VALUE         0x04
#define ZCL_WNCV_COMMAND_GOTO_LIFT_PERCENTAGE    0x05
#define ZCL_WNCV_COMMAND_GOTO_TILT_VALUE         0x07
#define ZCL_WNCV_COMMAND_GOTO_TILT_PERCENTAGE    0x08

/* Window Covering Config/Status Bit Mask */
#define ZCL_WNCV_STATUS_OPERATIONAL              0x01
#define ZCL_WNCV_STATUS_ONLINE                   0x02
#define ZCL_WNCV_STATUS_UP_REVERSED              0x04
#define ZCL_WNCV_STATUS_LIFT_CLOSED_LOOP         0x08
#define ZCL_WNCV_STATUS_TILT_CLOSED_LOOP         0x16
#define ZCL_WNCV_STATUS_LIFT_ENCODER             0x32
#define ZCL_WNCV_STATUS_TILT_ENCODER             0x64

/* Window Covering Mode Bit Mask */
#define ZCL_WNCV_MODE_REVERSED                   0x01
#define ZCL_WNCV_MODE_CALIBRATION                0x02
#define ZCL_WNCV_MODE_MAINTENANCE                0x04
#define ZCL_WNCV_MODE_LED_FEEDBACK               0x08

/* Window Covering Server */
/** Window Covering Server callbacks configuration */
struct ZbZclWindowServerCallbacksT {
    enum ZclStatusCodeT (*up_command)(struct ZbZclClusterT *cluster,
        struct ZbZclHeaderT *zclHdrPtr, struct ZbApsdeDataIndT *dataIndPtr, void *arg);
    /**< Callback to application, invoked on receipt of Up/Open command.
     * Application should update ZCL_WNCV_SVR_ATTR_CURR_POS_LIFT_PERCENT and ZCL_WNCV_SVR_ATTR_CURR_POS_TILT_PERCENT.
     */

    enum ZclStatusCodeT (*down_command)(struct ZbZclClusterT *cluster,
        struct ZbZclHeaderT *zclHdrPtr, struct ZbApsdeDataIndT *dataIndPtr, void *arg);
    /**< Callback to application, invoked on receipt of Down/Close command.
     * Application should update ZCL_WNCV_SVR_ATTR_CURR_POS_LIFT_PERCENT and ZCL_WNCV_SVR_ATTR_CURR_POS_TILT_PERCENT.
     */

    enum ZclStatusCodeT (*stop_command)(struct ZbZclClusterT *cluster,
        struct ZbZclHeaderT *zclHdrPtr, struct ZbApsdeDataIndT *dataIndPtr, void *arg);
    /**< Callback to application, invoked on receipt of Stop command.
     * Application should update ZCL_WNCV_SVR_ATTR_CURR_POS_LIFT_PERCENT and ZCL_WNCV_SVR_ATTR_CURR_POS_TILT_PERCENT.
     */

    enum ZclStatusCodeT (*set_lift_and_tilt_command)(struct ZbZclClusterT *cluster,
        void *arg, uint8_t liftPercentage, uint8_t tiltPercentage);
    /**< Callback to application, invoked to handle setting a Scene, which includes Lift and Tilt values.
     * Application should update ZCL_WNCV_SVR_ATTR_CURR_POS_LIFT_PERCENT and ZCL_WNCV_SVR_ATTR_CURR_POS_TILT_PERCENT.
     */
};

/**
 * Create a new instance of the Window Covering Server cluster
 * @param zb Zigbee stack instance
 * @param endpoint Endpoint on which to create cluster
 * @param callbacks Structure containing any callback function pointers for this cluster
 * @param arg Pointer to application data that will later be provided back to the callback functions when invoked
 * @return Cluster pointer, or NULL if there is an error
 */
struct ZbZclClusterT * ZbZclWindowServerAlloc(struct ZigBeeT *zb, uint8_t endpoint,
    struct ZbZclWindowServerCallbacksT *callbacks, void *arg);

/**
 * Configure the Window Covering mode
 * @param cluster Cluster instance from which to send this command
 * @param mode Window Covering mode bit mask
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclWindowClosureServerMode(struct ZbZclClusterT *cluster, uint8_t mode);

/* Window Covering Client */
/**
 * Create a new instance of the Window Covering Client cluster
 * @param zb Zigbee stack instance
 * @param endpoint Endpoint on which to create cluster
 * @return Cluster pointer, or NULL if there is an error
 */
struct ZbZclClusterT * ZbZclWindowClientAlloc(struct ZigBeeT *zb, uint8_t endpoint);

/**
 * Send an Up/Open command
 * @param cluster Cluster instance from which to send this command
 * @param dst The destination address information
 * @param callback Callback function that will be invoked later when the response is received
 * @param arg Pointer to application data that will later be provided back to the callback function when invoked
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclWindowClientCommandUp(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *dst,
    void (*callback)(struct ZbZclCommandRspT *zcl_rsp, void *arg), void *arg);

/**
 * Send a Down/Close command
 * @param cluster Cluster instance from which to send this command
 * @param dst The destination address information
 * @param callback Callback function that will be invoked later when the response is received
 * @param arg Pointer to application data that will later be provided back to the callback function when invoked
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclWindowClientCommandDown(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *dst,
    void (*callback)(struct ZbZclCommandRspT *zcl_rsp, void *arg), void *arg);

/**
 * Send a Stop command
 * @param cluster Cluster instance from which to send this command
 * @param dst The destination address information
 * @param callback Callback function that will be invoked later when the response is received
 * @param arg Pointer to application data that will later be provided back to the callback function when invoked
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclWindowClientCommandStop(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *dst,
    void (*callback)(struct ZbZclCommandRspT *zcl_rsp, void *arg), void *arg);

#endif