-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fabric Bridge: use AttributeAccessInterface for BridgedDeviceBasicInf…
…ormationCluster, expose more attributes (#34845) * Add extra attributes to the bridged device basic info structures, remove nonsense comments * Make use of AAI for BridgedDeviceBasicInformation cluster * Restyled by gn * Fix sizes for software version * Bump revision to 4 --------- Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
1 parent
4e2245b
commit a0fac9f
Showing
6 changed files
with
154 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceBasicInformationImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024 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. | ||
*/ | ||
#pragma once | ||
|
||
#include <app-common/zap-generated/ids/Clusters.h> | ||
#include <app/AttributeAccessInterface.h> | ||
|
||
class BridgedDeviceBasicInformationImpl : public chip::app::AttributeAccessInterface | ||
{ | ||
public: | ||
BridgedDeviceBasicInformationImpl() : | ||
chip::app::AttributeAccessInterface(chip::NullOptional /* endpointId */, | ||
chip::app::Clusters::BridgedDeviceBasicInformation::Id) | ||
{} | ||
|
||
// AttributeAccessInterface implementation | ||
CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & path, chip::app::AttributeValueEncoder & encoder) override; | ||
CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & path, chip::app::AttributeValueDecoder & decoder) override; | ||
}; |
78 changes: 78 additions & 0 deletions
78
examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceBasicInformationImpl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) 2024 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. | ||
*/ | ||
#include "BridgedDeviceBasicInformationImpl.h" | ||
|
||
#include "BridgedDeviceManager.h" | ||
|
||
#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/AttributeAccessInterfaceRegistry.h> | ||
|
||
static constexpr unsigned kBridgedDeviceBasicInformationClusterRevision = 4; | ||
static constexpr unsigned kBridgedDeviceBasicInformationFeatureMap = 0; | ||
|
||
using namespace ::chip; | ||
using namespace ::chip::app; | ||
using namespace ::chip::app::Clusters; | ||
|
||
CHIP_ERROR BridgedDeviceBasicInformationImpl::Read(const ConcreteReadAttributePath & path, AttributeValueEncoder & encoder) | ||
{ | ||
// Registration is done for the bridged device basic information only | ||
VerifyOrDie(path.mClusterId == app::Clusters::BridgedDeviceBasicInformation::Id); | ||
|
||
BridgedDevice * dev = BridgeDeviceMgr().GetDevice(path.mEndpointId); | ||
VerifyOrReturnError(dev != nullptr, CHIP_ERROR_NOT_FOUND); | ||
|
||
switch (path.mAttributeId) | ||
{ | ||
case BasicInformation::Attributes::Reachable::Id: | ||
encoder.Encode(dev->IsReachable()); | ||
break; | ||
case BasicInformation::Attributes::NodeLabel::Id: | ||
encoder.Encode(CharSpan::fromCharString(dev->GetName())); | ||
break; | ||
case BasicInformation::Attributes::ClusterRevision::Id: | ||
encoder.Encode(kBridgedDeviceBasicInformationClusterRevision); | ||
break; | ||
case BasicInformation::Attributes::FeatureMap::Id: | ||
encoder.Encode(kBridgedDeviceBasicInformationFeatureMap); | ||
break; | ||
default: | ||
return CHIP_ERROR_INVALID_ARGUMENT; | ||
} | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
CHIP_ERROR BridgedDeviceBasicInformationImpl::Write(const ConcreteDataAttributePath & path, AttributeValueDecoder & decoder) | ||
{ | ||
VerifyOrDie(path.mClusterId == app::Clusters::BridgedDeviceBasicInformation::Id); | ||
|
||
BridgedDevice * dev = BridgeDeviceMgr().GetDevice(path.mEndpointId); | ||
VerifyOrReturnError(dev != nullptr, CHIP_ERROR_NOT_FOUND); | ||
|
||
if (!dev->IsReachable()) | ||
{ | ||
return CHIP_ERROR_NOT_CONNECTED; | ||
} | ||
|
||
ChipLogProgress(NotSpecified, "Bridged device basic information attempt to write attribute: ep=%d", path.mAttributeId); | ||
|
||
// nothing writable right now ... | ||
|
||
return CHIP_ERROR_INVALID_ARGUMENT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters