Skip to content

Commit

Permalink
Update ZAP to force lists to be external-storage.
Browse files Browse the repository at this point in the history
The Power Source cluster addition is because that was one of two lists
that we did not already have AttributeAccessInterface handling for
(and the other one was in a cluster that already had an
AttributeAccessInterface).

Now that we have AttributeAccessInterface for all lists, we no longer
need the fake "return an empty list" thing in
ember-compatibility-functions.cpp.
  • Loading branch information
bzbarsky-apple committed Jan 22, 2022
1 parent ed8d276 commit 42bf26a
Show file tree
Hide file tree
Showing 28 changed files with 3,169 additions and 4,953 deletions.
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wake-on-lan-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src"
#${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-client
)
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ target_sources(${APP_TARGET} PRIVATE
${APP_CLUSTERS}/general-diagnostics-server/general-diagnostics-server.cpp
${APP_CLUSTERS}/group-key-mgmt-server/group-key-mgmt-server.cpp
${APP_CLUSTERS}/power-source-configuration-server/power-source-configuration-server.cpp
${APP_CLUSTERS}/power-source-server/power-source-server.cpp
${APP_CLUSTERS}/ota-requestor/ota-requestor-server.cpp
${APP_CLUSTERS}/ota-requestor/BDXDownloader.cpp
${APP_CLUSTERS}/ota-requestor/OTARequestor.cpp
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ idf_component_register(INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server"
PRIV_REQUIRES bt chip QRCode)

get_filename_component(CHIP_ROOT ../third_party/connectedhomeip REALPATH)
Expand Down Expand Up @@ -153,6 +154,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server"
PRIV_REQUIRES chip QRCode bt)

Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ target_sources(${APP_TARGET} PRIVATE
${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp
${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp
${CHIP_ROOT}/src/app/clusters/power-source-configuration-server/power-source-configuration-server.cpp
${CHIP_ROOT}/src/app/clusters/power-source-configuration-server/power-source-server.cpp
${CHIP_ROOT}/src/app/clusters/user-label-server/user-label-server.cpp
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ CHIP_ERROR GeneralCommissioningAttrAccess::Read(const ConcreteReadAttributePath
case LocationCapability::Id: {
return ReadIfSupported(&ConfigurationManager::GetLocationCapability, aEncoder);
}
case BasicCommissioningInfoList::Id: {
// TODO: This should not be a list at all!
return aEncoder.EncodeEmptyList();
}
default: {
break;
}
Expand Down
70 changes: 70 additions & 0 deletions src/app/clusters/power-source-server/power-source-server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/****************************************************************************
* @file
* @brief Implementation for the Power Source Server Cluster
***************************************************************************/

#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/AttributeAccessInterface.h>
#include <app/util/attribute-storage.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::PowerSource::Attributes;

namespace {

class PowerSourceAttrAccess : public AttributeAccessInterface
{
public:
// Register on all endpoints.
PowerSourceAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), PowerSource::Id) {}

CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
};

PowerSourceAttrAccess gAttrAccess;

CHIP_ERROR PowerSourceAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
{
CHIP_ERROR err = CHIP_NO_ERROR;

switch (aPath.mAttributeId)
{
case ActiveBatteryFaults::Id:
// TODO: Needs implementation.
err = aEncoder.EncodeEmptyList();
break;
default:
break;
}

return err;
}

} // anonymous namespace

void MatterPowerSourcePluginServerInitCallback(void)
{
registerAttributeAccessOverride(&gAttrAccess);
}
15 changes: 0 additions & 15 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,21 +658,6 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b
}
break;
}
case ZCL_ARRAY_ATTRIBUTE_TYPE: {
// We only get here for attributes of list type that have no override
// registered. There should not be any nonempty lists like that.
uint16_t length = emberAfGetInt16u(attributeData, 0, 2);
if (length != 0)
{
return CHIP_ERROR_INCORRECT_STATE;
}

// Just encode an empty array.
TLV::TLVType containerType;
ReturnErrorOnFailure(writer->StartContainer(tag, TLV::kTLVType_Array, containerType));
ReturnErrorOnFailure(writer->EndContainer(containerType));
break;
}
default:
ChipLogError(DataManagement, "Attribute type 0x%x not handled", static_cast<int>(attributeType));
emberStatus = EMBER_ZCL_STATUS_WRITE_ONLY;
Expand Down
1 change: 0 additions & 1 deletion src/app/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ void MatterPressureMeasurementPluginServerInitCallback() {}
void MatterTemperatureMeasurementPluginServerInitCallback() {}
void MatterFlowMeasurementPluginServerInitCallback() {}
void MatterOnOffSwitchConfigurationPluginServerInitCallback() {}
void MatterPowerSourcePluginServerInitCallback() {}
void MatterThermostatUserInterfaceConfigurationPluginServerInitCallback() {}
void MatterBridgedDeviceBasicInformationPluginServerInitCallback() {}
void MatterPowerConfigurationPluginServerInitCallback() {}
Expand Down
2 changes: 2 additions & 0 deletions src/app/zap-templates/zcl/zcl.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,7 @@
"commandDiscovery": true
}
},
"listsUseAttributeAccessInterface": true,
"attributeAccessInterfaceAttributes": {},
"defaultReportingPolicy": "mandatory"
}
2 changes: 1 addition & 1 deletion src/app/zap_cluster_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
'OTA_BOOTLOAD_CLUSTER': [],
'OTA_PROVIDER_CLUSTER': ['ota-provider'],
'OTA_REQUESTOR_CLUSTER': ['ota-requestor'],
'POWER_SOURCE_CLUSTER': [],
'POWER_SOURCE_CLUSTER': ['power-source-server'],
'POWER_SOURCE_CONFIGURATION_CLUSTER': ['power-source-configuration-server'],
'POLL_CONTROL_CLUSTER': [],
'POWER_CONFIG_CLUSTER': [],
Expand Down
Loading

0 comments on commit 42bf26a

Please sign in to comment.