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

zcl.alarm.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: ef340c0e70a0fbb8a60a08f525e76cb9ae61db6b (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
/**
 * @file zcl.alarm.h
 * @heading Alarms
 * @brief ZCL Alarms cluster header
 * ZCL 7 section 3.11
 * ZCL 8 section 3.11
 * @copyright Copyright [2009 - 2020] Exegin Technologies Limited. All rights reserved.
 */

#ifndef ZCL_ALARM_H
# define ZCL_ALARM_H

/*--------------------------------------------------------------------------
 *  DESCRIPTION
 *      Interface definition for the ZCL Alarms cluster
 *--------------------------------------------------------------------------
 */

/* @PICS.ZCL.Alarm
 * ALM.S | Server | True
 * ALM.C | Client | True
 *
 * Server Attributes
 * ALM.S.A0000 | AlarmCount | True | Optional
 * ALM.S.Afffd | ClusterRevision | True
 * ALM.S.Afffe | AttributeReportingStatus | False
 *
 * Commands Received
 * ALM.S.C00.Rsp | Reset Alarm | True
 * ALM.S.C01.Rsp | Reset all alarms | True
 * ALM.S.C02.Rsp | Get Alarm | True
 * ALM.S.C03.Rsp | Reset alarm log | True
 *
 * Commands Generated
 * ALM.S.C00.Tx | Alarm | True
 * ALM.S.C01.Tx | Get alarm response | True
 *
 * Client Attributes
 * ALM.C.Afffd | ClusterRevision | True
 * ALM.C.Afffe | AttributeReportingStatus | False
 *
 * Commands Received
 * ALM.C.C00.Rsp | Alarm | True
 * ALM.C.C01.Rsp | Get alarm response | True
 *
 * Commands Generated
 * ALM.C.C00.Tx | Reset Alarm | True
 * ALM.C.C01.Tx | Reset all alarms | True
 * ALM.C.C02.Tx | Get Alarm | True
 * ALM.C.C03.Tx | Reset alarm log | True
 */

#include "zcl/zcl.h"

/*---------------------------------------------------------------
 * Definitions
 *---------------------------------------------------------------
 */

/** Alarms Attribute IDs */
enum ZbZclAlarmsAttrT {
    ZCL_ALARM_ATTR_COUNT = 0x0000 /**< AlarmCount (Optional) */
};

/* Alarms cluster client commands */
enum {
    ZCL_ALARM_COMMAND_RESET = 0x00,
    ZCL_ALARM_COMMAND_RESET_ALL,
    ZCL_ALARM_COMMAND_GET,
    ZCL_ALARM_COMMAND_RESET_LOG
};

/* Alarms cluster server commands */
enum {
    ZCL_ALARM_COMMAND_ALARM = 0x00,
    ZCL_ALARM_COMMAND_GET_RESPONSE
};

/*---------------------------------------------------------------
 * Structures
 *---------------------------------------------------------------
 */

/**
 * Callback when an alarm is received
 * @param arg Pointer to application data as provided previously at the time the pointer to this callback function was provided in
 *  initiating API call
 * @param nwk_addr Short address where the alarm originates
 * @param endpoint Endpoint where the alarm originates
 * @param alarm_code Code of the detected alarm condition
 * @param cluster_id ID of cluster where alarm condition occurred
 * @return Returns void
 */
typedef void (*ZbZclAlarmClientCallbackT)(void *arg, uint16_t nwk_addr, uint8_t endpoint,
    uint8_t alarm_code, uint16_t cluster_id);

/*---------------------------------------------------------------
 * Function Declarations
 *---------------------------------------------------------------
 */

/*
 * Server Commands
 */

/**
 * Create a new instance of the Alarms Server cluster
 * @param zb Zigbee stack instance
 * @param endpoint Endpoint on which to create cluster
 * @param logSize Alarm log size
 * @param time_server Time Server cluster instance
 * @return Cluster pointer, or NULL if there is an error
 */
struct ZbZclClusterT * ZbZclAlarmServerAlloc(struct ZigBeeT *zb, uint8_t endpoint,
    uint16_t logSize, struct ZbZclClusterT *time_server);

/*
 * Client Commands
 */

/**
 * Create a new instance of the Alarms Client cluster
 * @param zb Zigbee stack instance
 * @param endpoint Endpoint on which to create cluster
 * @param callback Callback function that will be invoked later when an alarm occurs
 * @param arg Pointer to application data that will later be provided back to the callback function when it is invoked
 * @return Cluster pointer, or NULL if there is an error
 */
struct ZbZclClusterT * ZbZclAlarmClientAlloc(struct ZigBeeT *zb, uint8_t endpoint, ZbZclAlarmClientCallbackT callback, void *arg);

/*uint8_t ZbZclAlarmClientBind(struct ZbZclClusterT *clusterPtr, uint16_t nwkAddr, uint8_t endpoint);
uint8_t ZbZclAlarmClientBindDiscover(struct ZbZclClusterT *clusterPtr);
*/

/**
 * Send a Reset Alarm command
 * @param cluster Cluster instance from which to send this command
 * @param dst Destination address for request
 * @param alarm_code Code of the detected alarm condition
 * @param cluster_id ID of cluster where alarm condition occurred
 * @param callback Callback function that will be invoked later when response is received
 * @param arg Pointer to application data that will later be provided back to the callback function when it is invoked
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclAlarmClientResetAlarmReq(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *dst,
    uint8_t alarm_code, uint16_t cluster_id, void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

/**
 * Send a Reset All Alarms command
 * @param cluster Cluster instance from which to send this command
 * @param dst Destination address for request
 * @param callback Callback function that will be invoked later when response is received
 * @param arg Pointer to application data that will later be provided back to the callback function when it is invoked
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclAlarmClientResetAllAlarmsReq(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *dst,
    void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

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

/**
 * Send a Reset Alarm Log command
 * @param cluster Cluster instance from which to send this command
 * @param dst Destination address for request
 * @param callback Callback function that will be invoked later when response is received
 * @param arg Pointer to application data that will later be provided back to the callback function when it is invoked
 * @return ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error
 */
enum ZclStatusCodeT ZbZclAlarmClientResetAlarmLogReq(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *dst,
    void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

#endif /* __ZCL_ALARM_H */