Skip to content

Commit

Permalink
Fix Descriptor cluster when linking statically. (#11453)
Browse files Browse the repository at this point in the history
Specific changes:

1) Stop using weak symbols for cluster init callbacks.  The way things
   are, if a cluster has no commands its file might not get linked at
   all (because the weak symbols satisfy the linker), and hence its
   init callback would never be called.  This was hitting the
   Descriptor cluster.

2) Add a bunch of no-op cluster init callbacks so we can link successfully.
   Add some files to the all-clusters-app link that were missing.

Fixes #11344
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 26, 2021
1 parent 73428b5 commit 3503453
Show file tree
Hide file tree
Showing 37 changed files with 305 additions and 327 deletions.
2 changes: 2 additions & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/test-cluster-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server"
Expand All @@ -54,6 +55,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/media-playback-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-provider"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/target-navigator-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread_network_diagnostics_server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/tv-channel-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes"
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ target_sources(${APP_TARGET} PRIVATE
${APP_UTIL}/util.cpp
${APP_UTIL}/error-mapping.cpp

${APP_CLUSTERS}/application-basic-server/application-basic-server.cpp
${APP_CLUSTERS}/basic/basic.cpp
${APP_CLUSTERS}/bindings/bindings.cpp
${APP_CLUSTERS}/on-off-server/on-off-server.cpp
Expand Down Expand Up @@ -118,6 +119,7 @@ target_sources(${APP_TARGET} PRIVATE
${APP_CLUSTERS}/ota-provider/ota-provider.cpp
${APP_CLUSTERS}/scenes/scenes.cpp
${APP_CLUSTERS}/target-navigator-server/target-navigator-server.cpp
${APP_CLUSTERS}/thermostat-server/thermostat-server.cpp
${APP_CLUSTERS}/tv-channel-server/tv-channel-server.cpp
${APP_CLUSTERS}/operational-credentials-server/operational-credentials-server.cpp
${APP_CLUSTERS}/test-cluster-server/test-cluster-server.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ bool emberAfAccountLoginClusterLoginCallback(app::CommandHandler * command, cons
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterAccountLoginPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ bool emberAfAdministratorCommissioningClusterRevokeCommissioningCallback(
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
return true;
}

void MatterAdministratorCommissioningPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ bool emberAfApplicationBasicClusterChangeStatusCallback(app::CommandHandler * co
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterApplicationBasicPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co
sendResponse(command, response);
return true;
}

void MatterApplicationLauncherPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/audio-output-server/audio-output-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ bool emberAfAudioOutputClusterSelectOutputCallback(app::CommandHandler * command
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterAudioOutputPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,5 @@ bool emberAfBarrierControlClusterBarrierControlStopCallback(app::CommandHandler
sendDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
return true;
}

void MatterBarrierControlPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/basic/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint)
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Software Version: 0x%02x", status));
}
}

void MatterBasicPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ bool emberAfBindingClusterUnbindCallback(app::CommandHandler * commandObj, const
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
return true;
}

void MatterBindingPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -2585,3 +2585,5 @@ void emberAfPluginColorControlServerHueSatTransitionEventHandler(EndpointId endp
ColorControlServer::Instance().updateHueSatCommand(endpoint);
}
#endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV

void MatterColorControlPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ bool emberAfContentLauncherClusterLaunchURLCallback(app::CommandHandler * comman
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterContentLauncherPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ bool emberAfDiagnosticLogsClusterRetrieveLogsRequestCallback(app::CommandHandler
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterDiagnosticLogsPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server-core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ EmberAfStatus emAfPluginDoorLockServerNoteDoorStateChanged(EmberAfDoorState stat

return status;
}

void MatterDoorLockPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool emberAfEthernetNetworkDiagnosticsClusterResetCountsCallback(app::CommandHan
return true;
}

void MatterEthernetNetworkDiagnosticsClusterServerInitCallback()
void MatterEthernetNetworkDiagnosticsPluginServerInitCallback()
{
registerAttributeAccessOverride(&gAttrAccess);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH

return true;
}

void MatterGeneralCommissioningPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/groups-server/groups-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,5 @@ bool emberAfPluginGroupsServerGroupNamesSupportedCallback(EndpointId endpoint)
}

void emberAfPluginGroupsServerSetGroupNameCallback(EndpointId endpoint, GroupId groupId, const CharSpan & groupName) {}

void MatterGroupsPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/ias-zone-server/ias-zone-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,3 +924,5 @@ uint16_t computeElapsedTimeQs(IasZoneStatusQueueEntry * entry)
return deltaTimeMs / MILLISECOND_TICKS_PER_QUARTERSECOND;
}
#endif

void MatterIasZonePluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/identify-server/identify-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,5 @@ Identify::~Identify()
{
unreg(this);
}

void MatterIdentifyPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/keypad-input-server/keypad-input-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ bool emberAfKeypadInputClusterSendKeyCallback(app::CommandHandler * command, con
sendResponse(command, status);
return true;
}

void MatterKeypadInputPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,3 +1053,5 @@ static bool areStartUpLevelControlServerAttributesTokenized(EndpointId endpoint)
#endif

void emberAfPluginLevelControlClusterServerPostInitCallback(EndpointId endpoint) {}

void MatterLevelControlPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/low-power-server/low-power-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ bool emberAfLowPowerClusterSleepCallback(app::CommandHandler * command, const ap
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterLowPowerPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/media-input-server/media-input-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ bool emberAfMediaInputClusterRenameInputCallback(app::CommandHandler * command,
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterMediaInputPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,5 @@ bool emberAfMediaPlaybackClusterMediaStartOverCallback(app::CommandHandler * com
sendResponse(command, "MediaStartOver", Commands::MediaStartOverResponse::Id, status);
return true;
}

void MatterMediaPlaybackPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ bool emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(app::CommandHan
{
return false;
}

void MatterNetworkCommissioningPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ HalOccupancySensorType __attribute__((weak)) halOccupancyGetSensorType(EndpointI
{
return HAL_OCCUPANCY_SENSOR_TYPE_PIR;
}

void MatterOccupancySensingPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,5 @@ static bool areStartUpOnOffServerAttributesTokenized(EndpointId endpoint)
#endif

void emberAfPluginOnOffClusterServerPostInitCallback(EndpointId endpoint) {}

void MatterOnOffPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/ota-provider/ota-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,5 @@ void SetDelegate(EndpointId endpoint, OTAProviderDelegate * delegate)
} // namespace Clusters
} // namespace app
} // namespace chip

void MatterOtaSoftwareUpdateProviderPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ void MatterPumpConfigurationAndControlClusterServerAttributeChangedCallback(cons
(unsigned int) attributePath.mAttributeId);
// TODO
}

void MatterPumpConfigurationAndControlPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/scenes/scenes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,3 +1314,5 @@ void emberAfScenesClusterRemoveScenesInGroupCallback(EndpointId endpoint, GroupI
}
}
}

void MatterScenesPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ bool emberAfTargetNavigatorClusterNavigateTargetCallback(app::CommandHandler * c
sendResponse(command, response);
return true;
}

void MatterTargetNavigatorPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,3 +774,5 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterThermostatPluginServerInitCallback() {}
2 changes: 2 additions & 0 deletions src/app/clusters/tv-channel-server/tv-channel-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ bool emberAfTvChannelClusterSkipChannelCallback(app::CommandHandler * command, c
emberAfSendImmediateDefaultResponse(status);
return true;
}

void MatterTvChannelPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,5 @@ bool emberAfWindowCoveringClusterGoToTiltPercentageCallback(app::CommandHandler
}
return true;
}

void MatterWindowCoveringPluginServerInitCallback() {}
20 changes: 20 additions & 0 deletions src/app/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ void emberAfTick(void)
#endif
}

// Cluster init functions that don't have a cluster implementation to define
// them in.
void MatterBooleanStatePluginServerInitCallback() {}
void MatterBridgedDeviceBasicPluginServerInitCallback() {}
void MatterElectricalMeasurementPluginServerInitCallback() {}
void MatterOtaSoftwareUpdateRequestorPluginServerInitCallback() {}
void MatterGroupKeyManagementPluginServerInitCallback() {}
void MatterRelativeHumidityMeasurementPluginServerInitCallback() {}
void MatterFixedLabelPluginServerInitCallback() {}
void MatterSwitchPluginServerInitCallback() {}
void MatterIlluminanceMeasurementPluginServerInitCallback() {}
void MatterBinaryInputBasicPluginServerInitCallback() {}
void MatterPressureMeasurementPluginServerInitCallback() {}
void MatterTemperatureMeasurementPluginServerInitCallback() {}
void MatterFlowMeasurementPluginServerInitCallback() {}
void MatterWakeOnLanPluginServerInitCallback() {}
void MatterOnOffSwitchConfigurationPluginServerInitCallback() {}
void MatterPowerSourcePluginServerInitCallback() {}
void MatterThermostatUserInterfaceConfigurationPluginServerInitCallback() {}

// ****************************************
// This function is called by the application when the stack goes down,
// such as after a leave network. This allows zcl utils to clear state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#pragma once

{{#zcl_clusters}}
{{#*inline "callbackName"}}void __attribute__((weak)) Matter{{asUpperCamelCase label}}{{> @partial-block}}InitCallback() {};{{/inline}}
{{#>callbackName}}PluginClient{{/callbackName}}
{{#>callbackName}}PluginServer{{/callbackName}}
void __attribute__((weak)) Matter{{asUpperCamelCase label}}PluginClientInitCallback() {}
void Matter{{asUpperCamelCase label}}PluginServerInitCallback();
{{/zcl_clusters}}
Loading

0 comments on commit 3503453

Please sign in to comment.