From 46093311cb3acae4d86d77dd9a1e919c3bc9e069 Mon Sep 17 00:00:00 2001 From: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> Date: Sat, 27 Jul 2024 02:25:04 +0900 Subject: [PATCH] Fix UNSUPPORTED_ENDPOINT of TC-BR-4's step 1h (#34499) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix UNSUPPORTED_ENDPOINT of TC-BR-4's step 1h When testing step 1h of TC-BR-4 with bridge-app on the latest TH, an UNSUPPORTED_ENDPOINT error occurs. This is because ComposedDevice and ComposedPowerSource are local variables in the ApplicationInit function, so they are not valid when the bridge-app runs. This change moves ComposedDevice and ComposedPowerSource to global scope. Co-authored-by: Charles Kim Co-authored-by: Sanghee Kim Co-authored-by: Hunsup Jung Co-authored-by: sanghyukko Co-authored-by: Jaehoon You Co-authored-by: Kyu-Wook Lim Signed-off-by: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> * Fix ambiguous build error of bridge app ComposedDevice has the same type and variable name, so an ambiguous build error occurs as shown below. This change renames the variable to gComposeDevice. ../../main.cpp: In function ‘void ApplicationInit()’: ../../main.cpp:924:5: error: reference to ‘ComposedDevice’ is ambiguous 924 | ComposedDevice.SetReachable(true); | ^~~~~~~~~~~~~~ ../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’ 174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom"); | ^~~~~~~~~~~~~~ In file included from ../../main.cpp:46: ../../include/Device.h:158:7: note: ‘class ComposedDevice’ 158 | class ComposedDevice : public Device | ^~~~~~~~~~~~~~ ../../main.cpp:954:24: error: reference to ‘ComposedDevice’ is ambiguous 954 | AddDeviceEndpoint(&ComposedDevice, &bridgedComposedDeviceEndpoint, Span(gBridgedComposedDeviceTypes), | ^~~~~~~~~~~~~~ ../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’ 174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom"); | ^~~~~~~~~~~~~~ In file included from ../../main.cpp:46: ../../include/Device.h:158:7: note: ‘class ComposedDevice’ 158 | class ComposedDevice : public Device | ^~~~~~~~~~~~~~ ../../main.cpp:958:76: error: reference to ‘ComposedDevice’ is ambiguous 958 | Span(gComposedTempSensor1DataVersions), ComposedDevice.GetEndpointId()); | ^~~~~~~~~~~~~~ ../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’ 174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom"); | ^~~~~~~~~~~~~~ In file included from ../../main.cpp:46: ../../include/Device.h:158:7: note: ‘class ComposedDevice’ 158 | class ComposedDevice : public Device | ^~~~~~~~~~~~~~ ../../main.cpp:961:76: error: reference to ‘ComposedDevice’ is ambiguous 961 | Span(gComposedTempSensor2DataVersions), ComposedDevice.GetEndpointId()); | ^~~~~~~~~~~~~~ ../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’ 174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom"); | ^~~~~~~~~~~~~~ In file included from ../../main.cpp:46: ../../include/Device.h:158:7: note: ‘class ComposedDevice’ 158 | class ComposedDevice : public Device | ^~~~~~~~~~~~~~ ../../main.cpp:977:28: error: reference to ‘ComposedDevice’ is ambiguous 977 | endpointList.push_back(ComposedDevice.GetEndpointId()); | ^~~~~~~~~~~~~~ ../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’ 174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom"); | ^~~~~~~~~~~~~~ In file included from ../../main.cpp:46: ../../include/Device.h:158:7: note: ‘class ComposedDevice’ 158 | class ComposedDevice : public Device | ^~~~~~~~~~~~~~ ../../main.cpp:981:39: error: reference to ‘ComposedDevice’ is ambiguous 981 | ComposedPowerSource.SetEndpointId(ComposedDevice.GetEndpointId()); | ^~~~~~~~~~~~~~ ../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’ 174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom"); | ^~~~~~~~~~~~~~ In file included from ../../main.cpp:46: ../../include/Device.h:158:7: note: ‘class ComposedDevice’ 158 | class ComposedDevice : public Device | ^~~~~~~~~~~~~~ At global scope: cc1plus: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror] cc1plus: all warnings being treated as errors ninja: build stopped: subcommand failed. Signed-off-by: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> --------- Signed-off-by: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> Co-authored-by: Charles Kim Co-authored-by: Sanghee Kim Co-authored-by: Hunsup Jung Co-authored-by: sanghyukko Co-authored-by: Jaehoon You Co-authored-by: Kyu-Wook Lim Co-authored-by: Andrei Litvin --- examples/bridge-app/linux/main.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 699a87fa8c7938..c7e1dfb5a9c50b 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -159,9 +159,6 @@ DeviceOnOff Light2("Light 2", "Office"); DeviceTempSensor TempSensor1("TempSensor 1", "Office", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); DeviceTempSensor TempSensor2("TempSensor 2", "Office", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); -DeviceTempSensor ComposedTempSensor1("Composed TempSensor 1", "Bedroom", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); -DeviceTempSensor ComposedTempSensor2("Composed TempSensor 2", "Bedroom", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); - // Declare Bridged endpoints used for Action clusters DataVersion gActionLight1DataVersions[ArraySize(bridgedLightClusters)]; DataVersion gActionLight2DataVersions[ArraySize(bridgedLightClusters)]; @@ -173,6 +170,12 @@ DeviceOnOff ActionLight2("Action Light 2", "Room 1"); DeviceOnOff ActionLight3("Action Light 3", "Room 2"); DeviceOnOff ActionLight4("Action Light 4", "Room 2"); +// Setup composed device with two temperature sensors and a power source +ComposedDevice gComposedDevice("Composed Device", "Bedroom"); +DeviceTempSensor ComposedTempSensor1("Composed TempSensor 1", "Bedroom", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); +DeviceTempSensor ComposedTempSensor2("Composed TempSensor 2", "Bedroom", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); +DevicePowerSource ComposedPowerSource("Composed Power Source", "Bedroom", PowerSource::Feature::kBattery); + Room room1("Room 1", 0xE001, Actions::EndpointListTypeEnum::kRoom, true); Room room2("Room 2", 0xE002, Actions::EndpointListTypeEnum::kRoom, true); Room room3("Zone 3", 0xE003, Actions::EndpointListTypeEnum::kZone, false); @@ -918,11 +921,7 @@ void ApplicationInit() ActionLight3.SetChangeCallback(&HandleDeviceOnOffStatusChanged); ActionLight4.SetChangeCallback(&HandleDeviceOnOffStatusChanged); - // Setup composed device with two temperature sensors and a power source - ComposedDevice ComposedDevice("Composed Device", "Bedroom"); - DevicePowerSource ComposedPowerSource("Composed Power Source", "Bedroom", PowerSource::Feature::kBattery); - - ComposedDevice.SetReachable(true); + gComposedDevice.SetReachable(true); ComposedTempSensor1.SetReachable(true); ComposedTempSensor2.SetReachable(true); ComposedPowerSource.SetReachable(true); @@ -952,14 +951,14 @@ void ApplicationInit() Span(gTempSensor2DataVersions), 1); // Add composed Device with two temperature sensors and a power source - AddDeviceEndpoint(&ComposedDevice, &bridgedComposedDeviceEndpoint, Span(gBridgedComposedDeviceTypes), + AddDeviceEndpoint(&gComposedDevice, &bridgedComposedDeviceEndpoint, Span(gBridgedComposedDeviceTypes), Span(gComposedDeviceDataVersions), 1); AddDeviceEndpoint(&ComposedTempSensor1, &bridgedTempSensorEndpoint, Span(gComposedTempSensorDeviceTypes), - Span(gComposedTempSensor1DataVersions), ComposedDevice.GetEndpointId()); + Span(gComposedTempSensor1DataVersions), gComposedDevice.GetEndpointId()); AddDeviceEndpoint(&ComposedTempSensor2, &bridgedTempSensorEndpoint, Span(gComposedTempSensorDeviceTypes), - Span(gComposedTempSensor2DataVersions), ComposedDevice.GetEndpointId()); + Span(gComposedTempSensor2DataVersions), gComposedDevice.GetEndpointId()); // Add 4 lights for the Action Clusters tests AddDeviceEndpoint(&ActionLight1, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), @@ -975,11 +974,11 @@ void ApplicationInit() gDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT] = &ComposedPowerSource; // This provides power for the composed endpoint std::vector endpointList; - endpointList.push_back(ComposedDevice.GetEndpointId()); + endpointList.push_back(gComposedDevice.GetEndpointId()); endpointList.push_back(ComposedTempSensor1.GetEndpointId()); endpointList.push_back(ComposedTempSensor2.GetEndpointId()); ComposedPowerSource.SetEndpointList(endpointList); - ComposedPowerSource.SetEndpointId(ComposedDevice.GetEndpointId()); + ComposedPowerSource.SetEndpointId(gComposedDevice.GetEndpointId()); gRooms.push_back(&room1); gRooms.push_back(&room2);