15
15
* See the License for the specific language governing permissions and
16
16
* limitations under the License.
17
17
*/
18
+
19
+ #include " AccessControl.h"
20
+
18
21
#include < access/SubjectDescriptor.h>
19
22
#include < app-common/zap-generated/callback.h>
20
23
#include < app-common/zap-generated/cluster-objects.h>
@@ -52,10 +55,6 @@ using namespace chip::app::Clusters;
52
55
53
56
namespace {
54
57
55
- // TODO: Maybe consider making this configurable? See also
56
- // AccessControl.cpp.
57
- constexpr EndpointId kSupportedEndpoint = 0 ;
58
-
59
58
DataVersion gMockDataVersion = 0 ;
60
59
61
60
} // anonymous namespace
@@ -118,15 +117,18 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aPath, TLV::TLVRea
118
117
} // namespace chip
119
118
120
119
/* *
121
- * Called by the OTA provider cluster server to determine an index
122
- * into its array.
120
+ * Returns the index of the given endpoint in the list of all endpoints that might support the given cluster server.
123
121
*/
124
122
uint16_t emberAfGetClusterServerEndpointIndex (EndpointId endpoint, ClusterId cluster, uint16_t fixedClusterServerEndpointCount)
125
123
{
126
- if (endpoint == kSupportedEndpoint && cluster == OtaSoftwareUpdateProvider::Id)
124
+ if (endpoint == kOtaProviderDynamicEndpointId && cluster == OtaSoftwareUpdateProvider::Id)
127
125
{
128
126
return 0 ;
129
127
}
128
+ else if (endpoint == kWebRTCRequesterDynamicEndpointId && cluster == WebRTCTransportRequestor::Id)
129
+ {
130
+ return 1 ;
131
+ }
130
132
131
133
return UINT16_MAX;
132
134
}
@@ -145,31 +147,47 @@ uint16_t emberAfGetServerAttributeCount(EndpointId endpoint, ClusterId cluster)
145
147
146
148
uint16_t emberAfEndpointCount (void )
147
149
{
148
- return 1 ;
150
+ return 2 ;
149
151
}
150
152
151
153
uint16_t emberAfIndexFromEndpoint (EndpointId endpoint)
152
154
{
153
- if (endpoint == kSupportedEndpoint )
155
+ if (endpoint == kOtaProviderDynamicEndpointId )
154
156
{
155
157
return 0 ;
156
158
}
159
+ else if (endpoint == kWebRTCRequesterDynamicEndpointId )
160
+ {
161
+ return 1 ;
162
+ }
157
163
158
164
return UINT16_MAX;
159
165
}
160
166
161
167
EndpointId emberAfEndpointFromIndex (uint16_t index)
162
168
{
163
- // Index must be valid here, so 0.
164
- return kSupportedEndpoint ;
169
+ if (index == 0 )
170
+ {
171
+ return kOtaProviderDynamicEndpointId ;
172
+ }
173
+ else if (index == 1 )
174
+ {
175
+ return kWebRTCRequesterDynamicEndpointId ;
176
+ }
177
+
178
+ return UINT16_MAX;
165
179
}
166
180
167
181
Optional<ClusterId> emberAfGetNthClusterId (EndpointId endpoint, uint8_t n, bool server)
168
182
{
169
- if (endpoint == kSupportedEndpoint && n == 0 && server)
183
+ if (endpoint == kOtaProviderDynamicEndpointId && n == 0 && server)
170
184
{
171
185
return MakeOptional (OtaSoftwareUpdateProvider::Id);
172
186
}
187
+ else if (endpoint == kWebRTCRequesterDynamicEndpointId && n == 0 && server)
188
+ {
189
+ return MakeOptional (WebRTCTransportRequestor::Id);
190
+ }
173
191
174
192
return NullOptional;
175
193
}
@@ -186,7 +204,12 @@ bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId cluster
186
204
187
205
uint8_t emberAfClusterCount (EndpointId endpoint, bool server)
188
206
{
189
- if (endpoint == kSupportedEndpoint && server)
207
+ if (endpoint == kOtaProviderDynamicEndpointId && server)
208
+ {
209
+ return 1 ;
210
+ }
211
+
212
+ if (endpoint == kWebRTCRequesterDynamicEndpointId && server)
190
213
{
191
214
return 1 ;
192
215
}
@@ -209,7 +232,14 @@ Optional<AttributeId> emberAfGetServerAttributeIdByIndex(EndpointId endpoint, Cl
209
232
210
233
uint8_t emberAfClusterIndex (EndpointId endpoint, ClusterId clusterId, EmberAfClusterMask mask)
211
234
{
212
- if (endpoint == kSupportedEndpoint && clusterId == OtaSoftwareUpdateProvider::Id && (mask & MATTER_CLUSTER_FLAG_SERVER))
235
+ if (endpoint == kOtaProviderDynamicEndpointId && clusterId == OtaSoftwareUpdateProvider::Id &&
236
+ (mask & MATTER_CLUSTER_FLAG_SERVER))
237
+ {
238
+ return 0 ;
239
+ }
240
+
241
+ if (endpoint == kWebRTCRequesterDynamicEndpointId && clusterId == WebRTCTransportRequestor::Id &&
242
+ (mask & MATTER_CLUSTER_FLAG_SERVER))
213
243
{
214
244
return 0 ;
215
245
}
@@ -223,43 +253,81 @@ bool emberAfEndpointIndexIsEnabled(uint16_t index)
223
253
}
224
254
225
255
namespace {
226
- const CommandId acceptedCommands[] = { Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::Id,
227
- Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id,
228
- Clusters::OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, kInvalidCommandId };
229
- const CommandId generatedCommands[] = { Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Id,
230
- Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::Id, kInvalidCommandId };
256
+
257
+ const CommandId acceptedOtaProviderCommands[] = { Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::Id,
258
+ Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id,
259
+ Clusters::OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id,
260
+ kInvalidCommandId };
261
+
262
+ const CommandId generatedOtaProviderCommands[] = { Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Id,
263
+ Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::Id,
264
+ kInvalidCommandId };
265
+
231
266
const EmberAfCluster otaProviderCluster{
232
267
.clusterId = Clusters::OtaSoftwareUpdateProvider::Id,
233
268
.attributes = nullptr ,
234
269
.attributeCount = 0 ,
235
270
.clusterSize = 0 ,
236
271
.mask = MATTER_CLUSTER_FLAG_SERVER,
237
272
.functions = nullptr ,
238
- .acceptedCommandList = acceptedCommands ,
239
- .generatedCommandList = generatedCommands ,
273
+ .acceptedCommandList = acceptedOtaProviderCommands ,
274
+ .generatedCommandList = generatedOtaProviderCommands ,
240
275
.eventList = nullptr ,
241
276
.eventCount = 0 ,
242
277
};
278
+
243
279
const EmberAfEndpointType otaProviderEndpoint{ .cluster = &otaProviderCluster, .clusterCount = 1 , .endpointSize = 0 };
280
+
281
+ const CommandId acceptedWebRTCRequestorCommands[] = { Clusters::WebRTCTransportRequestor::Commands::Offer::Id,
282
+ Clusters::WebRTCTransportRequestor::Commands::Answer::Id,
283
+ Clusters::WebRTCTransportRequestor::Commands::ICECandidates::Id,
284
+ Clusters::WebRTCTransportRequestor::Commands::End::Id, kInvalidCommandId };
285
+
286
+ const CommandId generatedWebRTCRequestorCommands[] = { kInvalidCommandId };
287
+
288
+ const EmberAfCluster webRTCReqeustorCluster{
289
+ .clusterId = Clusters::WebRTCTransportRequestor::Id,
290
+ .attributes = nullptr ,
291
+ .attributeCount = 0 ,
292
+ .clusterSize = 0 ,
293
+ .mask = MATTER_CLUSTER_FLAG_SERVER,
294
+ .functions = nullptr ,
295
+ .acceptedCommandList = acceptedWebRTCRequestorCommands,
296
+ .generatedCommandList = generatedWebRTCRequestorCommands,
297
+ .eventList = nullptr ,
298
+ .eventCount = 0 ,
299
+ };
300
+
301
+ const EmberAfEndpointType webRTCRequestorEndpoint{ .cluster = &webRTCReqeustorCluster, .clusterCount = 1 , .endpointSize = 0 };
302
+
244
303
} // namespace
245
304
246
305
const EmberAfEndpointType * emberAfFindEndpointType (EndpointId endpoint)
247
306
{
248
- if (endpoint == kSupportedEndpoint )
307
+ if (endpoint == kOtaProviderDynamicEndpointId )
249
308
{
250
309
return &otaProviderEndpoint;
251
310
}
311
+ else if (endpoint == kWebRTCRequesterDynamicEndpointId )
312
+ {
313
+ return &webRTCRequestorEndpoint;
314
+ }
252
315
253
316
return nullptr ;
254
317
}
255
318
256
319
const EmberAfCluster * emberAfFindServerCluster (EndpointId endpoint, ClusterId cluster)
257
320
{
258
- if (endpoint == kSupportedEndpoint && cluster == Clusters::OtaSoftwareUpdateProvider::Id)
321
+ if (endpoint == kOtaProviderDynamicEndpointId && cluster == Clusters::OtaSoftwareUpdateProvider::Id)
259
322
{
260
323
return &otaProviderCluster;
261
324
}
262
325
326
+ if (endpoint == kWebRTCRequesterDynamicEndpointId && cluster == Clusters::WebRTCTransportRequestor::Id)
327
+ {
328
+ return &webRTCReqeustorCluster;
329
+ }
330
+
263
331
return nullptr ;
264
332
}
265
333
@@ -341,6 +409,11 @@ const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endp
341
409
return &otaProviderCluster;
342
410
}
343
411
412
+ if ((endpointType == &webRTCRequestorEndpoint) && (clusterId == Clusters::WebRTCTransportRequestor::Id))
413
+ {
414
+ return &webRTCReqeustorCluster;
415
+ }
416
+
344
417
return nullptr ;
345
418
}
346
419
0 commit comments