Skip to content

Commit 5916714

Browse files
tcarmelveilleuxOliverFan1restyled-commitsbzbarsky-apple
authored andcommittedJul 31, 2024
[un-revert] Occupancy sensing updates for Matter 1.4 (project-chip#34593)
* [occupancy-sensing]Updated occupancy sensing cluster SDK & Sample app(all-clusters-app) implementation to Rev 5 (Matter 1.4) (project-chip#34293) * [occupancy-sensing]Updated occupancy sensing cluster SDK & Sample app(all-clusters-app) implementation to Rev 5 (Matter 1.4) Signed-off-by: Oliver Fan <oliver.fan@nxp.com> * Restyled by whitespace * Restyled by clang-format * Apply suggestions from code review Update Copyright suggestions Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Apply suggestions from code review, remove some dead code. Signed-off-by: Oliver Fan <oliver.fan@nxp.com> * Restyled by clang-format * Apply suggestions from code review * Avoid mixing code-backed and Attribute-store-backed attributes * Avoid global singletons to maintain state * Initialize the cluster from the application * Report features based on code, not on ZAP-configured values Signed-off-by: Oliver Fan <oliver.fan@nxp.com> * Restyled by whitespace * Restyled by clang-format * Restyled by clang-format * Restyled by clang-format * Restyled by clang-format * Update examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Apply suggestions from code review change mHoldTimeLimitsStructs and mHoldTime to sHoldTimeLimitsStructs and sHoldTime put above two variables in an anonymous namespace Signed-off-by: Oliver Fan <oliver.fan@nxp.com> * Restyled by clang-format --------- Signed-off-by: Oliver Fan <oliver.fan@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Don't try to built occupancy-sensor-server as part of the ESP light-switch app. This app does not actually use occupancy-sensor-server, which means that ZAP-provided information the cluster server implementation needs is not available. And light-switch-app does not use occupancy sensor in any way. * Don't try to built occupancy-sensor-server as part of the ESP energy-management-app. --------- Signed-off-by: Oliver Fan <oliver.fan@nxp.com> Co-authored-by: Oliver FAN <156269022+OliverFan1@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent d157918 commit 5916714

File tree

9 files changed

+327
-28
lines changed

9 files changed

+327
-28
lines changed
 

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -8976,8 +8976,10 @@ endpoint 1 {
89768976
ram attribute occupancy;
89778977
ram attribute occupancySensorType;
89788978
ram attribute occupancySensorTypeBitmap;
8979-
ram attribute featureMap default = 0;
8980-
ram attribute clusterRevision default = 4;
8979+
ram attribute holdTime default = 10;
8980+
callback attribute holdTimeLimits;
8981+
ram attribute featureMap default = 0x01;
8982+
ram attribute clusterRevision default = 5;
89818983
}
89828984

89838985
server cluster CarbonMonoxideConcentrationMeasurement {
@@ -9445,8 +9447,10 @@ endpoint 2 {
94459447
ram attribute occupancy;
94469448
ram attribute occupancySensorType;
94479449
ram attribute occupancySensorTypeBitmap;
9448-
ram attribute featureMap default = 0;
9449-
ram attribute clusterRevision default = 4;
9450+
ram attribute holdTime default = 20;
9451+
callback attribute holdTimeLimits;
9452+
ram attribute featureMap default = 0x01;
9453+
ram attribute clusterRevision default = 5;
94509454
}
94519455
}
94529456
endpoint 3 {

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

+68-4
Original file line numberDiff line numberDiff line change
@@ -18997,6 +18997,38 @@
1899718997
"maxInterval": 65344,
1899818998
"reportableChange": 0
1899918999
},
19000+
{
19001+
"name": "HoldTime",
19002+
"code": 3,
19003+
"mfgCode": null,
19004+
"side": "server",
19005+
"type": "int16u",
19006+
"included": 1,
19007+
"storageOption": "RAM",
19008+
"singleton": 0,
19009+
"bounded": 0,
19010+
"defaultValue": "10",
19011+
"reportable": 1,
19012+
"minInterval": 1,
19013+
"maxInterval": 65534,
19014+
"reportableChange": 0
19015+
},
19016+
{
19017+
"name": "HoldTimeLimits",
19018+
"code": 4,
19019+
"mfgCode": null,
19020+
"side": "server",
19021+
"type": "HoldTimeLimitsStruct",
19022+
"included": 1,
19023+
"storageOption": "External",
19024+
"singleton": 0,
19025+
"bounded": 0,
19026+
"defaultValue": null,
19027+
"reportable": 1,
19028+
"minInterval": 1,
19029+
"maxInterval": 65534,
19030+
"reportableChange": 0
19031+
},
1900019032
{
1900119033
"name": "FeatureMap",
1900219034
"code": 65532,
@@ -19007,7 +19039,7 @@
1900719039
"storageOption": "RAM",
1900819040
"singleton": 0,
1900919041
"bounded": 0,
19010-
"defaultValue": "0",
19042+
"defaultValue": "0x01",
1901119043
"reportable": 1,
1901219044
"minInterval": 1,
1901319045
"maxInterval": 65534,
@@ -19023,7 +19055,7 @@
1902319055
"storageOption": "RAM",
1902419056
"singleton": 0,
1902519057
"bounded": 0,
19026-
"defaultValue": "4",
19058+
"defaultValue": "5",
1902719059
"reportable": 1,
1902819060
"minInterval": 0,
1902919061
"maxInterval": 65344,
@@ -25026,6 +25058,38 @@
2502625058
"maxInterval": 65344,
2502725059
"reportableChange": 0
2502825060
},
25061+
{
25062+
"name": "HoldTime",
25063+
"code": 3,
25064+
"mfgCode": null,
25065+
"side": "server",
25066+
"type": "int16u",
25067+
"included": 1,
25068+
"storageOption": "RAM",
25069+
"singleton": 0,
25070+
"bounded": 0,
25071+
"defaultValue": "20",
25072+
"reportable": 1,
25073+
"minInterval": 1,
25074+
"maxInterval": 65534,
25075+
"reportableChange": 0
25076+
},
25077+
{
25078+
"name": "HoldTimeLimits",
25079+
"code": 4,
25080+
"mfgCode": null,
25081+
"side": "server",
25082+
"type": "HoldTimeLimitsStruct",
25083+
"included": 1,
25084+
"storageOption": "External",
25085+
"singleton": 0,
25086+
"bounded": 0,
25087+
"defaultValue": null,
25088+
"reportable": 1,
25089+
"minInterval": 1,
25090+
"maxInterval": 65534,
25091+
"reportableChange": 0
25092+
},
2502925093
{
2503025094
"name": "FeatureMap",
2503125095
"code": 65532,
@@ -25036,7 +25100,7 @@
2503625100
"storageOption": "RAM",
2503725101
"singleton": 0,
2503825102
"bounded": 0,
25039-
"defaultValue": "0",
25103+
"defaultValue": "0x01",
2504025104
"reportable": 1,
2504125105
"minInterval": 1,
2504225106
"maxInterval": 65534,
@@ -25052,7 +25116,7 @@
2505225116
"storageOption": "RAM",
2505325117
"singleton": 0,
2505425118
"bounded": 0,
25055-
"defaultValue": "4",
25119+
"defaultValue": "5",
2505625120
"reportable": 1,
2505725121
"minInterval": 0,
2505825122
"maxInterval": 65344,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include <app/CommandHandler.h>
19+
#include <app/clusters/occupancy-sensor-server/occupancy-hal.h>
20+
#include <app/clusters/occupancy-sensor-server/occupancy-sensor-server.h>
21+
#include <platform/CHIPDeviceLayer.h>
22+
23+
using namespace chip;
24+
using namespace chip::app::Clusters;
25+
using namespace chip::app::Clusters::OccupancySensing;
26+
using namespace chip::app::Clusters::OccupancySensing::Structs;
27+
using namespace chip::DeviceLayer;
28+
29+
using chip::Protocols::InteractionModel::Status;
30+
31+
static std::unique_ptr<OccupancySensingAttrAccess>
32+
gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];
33+
34+
void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId)
35+
{
36+
VerifyOrDie(!gAttrAccess[endpointId]);
37+
38+
gAttrAccess[endpointId] = std::make_unique<OccupancySensingAttrAccess>(
39+
BitMask<OccupancySensing::Feature, uint32_t>(OccupancySensing::Feature::kOther));
40+
41+
OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = {
42+
.holdTimeMin = 1,
43+
.holdTimeMax = 300,
44+
.holdTimeDefault = 10,
45+
};
46+
47+
uint16_t holdTime = 10;
48+
49+
if (gAttrAccess[endpointId])
50+
{
51+
gAttrAccess[endpointId]->Init();
52+
53+
SetHoldTimeLimits(endpointId, holdTimeLimits);
54+
55+
SetHoldTime(endpointId, holdTime);
56+
}
57+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ source_set("chip-all-clusters-common") {
5050
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp",
5151
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp",
5252
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp",
53+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp",
5354
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp",
5455
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp",
5556
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp",

‎examples/energy-management-app/esp32/main/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ set(SRC_DIRS_LIST
5454
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server"
5555
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/device-energy-management-server"
5656
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning"
57-
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server"
5857
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server"
5958
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor"
6059
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server"

‎examples/light-switch-app/esp32/main/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ idf_component_register(PRIV_INCLUDE_DIRS
4646
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server"
4747
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server"
4848
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning"
49-
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server"
5049
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server"
5150
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor"
5251
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server"

0 commit comments

Comments
 (0)