@@ -146,7 +146,7 @@ DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)];
146
146
#define ZCL_ON_OFF_CLUSTER_REVISION (4u )
147
147
148
148
int AddDeviceEndpoint (Device * dev, EmberAfEndpointType * ep, const Span<const EmberAfDeviceType> & deviceTypeList,
149
- const Span<DataVersion> & dataVersionStorage)
149
+ const Span<DataVersion> & dataVersionStorage, chip::EndpointId parentEndpointId )
150
150
{
151
151
uint8_t index = 0 ;
152
152
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
@@ -158,7 +158,7 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
158
158
while (1 )
159
159
{
160
160
dev->SetEndpointId (gCurrentEndpointId );
161
- ret = emberAfSetDynamicEndpoint (index , gCurrentEndpointId , ep, dataVersionStorage, deviceTypeList);
161
+ ret = emberAfSetDynamicEndpoint (index , gCurrentEndpointId , ep, dataVersionStorage, deviceTypeList, parentEndpointId );
162
162
if (ret == EMBER_ZCL_STATUS_SUCCESS)
163
163
{
164
164
ChipLogProgress (DeviceLayer, " Added device %s to dynamic endpoint %d (index=%d)" , dev->GetName (),
@@ -337,8 +337,8 @@ bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj
337
337
return true ;
338
338
}
339
339
340
- const EmberAfDeviceType gBridgedRootDeviceTypes [] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT },
341
- { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } };
340
+ const EmberAfDeviceType gRootDeviceTypes [] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT } };
341
+ const EmberAfDeviceType gAggregateNodeDeviceTypes [] = { { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } };
342
342
343
343
const EmberAfDeviceType gBridgedOnOffDeviceTypes [] = { { DEVICE_TYPE_LO_ON_OFF_LIGHT, DEVICE_VERSION_DEFAULT },
344
344
{ DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } };
@@ -357,30 +357,28 @@ static void InitServer(intptr_t context)
357
357
// supported clusters so that ZAP will generated the requisite code.
358
358
emberAfEndpointEnableDisable (emberAfEndpointFromIndex (static_cast <uint16_t >(emberAfFixedEndpointCount () - 1 )), false );
359
359
360
- //
361
- // By default, ZAP only supports specifying a single device type in the UI. However for bridges, they are both
362
- // a Bridge and Matter Root Node device on EP0. Consequently, over-ride the generated value to correct this.
363
- //
364
- emberAfSetDeviceTypeList (0 , Span<const EmberAfDeviceType>(gBridgedRootDeviceTypes ));
360
+ // A bridge has root node device type on EP0 and aggregate node device type (bridge) at EP1
361
+ emberAfSetDeviceTypeList (0 , Span<const EmberAfDeviceType>(gRootDeviceTypes ));
362
+ emberAfSetDeviceTypeList (1 , Span<const EmberAfDeviceType>(gAggregateNodeDeviceTypes ));
365
363
366
- // Add lights 1..3 --> will be mapped to ZCL endpoints 2, 3, 4
364
+ // Add lights 1..3 --> will be mapped to ZCL endpoints 3, 4, 5
367
365
AddDeviceEndpoint (&gLight1 , &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes ),
368
- Span<DataVersion>(gLight1DataVersions ));
366
+ Span<DataVersion>(gLight1DataVersions ), 1 );
369
367
AddDeviceEndpoint (&gLight2 , &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes ),
370
- Span<DataVersion>(gLight2DataVersions ));
368
+ Span<DataVersion>(gLight2DataVersions ), 1 );
371
369
AddDeviceEndpoint (&gLight3 , &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes ),
372
- Span<DataVersion>(gLight3DataVersions ));
370
+ Span<DataVersion>(gLight3DataVersions ), 1 );
373
371
374
- // Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 2 & 4
372
+ // Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 3 & 5
375
373
RemoveDeviceEndpoint (&gLight2 );
376
374
377
- // Add Light 4 -- > will be mapped to ZCL endpoint 5
375
+ // Add Light 4 -- > will be mapped to ZCL endpoint 6
378
376
AddDeviceEndpoint (&gLight4 , &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes ),
379
- Span<DataVersion>(gLight4DataVersions ));
377
+ Span<DataVersion>(gLight4DataVersions ), 1 );
380
378
381
- // Re-add Light 2 -- > will be mapped to ZCL endpoint 6
379
+ // Re-add Light 2 -- > will be mapped to ZCL endpoint 7
382
380
AddDeviceEndpoint (&gLight2 , &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes ),
383
- Span<DataVersion>(gLight2DataVersions ));
381
+ Span<DataVersion>(gLight2DataVersions ), 1 );
384
382
}
385
383
386
384
extern " C" void app_main ()
0 commit comments