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

zcl.poll.control.h « general « 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: fa024c3a348e87e43c48d4009f782bb0062200dd (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
/**
 * @file zcl.poll.control.h
 * @heading Poll Control
 * @brief ZCL Poll Control cluster header
 * ZCL 7 section 3.16
 * ZCL 8 section 3.16
 * @copyright Copyright [2019 - 2021] Exegin Technologies Limited. All rights reserved.
 */

#ifndef ZCL_POLL_CONTROL_H
# define ZCL_POLL_CONTROL_H

/* @PICS.ZCL.Poll.Control
 * POLL.S | Server | True
 * POLL.C | Client | True
 *
 * Server Attributes
 * POLL.S.A0000 | Check-inInterval | True
 * POLL.S.A0001 | LongPollInterval | True
 * POLL.S.A0002 | ShortPollInterval | True
 * POLL.S.A0003 | FastPollTimeout | True
 * POLL.S.A0004 | Check-inIntervalMin | True | Optional
 * POLL.S.A0005 | LongPollIntervalMin | True | Optional
 * POLL.S.A0006 | FastPollTimeoutMax | True | Optional
 * POLL.S.AFFFD | ClusterRevision | True
 * POLL.S.AFFFE | AttributeReportingStatus | True
 *
 * Commands Received
 * POLL.S.C00.Rsp | Check-in Response | True
 * POLL.S.C01.Rsp | Fast Poll Stop | True
 * POLL.S.C02.Rsp | Set Long Poll Interval | True
 * POLL.S.C03.Rsp | Set Short Poll Interval | True
 *
 * Commands Generated
 * POLL.S.C00.Tx | Check-in | True
 *
 * Client Attributes
 * POLL.C.AFFFD | ClusterRevision | True
 * POLL.C.AFFFE | AttributeReportingStatus | True
 *
 * Commands Received
 * POLL.C.C00.Rsp | Check-in | True
 *
 * Commands Generated
 * POLL.C.C00.Tx | Check-in Response | True
 * POLL.C.C01.Tx | Fast Poll Stop | True
 * POLL.C.C02.Tx | Set Long Poll Interval | True
 * POLL.C.C03.Tx | Set Short Poll Interval | True
 */

#include "zcl/zcl.h"

/** Poll Control Server Attribute IDs */
enum ZbZclPollControlSvrAttrT {
    ZCL_POLL_CHECK_IN_INTERVAL = 0x0000, /**< Check-inInterval */
    ZCL_POLL_LONG_POLL_INTERVAL = 0x0001, /**< LongPollInterval */
    ZCL_POLL_SHORT_POLL_INTERVAL = 0x0002, /**< ShortPollInterval */
    ZCL_POLL_FAST_POLL_TIMEOUT = 0x0003, /**< FastPollTimeout */
    ZCL_POLL_CHECK_IN_INTERVAL_MIN = 0x0004, /**< Check-inIntervalMin (Optional) */
    ZCL_POLL_LONG_POLL_INTERVAL_MIN = 0x0005, /**< LongPollIntervalMin (Optional) */
    ZCL_POLL_FAST_POLL_TIMEOUT_MAX = 0x0006, /**< FastPollTimeoutMax (Optional) */

};

/* Client Generated Commands */
enum {
    ZCL_POLL_CTRL_CLI_CHECK_IN_RSP = 0x00, /* mandatory */
    ZCL_POLL_CTRL_CLI_FAST_POLL_STOP = 0x01, /* mandatory */
    ZCL_POLL_CTRL_CLI_SET_LONG_POLL_INTERVAL = 0x02,
    ZCL_POLL_CTRL_CLI_SET_SHOR_POLL_INTERVAL = 0x03
};

/* Server Generated Commands */
enum {
    ZCL_POLL_CTRL_SVR_CHECK_IN = 0x00 /* mandatory */
};

/** Check-in Response command structure */
struct zcl_poll_checkin_rsp_t {
    enum ZclStatusCodeT status; /**< Status */
    bool start_fast_poll; /**< Start Fast Polling */
    uint16_t fast_poll_timeout; /**< Fast Poll Timeout */
};

/*---------------------------------------------------------------
 * Server API
 *---------------------------------------------------------------
 */

/** Poll Control Server callbacks configuration */
struct ZbZclPollControlServerCallbackT {
    void (*checkin_rsp)(struct ZbZclClusterT *clusterPtr,
        struct zcl_poll_checkin_rsp_t *rsp_info, struct ZbZclAddrInfoT *srcInfo, void *arg);
    /**< Callback to application, invoked on receipt of Check-in Response command */
};

/**
 * Create a new instance of the Poll Control 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 * zcl_poll_server_alloc(struct ZigBeeT *zb, uint8_t endpoint,
    struct ZbZclPollControlServerCallbackT *callbacks, void *arg);

/**
 * Send a Check-in command to any bound Clients.
 * @param cluster Cluster instance from which to send this command
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT zcl_poll_server_send_checkin(struct ZbZclClusterT *cluster);

/**
 * Change the long polling interval. Default is disabled (ZCL_INVALID_UNSIGNED_32BIT = 0xffffffff).
 * @param clusterPtr Cluster instance from which to send this command
 * @param long_poll_intvl Polling interval in quarter-seconds (1 = 250 mS)
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT zcl_poll_server_write_long_poll_intvl(struct ZbZclClusterT *clusterPtr,
    uint32_t long_poll_intvl);

/*---------------------------------------------------------------
 * Client API
 *---------------------------------------------------------------
 */

/** Check-in Info structure */
struct ZbZclPollControlClientCheckinInfo {
    struct ZbApsAddrT dst; /**< Destination Address */
    bool start_fast_poll; /**< Start Fast Poll */
    uint16_t fast_poll_timeout; /**< Fast Poll Timeout */
};

/** Fast Poll Stop command structure */
struct ZbZclPollControlClientStopReq {
    struct ZbApsAddrT dst; /**< Destination Address */
};

/** Set Long Poll Interval command structure */
struct ZbZclPollControlClientSetLongReq {
    struct ZbApsAddrT dst; /**< Destination Address */
    uint32_t interval; /**< NewLongPollInterval */
};

/** Set Short Poll Interval command structure */
struct ZbZclPollControlClientSetShortReq {
    struct ZbApsAddrT dst; /**< Destination Address */
    uint16_t interval; /**< New Short Poll Interval */
};

/** Poll Control Client callbacks configuration */
struct ZbZclPollControlClientCallbackT {
    /* Callback limitation note:
     * If timeout returned to the callback is zero, that means that the server is fast polling
     * for the amount of time it's fast poll timeout attribute is set to.
     *
     * We can only assume that the server is fast polling if the default response status is
     * success, since there is no way for the client to know if the server is actually fast
     * polling from the check-in response due to various reasons (i.e. already fast polling,
     * fails to start fast poll after sending the default response, or stopped fast polling).
     *
     * If the polling boolean is false, there is a chance that the server is fast polling
     * still. This could be due to other Poll Clients the server is bound to.
     * */
    enum ZclStatusCodeT (*checkin_rsp_callback)(struct ZbZclClusterT *clusterPtr,
        struct zcl_poll_checkin_rsp_t *rsp_info, struct ZbZclAddrInfoT *srcInfo, void *arg);
    /**< Callback to application, invoked on receipt of Check-in Response command */
};

/**
 * Create a new instance of the Poll Control Client 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 * zcl_poll_client_alloc(struct ZigBeeT *zb, uint8_t endpoint,
    struct ZbZclPollControlClientCallbackT *callbacks, void *arg);

/**
 * Set Check-in Response configuration
 * @param cluster Cluster instance from which to send this command
 * @param info Check-in configuration info
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT zcl_poll_client_set_checkin_rsp(struct ZbZclClusterT *cluster,
    struct ZbZclPollControlClientCheckinInfo *info);

/**
 * Send a Fast Poll Stop command
 * @param cluster Cluster instance from which to send this command
 * @param req Fast Poll Stop command request structure
 * @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 zcl_poll_client_stop_fastpoll_req(struct ZbZclClusterT *cluster,
    struct ZbZclPollControlClientStopReq *req,
    void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

/**
 * Send a Set Long Interval command
 * @param cluster Cluster instance from which to send this command
 * @param req Set Long Interval command request structure
 * @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 zcl_poll_client_set_long_intvl_req(struct ZbZclClusterT *cluster,
    struct ZbZclPollControlClientSetLongReq *req,
    void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

/**
 * Send a Set Short Interval command
 * @param cluster Cluster instance from which to send this command
 * @param req Set Short Interval command request structure
 * @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 zcl_poll_client_set_short_intvl_req(struct ZbZclClusterT *cluster,
    struct ZbZclPollControlClientSetShortReq *req,
    void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

#endif /* ZCL_POLL_CONTROL_H */