Skip to content

Commit 1f0370d

Browse files
authored
Merge branch 'master' into granbery/atomic_write
2 parents bba5072 + 3d9ada2 commit 1f0370d

File tree

7 files changed

+26
-327
lines changed

7 files changed

+26
-327
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+4-8
Original file line numberDiff line numberDiff line change
@@ -8874,10 +8874,8 @@ endpoint 1 {
88748874
ram attribute occupancy;
88758875
ram attribute occupancySensorType;
88768876
ram attribute occupancySensorTypeBitmap;
8877-
ram attribute holdTime default = 10;
8878-
callback attribute holdTimeLimits;
8879-
ram attribute featureMap default = 0x01;
8880-
ram attribute clusterRevision default = 5;
8877+
ram attribute featureMap default = 0;
8878+
ram attribute clusterRevision default = 4;
88818879
}
88828880

88838881
server cluster CarbonMonoxideConcentrationMeasurement {
@@ -9345,10 +9343,8 @@ endpoint 2 {
93459343
ram attribute occupancy;
93469344
ram attribute occupancySensorType;
93479345
ram attribute occupancySensorTypeBitmap;
9348-
ram attribute holdTime default = 20;
9349-
callback attribute holdTimeLimits;
9350-
ram attribute featureMap default = 0x01;
9351-
ram attribute clusterRevision default = 5;
9346+
ram attribute featureMap default = 0;
9347+
ram attribute clusterRevision default = 4;
93529348
}
93539349
}
93549350
endpoint 3 {

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+4-68
Original file line numberDiff line numberDiff line change
@@ -18952,38 +18952,6 @@
1895218952
"maxInterval": 65344,
1895318953
"reportableChange": 0
1895418954
},
18955-
{
18956-
"name": "HoldTime",
18957-
"code": 3,
18958-
"mfgCode": null,
18959-
"side": "server",
18960-
"type": "int16u",
18961-
"included": 1,
18962-
"storageOption": "RAM",
18963-
"singleton": 0,
18964-
"bounded": 0,
18965-
"defaultValue": "10",
18966-
"reportable": 1,
18967-
"minInterval": 1,
18968-
"maxInterval": 65534,
18969-
"reportableChange": 0
18970-
},
18971-
{
18972-
"name": "HoldTimeLimits",
18973-
"code": 4,
18974-
"mfgCode": null,
18975-
"side": "server",
18976-
"type": "HoldTimeLimitsStruct",
18977-
"included": 1,
18978-
"storageOption": "External",
18979-
"singleton": 0,
18980-
"bounded": 0,
18981-
"defaultValue": null,
18982-
"reportable": 1,
18983-
"minInterval": 1,
18984-
"maxInterval": 65534,
18985-
"reportableChange": 0
18986-
},
1898718955
{
1898818956
"name": "FeatureMap",
1898918957
"code": 65532,
@@ -18994,7 +18962,7 @@
1899418962
"storageOption": "RAM",
1899518963
"singleton": 0,
1899618964
"bounded": 0,
18997-
"defaultValue": "0x01",
18965+
"defaultValue": "0",
1899818966
"reportable": 1,
1899918967
"minInterval": 1,
1900018968
"maxInterval": 65534,
@@ -19010,7 +18978,7 @@
1901018978
"storageOption": "RAM",
1901118979
"singleton": 0,
1901218980
"bounded": 0,
19013-
"defaultValue": "5",
18981+
"defaultValue": "4",
1901418982
"reportable": 1,
1901518983
"minInterval": 0,
1901618984
"maxInterval": 65344,
@@ -25013,38 +24981,6 @@
2501324981
"maxInterval": 65344,
2501424982
"reportableChange": 0
2501524983
},
25016-
{
25017-
"name": "HoldTime",
25018-
"code": 3,
25019-
"mfgCode": null,
25020-
"side": "server",
25021-
"type": "int16u",
25022-
"included": 1,
25023-
"storageOption": "RAM",
25024-
"singleton": 0,
25025-
"bounded": 0,
25026-
"defaultValue": "20",
25027-
"reportable": 1,
25028-
"minInterval": 1,
25029-
"maxInterval": 65534,
25030-
"reportableChange": 0
25031-
},
25032-
{
25033-
"name": "HoldTimeLimits",
25034-
"code": 4,
25035-
"mfgCode": null,
25036-
"side": "server",
25037-
"type": "HoldTimeLimitsStruct",
25038-
"included": 1,
25039-
"storageOption": "External",
25040-
"singleton": 0,
25041-
"bounded": 0,
25042-
"defaultValue": null,
25043-
"reportable": 1,
25044-
"minInterval": 1,
25045-
"maxInterval": 65534,
25046-
"reportableChange": 0
25047-
},
2504824984
{
2504924985
"name": "FeatureMap",
2505024986
"code": 65532,
@@ -25055,7 +24991,7 @@
2505524991
"storageOption": "RAM",
2505624992
"singleton": 0,
2505724993
"bounded": 0,
25058-
"defaultValue": "0x01",
24994+
"defaultValue": "0",
2505924995
"reportable": 1,
2506024996
"minInterval": 1,
2506124997
"maxInterval": 65534,
@@ -25071,7 +25007,7 @@
2507125007
"storageOption": "RAM",
2507225008
"singleton": 0,
2507325009
"bounded": 0,
25074-
"defaultValue": "5",
25010+
"defaultValue": "4",
2507525011
"reportable": 1,
2507625012
"minInterval": 0,
2507725013
"maxInterval": 65344,

examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp

-57
This file was deleted.

examples/all-clusters-app/linux/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ source_set("chip-all-clusters-common") {
4646
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp",
4747
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp",
4848
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp",
49-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp",
5049
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp",
5150
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp",
5251
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp",

src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp

+7-149
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2020-2024 Project CHIP Authors
3+
* Copyright (c) 2020 Project CHIP Authors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,158 +16,12 @@
1616
*/
1717

1818
#include "occupancy-sensor-server.h"
19-
#include "occupancy-hal.h"
20-
21-
#include <app/AttributeAccessInterfaceRegistry.h>
22-
#include <app/EventLogging.h>
23-
#include <app/data-model/Encode.h>
24-
#include <app/reporting/reporting.h>
25-
#include <app/util/attribute-storage.h>
26-
#include <lib/core/CHIPError.h>
27-
28-
using chip::Protocols::InteractionModel::Status;
29-
30-
namespace chip {
31-
namespace app {
32-
namespace Clusters {
33-
namespace OccupancySensing {
34-
35-
namespace {
36-
Structs::HoldTimeLimitsStruct::Type
37-
sHoldTimeLimitsStructs[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];
38-
39-
uint16_t sHoldTime[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];
40-
} // namespace
41-
42-
CHIP_ERROR OccupancySensingAttrAccess::Init()
43-
{
44-
VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE);
45-
return CHIP_NO_ERROR;
46-
}
47-
48-
void OccupancySensingAttrAccess::Shutdown()
49-
{
50-
unregisterAttributeAccessOverride(this);
51-
}
52-
53-
CHIP_ERROR OccupancySensingAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
54-
{
55-
VerifyOrDie(aPath.mClusterId == app::Clusters::OccupancySensing::Id);
56-
57-
switch (aPath.mAttributeId)
58-
{
59-
case Attributes::FeatureMap::Id:
60-
ReturnErrorOnFailure(aEncoder.Encode(mFeature));
61-
break;
62-
case Attributes::HoldTime::Id: {
6319

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

66-
if (holdTime == nullptr)
67-
{
68-
return CHIP_ERROR_NOT_FOUND;
69-
}
70-
71-
return aEncoder.Encode(*holdTime);
72-
}
73-
case Attributes::HoldTimeLimits::Id: {
74-
75-
Structs::HoldTimeLimitsStruct::Type * holdTimeLimitsStruct = GetHoldTimeLimitsForEndpoint(aPath.mEndpointId);
76-
77-
if (holdTimeLimitsStruct == nullptr)
78-
{
79-
return CHIP_ERROR_NOT_FOUND;
80-
}
81-
82-
return aEncoder.Encode(*holdTimeLimitsStruct);
83-
}
84-
default:
85-
return CHIP_NO_ERROR;
86-
}
87-
88-
return CHIP_NO_ERROR;
89-
}
90-
91-
bool OccupancySensingAttrAccess::HasFeature(Feature aFeature) const
92-
{
93-
return mFeature.Has(aFeature);
94-
}
95-
96-
Structs::HoldTimeLimitsStruct::Type * GetHoldTimeLimitsForEndpoint(EndpointId endpoint)
97-
{
98-
auto index = emberAfGetClusterServerEndpointIndex(endpoint, app::Clusters::OccupancySensing::Id,
99-
MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT);
100-
101-
if (index == kEmberInvalidEndpointIndex)
102-
{
103-
return nullptr;
104-
}
105-
106-
if (index >= ArraySize(sHoldTimeLimitsStructs))
107-
{
108-
ChipLogError(NotSpecified, "Internal error: invalid/unexpected hold time limits index.");
109-
return nullptr;
110-
}
111-
return &sHoldTimeLimitsStructs[index];
112-
}
113-
114-
CHIP_ERROR SetHoldTimeLimits(EndpointId endpointId, const Structs::HoldTimeLimitsStruct::Type & holdTimeLimits)
115-
{
116-
117-
VerifyOrReturnError(kInvalidEndpointId != endpointId, CHIP_ERROR_INVALID_ARGUMENT);
118-
119-
Structs::HoldTimeLimitsStruct::Type * holdTimeLimitsForEndpoint = GetHoldTimeLimitsForEndpoint(endpointId);
120-
VerifyOrReturnError(holdTimeLimitsForEndpoint != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
121-
122-
holdTimeLimitsForEndpoint->holdTimeMin = holdTimeLimits.holdTimeMin;
123-
holdTimeLimitsForEndpoint->holdTimeMax = holdTimeLimits.holdTimeMax;
124-
holdTimeLimitsForEndpoint->holdTimeDefault = holdTimeLimits.holdTimeDefault;
125-
126-
MatterReportingAttributeChangeCallback(endpointId, OccupancySensing::Id, Attributes::HoldTimeLimits::Id);
127-
128-
return CHIP_NO_ERROR;
129-
}
130-
131-
uint16_t * GetHoldTimeForEndpoint(EndpointId endpoint)
132-
{
133-
auto index = emberAfGetClusterServerEndpointIndex(endpoint, app::Clusters::OccupancySensing::Id,
134-
MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT);
135-
136-
if (index == kEmberInvalidEndpointIndex)
137-
{
138-
return nullptr;
139-
}
140-
141-
if (index >= ArraySize(sHoldTimeLimitsStructs))
142-
{
143-
ChipLogError(NotSpecified, "Internal error: invalid/unexpected hold time index.");
144-
return nullptr;
145-
}
146-
return &sHoldTime[index];
147-
}
148-
149-
CHIP_ERROR SetHoldTime(EndpointId endpointId, const uint16_t & holdTime)
150-
{
151-
VerifyOrReturnError(kInvalidEndpointId != endpointId, CHIP_ERROR_INVALID_ARGUMENT);
152-
153-
uint16_t * holdTimeForEndpoint = GetHoldTimeForEndpoint(endpointId);
154-
VerifyOrReturnError(holdTimeForEndpoint != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
155-
156-
*holdTimeForEndpoint = holdTime;
157-
158-
MatterReportingAttributeChangeCallback(endpointId, OccupancySensing::Id, Attributes::HoldTime::Id);
159-
160-
return CHIP_NO_ERROR;
161-
}
162-
163-
} // namespace OccupancySensing
164-
} // namespace Clusters
165-
} // namespace app
166-
} // namespace chip
22+
#include "occupancy-hal.h"
16723

16824
using namespace chip;
169-
using namespace chip::app;
170-
using namespace chip::app::Clusters;
17125
using namespace chip::app::Clusters::OccupancySensing;
17226

17327
//******************************************************************************
@@ -205,6 +59,8 @@ void emberAfOccupancySensingClusterServerInitCallback(EndpointId endpoint)
20559
break;
20660
}
20761
Attributes::OccupancySensorTypeBitmap::Set(endpoint, deviceTypeBitmap);
62+
63+
emberAfPluginOccupancyClusterServerPostInitCallback(endpoint);
20864
}
20965

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

85+
void emberAfPluginOccupancyClusterServerPostInitCallback(EndpointId endpoint) {}
86+
22987
HalOccupancySensorType __attribute__((weak)) halOccupancyGetSensorType(EndpointId endpoint)
23088
{
23189
return HAL_OCCUPANCY_SENSOR_TYPE_PIR;

0 commit comments

Comments
 (0)