Skip to content

Commit

Permalink
Fix UNSUPPORTED_ENDPOINT of TC-BR-4's step 1h (#34499)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Sanghee Kim <[email protected]>
Co-authored-by: Hunsup Jung <[email protected]>
Co-authored-by: sanghyukko <[email protected]>
Co-authored-by: Jaehoon You <[email protected]>
Co-authored-by: Kyu-Wook Lim <[email protected]>
Signed-off-by: Youngho Yoon <[email protected]>

* 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<const EmberAfDeviceType>(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<DataVersion>(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<DataVersion>(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 <[email protected]>

---------

Signed-off-by: Youngho Yoon <[email protected]>
Co-authored-by: Charles Kim <[email protected]>
Co-authored-by: Sanghee Kim <[email protected]>
Co-authored-by: Hunsup Jung <[email protected]>
Co-authored-by: sanghyukko <[email protected]>
Co-authored-by: Jaehoon You <[email protected]>
Co-authored-by: Kyu-Wook Lim <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
8 people authored and pull[bot] committed Aug 9, 2024
1 parent 00490af commit 4609331
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -952,14 +951,14 @@ void ApplicationInit()
Span<DataVersion>(gTempSensor2DataVersions), 1);

// Add composed Device with two temperature sensors and a power source
AddDeviceEndpoint(&ComposedDevice, &bridgedComposedDeviceEndpoint, Span<const EmberAfDeviceType>(gBridgedComposedDeviceTypes),
AddDeviceEndpoint(&gComposedDevice, &bridgedComposedDeviceEndpoint, Span<const EmberAfDeviceType>(gBridgedComposedDeviceTypes),
Span<DataVersion>(gComposedDeviceDataVersions), 1);
AddDeviceEndpoint(&ComposedTempSensor1, &bridgedTempSensorEndpoint,
Span<const EmberAfDeviceType>(gComposedTempSensorDeviceTypes),
Span<DataVersion>(gComposedTempSensor1DataVersions), ComposedDevice.GetEndpointId());
Span<DataVersion>(gComposedTempSensor1DataVersions), gComposedDevice.GetEndpointId());
AddDeviceEndpoint(&ComposedTempSensor2, &bridgedTempSensorEndpoint,
Span<const EmberAfDeviceType>(gComposedTempSensorDeviceTypes),
Span<DataVersion>(gComposedTempSensor2DataVersions), ComposedDevice.GetEndpointId());
Span<DataVersion>(gComposedTempSensor2DataVersions), gComposedDevice.GetEndpointId());

// Add 4 lights for the Action Clusters tests
AddDeviceEndpoint(&ActionLight1, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
Expand All @@ -975,11 +974,11 @@ void ApplicationInit()
gDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT] = &ComposedPowerSource;
// This provides power for the composed endpoint
std::vector<chip::EndpointId> 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);
Expand Down

0 comments on commit 4609331

Please sign in to comment.