Skip to content

Commit

Permalink
Add Thermostat app and add shell for scheduling attributes (#8540)
Browse files Browse the repository at this point in the history
* Initial creation of thermostat dev testing app

* Added stubbed in support for low power needed for rebase

* Added optional attributes to thermostat.zap for scheduling

* Added Thermostat cluster scheduling attributes

* Regenerate files after controller.zap file changes

* Restyled by gn

* errorcode -> csr (#8522)

* Initial creation of thermostat dev testing app

* Added stubbed in support for low power needed for rebase

* Added optional attributes to thermostat.zap for scheduling

* Added Thermostat cluster scheduling attributes

* Regenerate files after controller.zap file changes

* Restyled by gn

* Adding Thermostat Attributes for scheduling to the all clusters zap to pass darwin test

* regen all files

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Austin Hsieh <[email protected]>
  • Loading branch information
3 people authored Jul 26, 2021
1 parent 762a204 commit bb9a239
Show file tree
Hide file tree
Showing 42 changed files with 34,568 additions and 124 deletions.
14 changes: 14 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
enable_linux_lighting_app_build =
enable_default_builds && (host_os == "linux" || host_os == "mac")

# Build the Linux thermostat app example.
enable_linux_thermostat_app_build =
enable_default_builds && (host_os == "linux" || host_os == "mac")

# Build the cc13x2x7_26x2x7 lock app example.
enable_cc13x2x7_26x2x7_lock_app_build = enable_ti_simplelink_builds

Expand Down Expand Up @@ -321,6 +325,13 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}
}

if (enable_linux_thermostat_app_build) {
group("linux_thermostat_app") {
deps =
[ "${chip_root}/examples/thermostat/linux(${standalone_toolchain})" ]
}
}

