@@ -85,6 +85,105 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
85
85
}
86
86
} /* root_node */
87
87
88
+ namespace ota_requestor {
89
+ uint32_t get_device_type_id ()
90
+ {
91
+ return ESP_MATTER_OTA_REQUESTOR_DEVICE_TYPE_ID;
92
+ }
93
+
94
+ uint8_t get_device_type_version ()
95
+ {
96
+ return ESP_MATTER_OTA_REQUESTOR_DEVICE_TYPE_VERSION;
97
+ }
98
+
99
+ endpoint_t *create (node_t *node, config_t *config, uint8_t flags, void *priv_data)
100
+ {
101
+ #ifdef CONFIG_ENABLE_OTA_REQUESTOR
102
+ endpoint_t *endpoint = endpoint::create (node, flags, priv_data);
103
+ add (endpoint, config);
104
+ return endpoint;
105
+ #else
106
+ ESP_LOGE (TAG, " Need enable CONFIG_ENABLE_OTA_REQUESTOR to enable ota requestor function" );
107
+ return nullptr ;
108
+ #endif
109
+ }
110
+
111
+ esp_err_t add (endpoint_t *endpoint, config_t *config)
112
+ {
113
+ #ifdef CONFIG_ENABLE_OTA_REQUESTOR
114
+ if (!endpoint) {
115
+ ESP_LOGE (TAG, " Endpoint cannot be NULL" );
116
+ return ESP_ERR_INVALID_ARG;
117
+ }
118
+ esp_err_t err = add_device_type (endpoint, get_device_type_id (), get_device_type_version ());
119
+ if (err != ESP_OK) {
120
+ ESP_LOGE (TAG, " Failed to add device type id:%" PRIu32 " ,err: %d" , get_device_type_id (), err);
121
+ return err;
122
+ }
123
+
124
+ cluster_t *cluster = descriptor::create (endpoint, &(config->descriptor ), CLUSTER_FLAG_SERVER);
125
+ if (!cluster) {
126
+ return ESP_ERR_INVALID_STATE;
127
+ }
128
+ cluster_t *cluster_p = cluster::ota_provider::create (endpoint, NULL , CLUSTER_FLAG_CLIENT);
129
+ cluster_t *cluster_r = cluster::ota_requestor::create (endpoint, &(config->ota_requestor ), CLUSTER_FLAG_SERVER);
130
+ if (!cluster_p || !cluster_r) {
131
+ return ESP_FAIL;
132
+ }
133
+
134
+ return ESP_OK;
135
+ #else
136
+ ESP_LOGE (TAG, " Need enable CONFIG_ENABLE_OTA_REQUESTOR to enable ota requestor function" );
137
+ return ESP_FAIL;
138
+ #endif
139
+ }
140
+
141
+ } /* * ota_requestor **/
142
+
143
+ namespace ota_provider {
144
+ uint32_t get_device_type_id ()
145
+ {
146
+ return ESP_MATTER_OTA_PROVIDER_DEVICE_TYPE_ID;
147
+ }
148
+
149
+ uint8_t get_device_type_version ()
150
+ {
151
+ return ESP_MATTER_OTA_PROVIDER_DEVICE_TYPE_VERSION;
152
+ }
153
+
154
+ endpoint_t *create (node_t *node, config_t *config, uint8_t flags, void *priv_data)
155
+ {
156
+ endpoint_t *endpoint = endpoint::create (node, flags, priv_data);
157
+ add (endpoint, config);
158
+ return endpoint;
159
+ }
160
+
161
+ esp_err_t add (endpoint_t *endpoint, config_t *config)
162
+ {
163
+ if (!endpoint) {
164
+ ESP_LOGE (TAG, " Endpoint cannot be NULL" );
165
+ return ESP_ERR_INVALID_ARG;
166
+ }
167
+ esp_err_t err = add_device_type (endpoint, get_device_type_id (), get_device_type_version ());
168
+ if (err != ESP_OK) {
169
+ ESP_LOGE (TAG, " Failed to add device type id:%" PRIu32 " ,err: %d" , get_device_type_id (), err);
170
+ return err;
171
+ }
172
+
173
+ cluster_t *cluster = descriptor::create (endpoint, &(config->descriptor ), CLUSTER_FLAG_SERVER);
174
+ if (!cluster) {
175
+ return ESP_ERR_INVALID_STATE;
176
+ }
177
+ cluster = cluster::ota_provider::create (endpoint, &(config->ota_provider ), CLUSTER_FLAG_SERVER);
178
+ if (!cluster) {
179
+ return ESP_FAIL;
180
+ }
181
+
182
+ return ESP_OK;
183
+ }
184
+
185
+ } /* * ota_provider **/
186
+
88
187
namespace power_source_device {
89
188
uint32_t get_device_type_id ()
90
189
{
0 commit comments