Skip to content

Commit

Permalink
add water valve project
Browse files Browse the repository at this point in the history
  • Loading branch information
shih840426 committed Jul 3, 2024
1 parent 7e16d6b commit a37b67c
Show file tree
Hide file tree
Showing 30 changed files with 6,811 additions and 24 deletions.
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"smoke-alarm-app",
"temperature-measurement-app",
"thermostat",
"water-valve-app",
"window-app"
],
"default": ""
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/rt58x/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ chip_progress_logging = true
chip_detail_logging = false

#enable matter+ble multi control
raf_enable_multi_control = true
raf_enable_multi_control = false

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
Expand Down
3 changes: 3 additions & 0 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,9 @@ endpoint 0 {
}

server cluster BasicInformation {
emits event StartUp;
emits event ShutDown;
emits event Leave;
callback attribute dataModelRevision;
callback attribute vendorName;
callback attribute vendorID;
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/lock-common/lock-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"endpointTypes": [
{
"id": 1,
"name": "Anonymous Endpoint Type",
"name": "MA-rootdevice",
"deviceTypeRef": {
"code": 22,
"profileId": 259,
Expand Down Expand Up @@ -4279,7 +4279,7 @@
],
"endpoints": [
{
"endpointTypeName": "Anonymous Endpoint Type",
"endpointTypeName": "MA-rootdevice",
"endpointTypeIndex": 0,
"profileId": 259,
"endpointId": 0,
Expand Down
2 changes: 1 addition & 1 deletion examples/smart-plug-app/rt58x/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(void)
#endif

info( "==================================================\r\n");
info( "Rafael-SmartPlug-example(Matter 1.3) starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
info( "Rafael-Smart-Plug-example(Matter 1.3) starting Version %d\r\n", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
info( "==================================================\r\n");
err = PlatformMgr().InitChipStack();
if (err != CHIP_NO_ERROR)
Expand Down
48 changes: 42 additions & 6 deletions examples/smoke-alarm-app/rt58x/src/SmokeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,27 @@ void SmokeManager::SelfTestTimerEventHandler(TimerHandle_t xTimer)
}
void SmokeManager::ToggleSmokeState()
{
mSmokeAlarmState = (mSmokeAlarmState == AlarmStateEnum::kNormal) ? AlarmStateEnum::kWarning :
(mSmokeAlarmState == AlarmStateEnum::kWarning) ? AlarmStateEnum::kCritical :
AlarmStateEnum::kNormal;
switch(mSmokeAlarmState)
{
case AlarmStateEnum::kNormal:
{
mSmokeAlarmState = AlarmStateEnum::kWarning;
ChipLogProgress(NotSpecified,"Smoke State: Warning");
}
break;
case AlarmStateEnum::kWarning:
{
mSmokeAlarmState = AlarmStateEnum::kCritical;
ChipLogProgress(NotSpecified,"Smoke State: Critical");
}
break;
case AlarmStateEnum::kCritical:
{
mSmokeAlarmState = AlarmStateEnum::kNormal;
ChipLogProgress(NotSpecified,"Smoke State: Normal");
}
break;
}
PlatformMgr().LockChipStack();
SmokeCoAlarmServer::Instance().SetSmokeState(1, mSmokeAlarmState);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder);
Expand All @@ -107,9 +125,27 @@ void SmokeManager::ToggleSmokeState()

void SmokeManager::ToggleCOState()
{
mCOAlarmState = (mCOAlarmState == AlarmStateEnum::kNormal) ? AlarmStateEnum::kWarning :
(mCOAlarmState == AlarmStateEnum::kWarning) ? AlarmStateEnum::kCritical :
AlarmStateEnum::kNormal;
switch(mCOAlarmState)
{
case AlarmStateEnum::kNormal:
{
mCOAlarmState = AlarmStateEnum::kWarning;
ChipLogProgress(NotSpecified,"CO State: Warning");
}
break;
case AlarmStateEnum::kWarning:
{
mCOAlarmState = AlarmStateEnum::kCritical;
ChipLogProgress(NotSpecified,"CO State: Critical");
}
break;
case AlarmStateEnum::kCritical:
{
mCOAlarmState = AlarmStateEnum::kNormal;
ChipLogProgress(NotSpecified,"CO State: Normal");
}
break;
}
PlatformMgr().LockChipStack();
SmokeCoAlarmServer::Instance().SetCOState(1, mCOAlarmState);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder);
Expand Down
12 changes: 6 additions & 6 deletions examples/smoke-alarm-app/rt58x/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
{
ClusterId clusterId = attributePath.mClusterId;
AttributeId attributeId = attributePath.mAttributeId;
ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
// ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));

if (clusterId == Identify::Id)
{
ChipLogProgress(Zcl, "Identify attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u",
ChipLogValueMEI(attributeId), type, *value, size);
}
else if (clusterId == SmokeCoAlarm::Id)
{
ChipLogProgress(Zcl, "SmokeCoAlarm attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u",
ChipLogValueMEI(attributeId), type, *value, size);
}
// else if (clusterId == SmokeCoAlarm::Id)
// {
// ChipLogProgress(Zcl, "SmokeCoAlarm attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u",
// ChipLogValueMEI(attributeId), type, *value, size);
// }
}

void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,7 @@
},
{
"id": 2,
"name": "Anonymous Endpoint Type",
"name": "MA-smokecoalarm",
"deviceTypeRef": {
"code": 118,
"profileId": 259,
Expand Down Expand Up @@ -3591,7 +3591,7 @@
"parentEndpointIdentifier": null
},
{
"endpointTypeName": "Anonymous Endpoint Type",
"endpointTypeName": "MA-smokecoalarm",
"endpointTypeIndex": 1,
"profileId": 259,
"endpointId": 1,
Expand Down
27 changes: 27 additions & 0 deletions examples/water-valve-app/rt58x/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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 = {
target_cpu = "arm"
target_os = "freertos"
import("//args.gni")
}
151 changes: 151 additions & 0 deletions examples/water-valve-app/rt58x/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# 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")
import("//build_overrides/pigweed.gni")
import("//build_overrides/rt58x_sdk.gni")

import("${build_root}/config/defaults.gni")
import("${chip_root}/src/platform/device.gni")
import("${rt58x_sdk_build_root}/rt58x_executable.gni")
import("${rt58x_sdk_build_root}/rt58x_sdk.gni")

assert(current_os == "freertos")

rt58x_project_dir = "${chip_root}/examples/water-valve-app/rt58x"
examples_plat_dir = "${chip_root}/examples/platform/rt58x"

# _freertos_root = "${chip_root}/third_party/rafael/sdk/Portable/freertos/repo"

declare_args() {
# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840

# Enable Sleepy end device
enable_sleepy_device = false

# OTA timeout in seconds
OTA_periodic_query_timeout = 86400

#using default certification declaration
chip_using_default_cd = false
}

rt58x_sdk("sdk") {
sources = [
"${rt58x_project_dir}/include/CHIPProjectConfig.h",
]

include_dirs = [
"${chip_root}/src/platform/RT58x",
"${rt58x_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
]

defines = [
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

if (chip_build_platform_attestation_credentials_provider) {
defines += [ "RAFAEL_CERTS_ENABLED=1" ]
if(chip_using_default_cd) {
defines += [ "RAFAEL_CERTS_USE_EXAMPLE_CD=1" ]
}
}
}

rt58x_executable("water-valve_app") {
output_name = "chip-rt58x-water-valve-app-example.out"
include_dirs = [ "include" ]
defines = []

sources = [
"${examples_plat_dir}/heap_4_rt58x.c",
"${examples_plat_dir}/init_rt58xPlatform.cpp",
"${examples_plat_dir}/matter_config.cpp",
"${examples_plat_dir}/uart.cpp",
"include/WaterValveManager.h",
"src/AppTask.cpp",
"src/WaterValveManager.cpp",
"src/ZclCallbacks.cpp",
"src/init_water-valve-app_rt58xPlatform.cpp",
"src/main.cpp",
]
if (chip_build_libshell) {
sources += [ "${examples_plat_dir}/cmd_rafael.cpp" ]
}
deps = [
":sdk",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/examples/water-valve-app/water-valve-common",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
"${chip_root}/third_party/rafael/sdk/Portable/freertos",
]

# OpenThread Settings
if (chip_enable_openthread) {
deps += [
"${chip_root}/third_party/openthread:openthread",
"${chip_root}/third_party/openthread:openthread-platform",
"${examples_plat_dir}:rt58x-matter-shell",
]
}

if (!enable_sleepy_device) {
deps += [ "${examples_plat_dir}:rt58x-subscription-callback" ]
}

deps += [
"${chip_root}/src/lib/shell",
"${chip_root}/src/lib/shell:shell_core",
]

if (chip_enable_ota_requestor) {
defines += [ "RT58x_OTA_ENABLED=1" ]
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ]
}

ldscript = "${examples_plat_dir}/ldscript/rt58x.ld"

inputs = [ ldscript ]

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]

ldflags += [
"-Wl,--print-memory-usage",
"-fstack-usage",
"-Wunused-variable",
]

# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ "${chip_root}/src/platform/RT58x:rt58x-attestation-credentials" ]
}

output_dir = root_out_dir
}

group("rt58x") {
deps = [ ":water-valve_app" ]
}

group("default") {
deps = [ ":rt58x" ]
}
Loading

0 comments on commit a37b67c

Please sign in to comment.