diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 5f3a3de202a380..b5602aa5a00a6a 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -146,7 +146,7 @@ DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)]; #define ZCL_ON_OFF_CLUSTER_REVISION (4u) int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span & deviceTypeList, - const Span & dataVersionStorage) + const Span & dataVersionStorage, chip::EndpointId parentEndpointId) { uint8_t index = 0; while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) @@ -158,7 +158,8 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const SpanSetEndpointId(gCurrentEndpointId); - ret = emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList); + ret = + emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId); if (ret == EMBER_ZCL_STATUS_SUCCESS) { ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(), @@ -337,8 +338,8 @@ bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj return true; } -const EmberAfDeviceType gBridgedRootDeviceTypes[] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT }, - { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } }; +const EmberAfDeviceType gRootDeviceTypes[] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT } }; +const EmberAfDeviceType gAggregateNodeDeviceTypes[] = { { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } }; const EmberAfDeviceType gBridgedOnOffDeviceTypes[] = { { DEVICE_TYPE_LO_ON_OFF_LIGHT, DEVICE_VERSION_DEFAULT }, { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } }; @@ -357,30 +358,28 @@ static void InitServer(intptr_t context) // supported clusters so that ZAP will generated the requisite code. emberAfEndpointEnableDisable(emberAfEndpointFromIndex(static_cast(emberAfFixedEndpointCount() - 1)), false); - // - // By default, ZAP only supports specifying a single device type in the UI. However for bridges, they are both - // a Bridge and Matter Root Node device on EP0. Consequently, over-ride the generated value to correct this. - // - emberAfSetDeviceTypeList(0, Span(gBridgedRootDeviceTypes)); + // A bridge has root node device type on EP0 and aggregate node device type (bridge) at EP1 + emberAfSetDeviceTypeList(0, Span(gRootDeviceTypes)); + emberAfSetDeviceTypeList(1, Span(gAggregateNodeDeviceTypes)); - // Add lights 1..3 --> will be mapped to ZCL endpoints 2, 3, 4 + // Add lights 1..3 --> will be mapped to ZCL endpoints 3, 4, 5 AddDeviceEndpoint(&gLight1, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), - Span(gLight1DataVersions)); + Span(gLight1DataVersions), 1); AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), - Span(gLight2DataVersions)); + Span(gLight2DataVersions), 1); AddDeviceEndpoint(&gLight3, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), - Span(gLight3DataVersions)); + Span(gLight3DataVersions), 1); - // Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 2 & 4 + // Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 3 & 5 RemoveDeviceEndpoint(&gLight2); - // Add Light 4 -- > will be mapped to ZCL endpoint 5 + // Add Light 4 -- > will be mapped to ZCL endpoint 6 AddDeviceEndpoint(&gLight4, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), - Span(gLight4DataVersions)); + Span(gLight4DataVersions), 1); - // Re-add Light 2 -- > will be mapped to ZCL endpoint 6 + // Re-add Light 2 -- > will be mapped to ZCL endpoint 7 AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), - Span(gLight2DataVersions)); + Span(gLight2DataVersions), 1); } extern "C" void app_main()