Skip to content

Commit

Permalink
Merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nivi-apple committed Feb 9, 2024
1 parent e4c4c38 commit 2721cb2
Show file tree
Hide file tree
Showing 22 changed files with 2,458 additions and 39 deletions.
121 changes: 121 additions & 0 deletions #0001-Thermostat-changes-to-support-Apple-Thermostat-exten.patch#
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
From 650bacd3f9eb91d03c15660831154dcb03794d8a Mon Sep 17 00:00:00 2001
From: Nivedita Sarkar <[email protected]>
Date: Fri, 9 Feb 2024 09:37:39 -0800
Subject: [PATCH] Thermostat changes to support Apple Thermostat extensions

---
.../thermostat-server/thermostat-server.cpp | 22 ++--------
.../thermostat-server/thermostat-server.h | 43 +++++++++++++++++++
2 files changed, 46 insertions(+), 19 deletions(-)
create mode 100644 src/app/clusters/thermostat-server/thermostat-server.h

diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp
index f5a5157a7e..2feceb56a6 100644
--- a/src/app/clusters/thermostat-server/thermostat-server.cpp
+++ b/src/app/clusters/thermostat-server/thermostat-server.cpp
@@ -15,17 +15,14 @@
* limitations under the License.
*/

-#include <app/util/af.h>
-
-#include <app/util/attribute-storage.h>
+#include "thermostat-server.h"
+#include "apple-thermostat-extension-server.h"

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app/CommandHandler.h>
-#include <app/ConcreteAttributePath.h>
-#include <app/ConcreteCommandPath.h>
#include <app/util/error-mapping.h>
#include <lib/core/CHIPEncoding.h>

@@ -65,17 +62,6 @@ constexpr int8_t kDefaultDeadBand = 25; // 2.5C is the default

#define FEATURE_MAP_DEFAULT FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO

-namespace {
-
-class ThermostatAttrAccess : public AttributeAccessInterface
-{
-public:
- ThermostatAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), Thermostat::Id) {}
-
- CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
- CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;
-};
-
ThermostatAttrAccess gThermostatAttrAccess;

CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
@@ -180,8 +166,6 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath,
return CHIP_NO_ERROR;
}

-} // anonymous namespace
-
void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
{
// TODO
@@ -931,5 +915,5 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co

void MatterThermostatPluginServerInitCallback()
{
- registerAttributeAccessOverride(&gThermostatAttrAccess);
+ RegisterAppleThermostatExtAttrAccess(&gThermostatAttrAccess);
}
diff --git a/src/app/clusters/thermostat-server/thermostat-server.h b/src/app/clusters/thermostat-server/thermostat-server.h
new file mode 100644
index 0000000000..b41d89f19f
--- /dev/null
+++ b/src/app/clusters/thermostat-server/thermostat-server.h
@@ -0,0 +1,43 @@
+/**
+ *
+ * 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.
+ */
+
+/****************************************************************************
+ * @file
+ * @brief Thermostat cluster Attribute Access Interface
+ *
+ *******************************************************************************
+ ******************************************************************************/
+
+#pragma once
+
+#include <app/AttributeAccessInterface.h>
+#include <app/ConcreteAttributePath.h>
+#include <app/ConcreteCommandPath.h>
+#include <app-common/zap-generated/ids/Clusters.h>
+
+class ThermostatAttrAccess : public chip::app::AttributeAccessInterface
+{
+
+public:
+ ThermostatAttrAccess() : AttributeAccessInterface(chip::Optional<chip::EndpointId>::Missing(), chip::app::Clusters::Thermostat::Id) {}
+
+ CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) override;
+ CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & aPath, chip::app::AttributeValueDecoder & aDecoder) override;
+};
+
+int16_t EnforceHeatingSetpointLimits(int16_t HeatingSetpoint, chip::EndpointId endpoint);
+int16_t EnforceCoolingSetpointLimits(int16_t CoolingSetpoint, chip::EndpointId endpoint);
--
2.39.2 (Apple Git-144)

71 changes: 71 additions & 0 deletions 0001-Patch-thermostat-to-build-with-Apple-Thermostat-exte.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
From 452cc40204883de1491fe3d751a0f6c12bbedad3 Mon Sep 17 00:00:00 2001
From: Nivedita Sarkar <[email protected]>
Date: Fri, 9 Feb 2024 09:17:24 -0800
Subject: [PATCH] Patch thermostat to build with Apple Thermostat extension
code

---
.../thermostat-server/thermostat-server.cpp | 22 +++----------------
1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp
index f5a5157a7e..2feceb56a6 100644
--- a/src/app/clusters/thermostat-server/thermostat-server.cpp
+++ b/src/app/clusters/thermostat-server/thermostat-server.cpp
@@ -15,17 +15,14 @@
* limitations under the License.
*/

-#include <app/util/af.h>
-
-#include <app/util/attribute-storage.h>
+#include "thermostat-server.h"
+#include "apple-thermostat-extension-server.h"

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app/CommandHandler.h>
-#include <app/ConcreteAttributePath.h>
-#include <app/ConcreteCommandPath.h>
#include <app/util/error-mapping.h>
#include <lib/core/CHIPEncoding.h>

@@ -65,17 +62,6 @@ constexpr int8_t kDefaultDeadBand = 25; // 2.5C is the default

#define FEATURE_MAP_DEFAULT FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO

-namespace {
-
-class ThermostatAttrAccess : public AttributeAccessInterface
-{
-public:
- ThermostatAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), Thermostat::Id) {}
-
- CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
- CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;
-};
-
ThermostatAttrAccess gThermostatAttrAccess;

CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
@@ -180,8 +166,6 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath,
return CHIP_NO_ERROR;
}

-} // anonymous namespace
-
void emberAfThermostatClusterServerInitCallback(chip::EndpointId endpoint)
{
// TODO
@@ -931,5 +915,5 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co

void MatterThermostatPluginServerInitCallback()
{
- registerAttributeAccessOverride(&gThermostatAttrAccess);
+ RegisterAppleThermostatExtAttrAccess(&gThermostatAttrAccess);
}
--
2.39.2 (Apple Git-144)

58 changes: 58 additions & 0 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,14 @@ cluster Thermostat = 513 {
kHeatPumpInverter = 4;
}

enum ApplePresetScenarioEnum : enum8 {
kOccupied = 0;
kUnoccupied = 1;
kGoingToSleep = 2;
kSleep = 3;
kVacation = 4;
}

enum ControlSequenceOfOperationEnum : enum8 {
kCoolingOnly = 0;
kCoolingWithReheat = 1;
Expand Down Expand Up @@ -1771,6 +1779,12 @@ cluster Thermostat = 513 {
kHeat = 4;
}

enum ValenciaStateNotFollowingReasonEnum : enum8 {
kUnknown = 0;
kDREvent = 1;
kOngoingHold = 2;
}

bitmap ACErrorCodeBitmap : bitmap32 {
kCompressorFail = 0x1;
kRoomSensorFail = 0x2;
Expand Down Expand Up @@ -1873,6 +1887,19 @@ cluster Thermostat = 513 {
optional nullable boolean builtIn = 5;
}

struct ApplePresetStruct {
nullable octet_string<16> presetHandle = 0;
ApplePresetScenarioEnum presetScenario = 1;
temperature coolingSetpoint = 2;
temperature heatingSetpoint = 3;
nullable boolean builtIn = 4;
}

struct ApplePresetTypeStruct {
ApplePresetScenarioEnum presetScenario = 0;
int8u numberOfPresets = 1;
}

struct PresetStruct {
nullable octet_string<16> presetHandle = 0;
PresetScenarioEnum presetScenario = 1;
Expand Down Expand Up @@ -1968,6 +1995,15 @@ cluster Thermostat = 513 {
readonly attribute optional TemperatureSetpointHoldPolicyBitmap temperatureSetpointHoldPolicy = 83;
readonly attribute optional nullable epoch_s setpointHoldExpiryTimestamp = 84;
readonly attribute optional nullable QueuedPresetStruct queuedPreset = 85;
attribute boolean alvaradoEnabled = 323551232;
readonly attribute nullable int16s setpointOffset = 323551233;
attribute boolean valenciaStateEnabled = 323551234;
readonly attribute nullable ValenciaStateNotFollowingReasonEnum valenciaStateNotFollowingReason = 323551235;
readonly attribute ApplePresetTypeStruct applePresetTypes[] = 323551236;
readonly attribute int8u appleNumberOfPresets = 323551237;
attribute ApplePresetStruct applePresets[] = 323551238;
readonly attribute boolean applePresetsSchedulesEditable = 323551239;
readonly attribute nullable octet_string<16> appleActivePresetHandle = 323551240;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -2016,6 +2052,10 @@ cluster Thermostat = 513 {
TemperatureSetpointHoldPolicyBitmap temperatureSetpointHoldPolicy = 0;
}

request struct AppleStartPresetsSchedulesEditRequestRequest {
int8u timeoutSeconds = 0;
}

/** Command description for SetpointRaiseLower */
command SetpointRaiseLower(SetpointRaiseLowerRequest): DefaultSuccess = 0;
/** Command description for SetWeeklySchedule */
Expand All @@ -2038,6 +2078,12 @@ cluster Thermostat = 513 {
command access(invoke: manage) CancelSetActivePresetRequest(): DefaultSuccess = 10;
/** This command sets the set point hold policy. */
command SetTemperatureSetpointHoldPolicy(SetTemperatureSetpointHoldPolicyRequest): DefaultSuccess = 11;
/** This command is used to start editing the presets. */
command AppleStartPresetsSchedulesEditRequest(AppleStartPresetsSchedulesEditRequestRequest): DefaultSuccess = 323551472;
/** This command is used to cancel editing presets. */
command AppleCancelPresetsSchedulesEditRequest(): DefaultSuccess = 323551473;
/** This command is used to notify the server that all edits are done and should be committed. */
command AppleCommitPresetsSchedulesRequest(): DefaultSuccess = 323551474;
}

/** An interface for configuring the user interface of a thermostat (which may be remote from the thermostat). */
Expand Down Expand Up @@ -2486,8 +2532,20 @@ endpoint 1 {
callback attribute attributeList;
ram attribute featureMap default = 0x23;
ram attribute clusterRevision default = 6;
ram attribute alvaradoEnabled;
ram attribute setpointOffset;
ram attribute valenciaStateEnabled;
ram attribute valenciaStateNotFollowingReason;
callback attribute applePresetTypes;
ram attribute appleNumberOfPresets;
callback attribute applePresets;
ram attribute applePresetsSchedulesEditable;
ram attribute appleActivePresetHandle;

handle command SetpointRaiseLower;
handle command AppleStartPresetsSchedulesEditRequest;
handle command AppleCancelPresetsSchedulesEditRequest;
handle command AppleCommitPresetsSchedulesRequest;
}

server cluster ThermostatUserInterfaceConfiguration {
Expand Down
Loading

0 comments on commit 2721cb2

Please sign in to comment.