if (enable_linux_tv_app_build) {
group("linux_tv_app") {
deps = [ "${chip_root}/examples/tv-app/linux(${standalone_toolchain})" ]
Expand Down Expand Up @@ -418,6 +429,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (enable_linux_all_clusters_app_build) {
deps += [ ":linux_all_clusters_app" ]
}
if (enable_linux_thermostat_app_build) {
deps += [ ":linux_thermostat_app" ]
}
if (enable_linux_tv_app_build) {
deps += [ ":linux_tv_app" ]
}
Expand Down
75 changes: 75 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -9866,6 +9866,81 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "start of week",
"code": 32,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "number of weekly transitions",
"code": 33,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "7",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "number of daily transitions",
"code": 34,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "4",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "temperature setpoint hold",
"code": 35,
"mfgCode": null,
"side": "server",
"included": 0,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x00",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "feature map",
"code": 65532,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x000b",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "cluster revision",
"code": 65533,
Expand Down
260 changes: 137 additions & 123 deletions examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h

Large diffs are not rendered by default.

144 changes: 144 additions & 0 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18687,6 +18687,10 @@ class ReadTestClusterClusterRevision : public ModelCommand
| * OccupiedHeatingSetpoint | 0x0012 |
| * ControlSequenceOfOperation | 0x001B |
| * SystemMode | 0x001C |
| * StartOfWeek | 0x0020 |
| * NumberOfWeeklyTransitions | 0x0021 |
| * NumberOfDailyTransitions | 0x0022 |
| * FeatureMap | 0xFFFC |
| * ClusterRevision | 0xFFFD |
\*----------------------------------------------------------------------------*/

Expand Down Expand Up @@ -19241,6 +19245,142 @@ class WriteThermostatSystemMode : public ModelCommand
uint8_t mValue;
};

/*
* Attribute StartOfWeek
*/
class ReadThermostatStartOfWeek : public ModelCommand
{
public:
ReadThermostatStartOfWeek() : ModelCommand("read")
{
AddArgument("attr-name", "start-of-week");
ModelCommand::AddArguments();
}

~ReadThermostatStartOfWeek()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0201) command (0x00) on endpoint %" PRIu8, endpointId);

chip::Controller::ThermostatCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ReadAttributeStartOfWeek(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<Int8uAttributeCallback> * onSuccessCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*
* Attribute NumberOfWeeklyTransitions
*/
class ReadThermostatNumberOfWeeklyTransitions : public ModelCommand
{
public:
ReadThermostatNumberOfWeeklyTransitions() : ModelCommand("read")
{
AddArgument("attr-name", "number-of-weekly-transitions");
ModelCommand::AddArguments();
}

~ReadThermostatNumberOfWeeklyTransitions()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0201) command (0x00) on endpoint %" PRIu8, endpointId);

chip::Controller::ThermostatCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ReadAttributeNumberOfWeeklyTransitions(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<Int8uAttributeCallback> * onSuccessCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*
* Attribute NumberOfDailyTransitions
*/
class ReadThermostatNumberOfDailyTransitions : public ModelCommand
{
public:
ReadThermostatNumberOfDailyTransitions() : ModelCommand("read")
{
AddArgument("attr-name", "number-of-daily-transitions");
ModelCommand::AddArguments();
}

~ReadThermostatNumberOfDailyTransitions()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0201) command (0x00) on endpoint %" PRIu8, endpointId);

chip::Controller::ThermostatCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ReadAttributeNumberOfDailyTransitions(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<Int8uAttributeCallback> * onSuccessCallback =
new chip::Callback::Callback<Int8uAttributeCallback>(OnInt8uAttributeResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*
* Attribute FeatureMap
*/
class ReadThermostatFeatureMap : public ModelCommand
{
public:
ReadThermostatFeatureMap() : ModelCommand("read")
{
AddArgument("attr-name", "feature-map");
ModelCommand::AddArguments();
}

~ReadThermostatFeatureMap()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0201) command (0x00) on endpoint %" PRIu8, endpointId);

chip::Controller::ThermostatCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ReadAttributeFeatureMap(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<Int32uAttributeCallback> * onSuccessCallback =
new chip::Callback::Callback<Int32uAttributeCallback>(OnInt32uAttributeResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*
* Attribute ClusterRevision
*/
Expand Down Expand Up @@ -24031,6 +24171,10 @@ void registerClusterThermostat(Commands & commands)
make_unique<WriteThermostatControlSequenceOfOperation>(),
make_unique<ReadThermostatSystemMode>(),
make_unique<WriteThermostatSystemMode>(),
make_unique<ReadThermostatStartOfWeek>(),
make_unique<ReadThermostatNumberOfWeeklyTransitions>(),
make_unique<ReadThermostatNumberOfDailyTransitions>(),
make_unique<ReadThermostatFeatureMap>(),
make_unique<ReadThermostatClusterRevision>(),
};

Expand Down
25 changes: 25 additions & 0 deletions examples/thermostat/linux/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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.
# 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.

import("//build_overrides/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
import("//args.gni")
}
38 changes: 38 additions & 0 deletions examples/thermostat/linux/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.
# 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.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

executable("thermostat-app") {
sources = [
"include/low-power/LowPowerManager.cpp",
"include/low-power/LowPowerManager.h",
"main.cpp",
]

deps = [
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/examples/thermostat/thermostat-common",
"${chip_root}/src/lib",
]

cflags = [ "-Wconversion" ]

output_dir = root_out_dir
}

group("linux") {
deps = [ ":thermostat-app" ]
}
23 changes: 23 additions & 0 deletions examples/thermostat/linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2020 Project CHIP Authors
# All rights reserved.
#
# 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.
#

from generic_node_image
RUN apt-get install -y libglib2.0
COPY out/debug/chip-all-clusters-app /usr/bin/
COPY entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh", "server"]
17 changes: 17 additions & 0 deletions examples/thermostat/linux/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.
# 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.

import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")
1 change: 1 addition & 0 deletions examples/thermostat/linux/build_overrides
Loading

0 comments on commit bb9a239

Please sign in to comment.