3 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * Copyright (c) 2020 Silicon Labs
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
26 * http://www.apache.org/licenses/LICENSE-2.0
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 /****************************************************************************
36 * @brief This is the source for the plugin used to
37 *add an IAS Zone cluster server to a project. This
38 *source handles zone enrollment and storing of
39 * attributes from a CIE device and provides an API
40 *for different plugins to post updated zone status
42 *******************************************************************************
43 ******************************************************************************/
47 #include <app/util/af-types.h>
49 #define EM_AF_UNKNOWN_ENDPOINT 0
50 // Absolute max backoff time, at least one retry a day
51 // (ie. 24 hours * 60 minutes * 60 seconds).
52 #define IAS_ZONE_STATUS_QUEUE_RETRY_ABS_MAX_BACKOFF_TIME_SEC (24 * 60 * 60)
54 // Definitions for the IAS Zone enrollment mode.
57 EMBER_ZCL_IAS_ZONE_ENROLLMENT_MODE_TRIP_TO_PAIR = 0x00,
58 EMBER_ZCL_IAS_ZONE_ENROLLMENT_MODE_AUTO_ENROLLMENT_RESPONSE = 0x01,
59 EMBER_ZCL_IAS_ZONE_ENROLLMENT_MODE_REQUEST = 0x02
60 } EmberAfIasZoneEnrollmentMode;
62 // Status queue retry parameters
65 uint8_t firstBackoffTimeSec;
66 uint8_t backoffSeqCommonRatio;
67 uint32_t maxBackoffTimeSec;
68 bool unlimitedRetries;
69 uint8_t maxRetryAttempts;
70 } IasZoneStatusQueueRetryConfig;
72 /** @brief Updates the zone status for an endpoint.
74 * This function will update the zone status attribute of the specified endpoint
75 * using the specified new zone status. It will then notify the CIE of the
78 * @param endpoint The endpoint whose zone status attribute is to be updated.
79 * @param newStatus The new status to write to the attribute.
80 * @param timeSinceStatusOccurredQs The amount of time (in quarter seconds) that
81 * has passed since the status change occurred.
83 * @return EMBER_SUCCESS if the attribute update and notify succeeded, error
86 EmberStatus emberAfPluginIasZoneServerUpdateZoneStatus(chip::EndpointId endpoint, uint16_t newStatus,
87 uint16_t timeSinceStatusOccurredQs);
89 /** @brief Gets the CIE assigned zone id of a given endpoint.
91 * This function will return the zone ID that was assigned to the given
92 * endpoint by the CIE at time of enrollment.
94 * @param endpoint The endpoint whose ID is to be queried.
96 * @return The zone ID assigned by the CIE at time of enrollment.
98 uint8_t emberAfPluginIasZoneServerGetZoneId(chip::EndpointId endpoint);
100 /** @brief Determines the enrollment status of a given endpoint.
102 * This function will return true or false depending on whether the specified
103 * endpoint has undergone IAS Zone Enrollment.
105 * @param endpoint The endpoint whose enrollment status is to be queried.
107 * @return True if enrolled, false otherwise.
109 bool emberAfIasZoneClusterAmIEnrolled(chip::EndpointId endpoint);
111 /** @brief Set the enrollment status.
113 * This function will return the status of the set enrollment method attempt.
115 * @param endpoint The endpoint whose enrollment method is to be set
116 * @param method The enrollment method that should be set
118 * @return An ::EmberAfStatus value indicating the status of the set action.
120 EmberAfStatus emberAfPluginIasZoneClusterSetEnrollmentMethod(chip::EndpointId endpoint, EmberAfIasZoneEnrollmentMode method);
122 /** @brief Configure the retry parameters of the status queue.
124 * This function will configure the status queue retry parameters.
126 * @param retryConfig Status queue retry configuration.
128 EmberStatus emberAfIasZoneServerConfigStatusQueueRetryParams(IasZoneStatusQueueRetryConfig * retryConfig);
130 /** @brief Set the retry parameters of the status queue to default.
132 * This function will set the status queue retry parameters to their default values.
134 void emberAfIasZoneServerSetStatusQueueRetryParamsToDefault(void);
136 /** @brief Discards any pendint events in the status queue and sets it inactive.
138 * This function will discard any pending event pending in the status queue.
139 * Also, the status queue event control manager will be inactivated.
141 void emberAfIasZoneServerDiscardPendingEventsInStatusQueue(void);
143 /** @brief Prints information on the satus queue.
145 void emberAfPluginIasZoneServerPrintQueue(void);
147 /** @brief Prints the satus queue config.
149 void emberAfPluginIasZoneServerPrintQueueConfig(void);