8000 revert: [occupancy-sensing]Updated occupancy sensing cluster SDK & Sample app(all-clusters-app) implementation to Rev 5 (Matter 1.4)" by woody-apple · Pull Request #34592 · project-chip/connectedhomeip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

revert: [occupancy-sensing]Updated occupancy sensing cluster SDK & Sample app(all-clusters-app) implementation to Rev 5 (Matter 1.4)" #34592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll o 8000 ccasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8869,10 +8869,8 @@ endpoint 1 {
ram attribute occupancy;
ram attribute occupancySensorType;
ram attribute occupancySensorTypeBitmap;
ram attribute holdTime default = 10;
callback attribute holdTimeLimits;
ram attribute featureMap default = 0x01;
ram attribute clusterRevision default = 5;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;
}

server cluster CarbonMonoxideConcentrationMeasurement {
Expand Down Expand Up @@ -9340,10 +9338,8 @@ endpoint 2 {
ram attribute occupancy;
ram attribute occupancySensorType;
ram attribute occupancySensorTypeBitmap;
ram attribute holdTime default = 20;
callback attribute holdTimeLimits;
ram attribute featureMap default = 0x01;
ram attribute clusterRevision default = 5;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;
}
}
endpoint 3 {
Expand Down
72 changes: 4 additions & 68 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -18984,38 +18984,6 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "HoldTime",
"code": 3,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "10",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "HoldTimeLimits",
"code": 4,
"mfgCode": null,
"side": "server",
"type": "HoldTimeLimitsStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand All @@ -19026,7 +18994,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x01",
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -19042,7 +19010,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "5",
"defaultValue": "4",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down Expand Up @@ -25045,38 +25013,6 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "HoldTime",
"code": 3,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "20",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "HoldTimeLimits",
"code": 4,
"mfgCode": null,
"side": "server",
"type": "HoldTimeLimitsStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand All @@ -25087,7 +25023,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x01",
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -25103,7 +25039,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "5",
"defaultValue": "4",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ source_set("chip-all-clusters-common") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp",
Expand Down
156 changes: 7 additions & 149 deletions src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (c) 2020-2024 Project CHIP Authors
* Copyright (c) 2020 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.
Expand All @@ -16,158 +16,12 @@
*/

#include "occupancy-sensor-server.h"
#include "occupancy-hal.h"

#include <app/AttributeAccessInterfaceRegistry.h>
#include <app/EventLogging.h>
#include <app/data-model/Encode.h>
#include <app/reporting/reporting.h>
#include <app/util/attribute-storage.h>
#include <lib/core/CHIPError.h>

using chip::Protocols::InteractionModel::Status;

namespace chip {
namespace app {
namespace Clusters {
namespace OccupancySensing {

namespace {
Structs::HoldTimeLimitsStruct::Type
sHoldTimeLimitsStructs[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];

uint16_t sHoldTime[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];
} // namespace

CHIP_ERROR OccupancySensingAttrAccess::Init()
{
VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE);
return CHIP_NO_ERROR;
}

void OccupancySensingAttrAccess::Shutdown()
{
unregisterAttributeAccessOverride(this);
}

CHIP_ERROR OccupancySensingAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
{
VerifyOrDie(aPath.mClusterId == app::Clusters::OccupancySensing::Id);

switch (aPath.mAttributeId)
{
case Attributes::FeatureMap::Id:
ReturnErrorOnFailure(aEncoder.Encode(mFeature));
break;
case Attributes::HoldTime::Id: {

uint16_t * holdTime = GetHoldTimeForEndpoint(aPath.mEndpointId);
#include <app-common/zap-generated/attributes/Accessors.h>

if (holdTime == nullptr)
{
return CHIP_ERROR_NOT_FOUND;
}

return aEncoder.Encode(*holdTime);
}
case Attributes::HoldTimeLimits::Id: {

Structs::HoldTimeLimitsStruct::Type * holdTimeLimitsStruct = GetHoldTimeLimitsForEndpoint(aPath.mEndpointId);

if (holdTimeLimitsStruct == nullptr)
{
return CHIP_ERROR_NOT_FOUND;
}

return aEncoder.Encode(*holdTimeLimitsStruct);
}
default:
return CHIP_NO_ERROR;
}

return CHIP_NO_ERROR;
}

bool OccupancySensingAttrAccess::HasFeature(Feature aFeature) const
{
return mFeature.Has(aFeature);
}

Structs::HoldTimeLimitsStruct::Type * GetHoldTimeLimitsForEndpoint(EndpointId endpoint)
{
auto index = emberAfGetClusterServerEndpointIndex(endpoint, app::Clusters::OccupancySensing::Id,
MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT);

if (index == kEmberInvalidEndpointIndex)
{
return nullptr;
}

if (index >= ArraySize(sHoldTimeLimitsStructs))
{
ChipLogError(NotSpecified, "Internal error: invalid/unexpected hold time limits index.");
return nullptr;
}
return &sHoldTimeLimitsStructs[index];
}

CHIP_ERROR SetHoldTimeLimits(EndpointId endpointId, const Structs::HoldTimeLimitsStruct::Type & holdTimeLimits)
{

VerifyOrReturnError(kInvalidEndpointId != endpointId, CHIP_ERROR_INVALID_ARGUMENT);

Structs::HoldTimeLimitsStruct::Type * holdTimeLimitsForEndpoint = GetHoldTimeLimitsForEndpoint(endpointId);
VerifyOrReturnError(holdTimeLimitsForEndpoint != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

holdTimeLimitsForEndpoint->holdTimeMin = holdTimeLimits.holdTimeMin;
holdTimeLimitsForEndpoint->holdTimeMax = holdTimeLimits.holdTimeMax;
holdTimeLimitsForEndpoint->holdTimeDefault = holdTimeLimits.holdTimeDefault;

MatterReportingAttributeChangeCallback(endpointId, OccupancySensing::Id, Attributes::HoldTimeLimits::Id);

return CHIP_NO_ERROR;
}

uint16_t * GetHoldTimeForEndpoint(EndpointId endpoint)
{
auto index = emberAfGetClusterServerEndpointIndex(endpoint, app::Clusters::OccupancySensing::Id,
MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT);

if (index == kEmberInvalidEndpointIndex)
{
return nullptr;
}

if (index >= ArraySize(sHoldTimeLimitsStructs))
{
ChipLogError(NotSpecified, "Internal error: invalid/unexpected hold time index.");
return nullptr;
}
return &sHoldTime[index];
}

CHIP_ERROR SetHoldTime(EndpointId endpointId, const uint16_t & holdTime)
{
VerifyOrReturnError(kInvalidEndpointId != endpointId, CHIP_ERROR_INVALID_ARGUMENT);

uint16_t * holdTimeForEndpoint = GetHoldTimeForEndpoint(endpointId);
VerifyOrReturnError(holdTimeForEndpoint != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

*holdTimeForEndpoint = holdTime;

MatterReportingAttributeChangeCallback(endpointId, OccupancySensing::Id, Attributes::HoldTime::Id);

return CHIP_NO_ERROR;
}

} // namespace OccupancySensing
} // namespace Clusters
} // namespace app
} // namespace chip
#include "occupancy-hal.h"

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::OccupancySensing;

//******************************************************************************
Expand Down Expand Up @@ -205,6 +59,8 @@ void emberAfOccupancySensingClusterServerInitCallback(EndpointId endpoint)
break;
}
Attributes::OccupancySensorTypeBitmap::Set(endpoint, deviceTypeBitmap);

emberAfPluginOccupancyClusterServerPostInitCallback(endpoint);
}

//******************************************************************************
Expand All @@ -226,6 +82,8 @@ void halOccupancyStateChangedCallback(EndpointId endpoint, HalOccupancyState occ
Attributes::Occupancy::Set(endpoint, occupancyState);
}

void emberAfPluginOccupancyClusterServerPostInitCallback(EndpointId endpoint) {}

HalOccupancySensorType __attribute__((weak)) halOccupancyGetSensorType(EndpointId endpoint)
{
return HAL_OCCUPANCY_SENSOR_TYPE_PIR;
Expand Down
Loading
Loading
0