Skip to content

Commit

Permalink
Remove door lock cluster from all-clusters-app (#29802)
Browse files Browse the repository at this point in the history
* Remove door lock cluster from all-clusters-app

Both QA and the CI are using the door-lock app for all testing of
the door lock cluster. The all-clusters version is not well tested,
and is missing some command handlers.
Removing this in all-clusters in favour of the door lock app so we
don't have to maintain it in two places and to save some space.

* Fix esp32 build file

* Remove door lock support for esp32

* Remove door lock support from telink

* Remove door lock support for nrfconnect

* Fix esp32 compilation

* Restyle

---------

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
cecille and andreilitvin authored Oct 24, 2023
1 parent a010ae4 commit 57f0a73
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 1,367 deletions.
600 changes: 0 additions & 600 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

Large diffs are not rendered by default.

682 changes: 0 additions & 682 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

Large diffs are not rendered by default.

48 changes: 0 additions & 48 deletions examples/all-clusters-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include <app/server/OnboardingCodesUtil.h>
#include <lock/BoltLockManager.h>

#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
#include "esp_spi_flash.h"
Expand Down Expand Up @@ -94,12 +93,6 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent)
// cancel, if required.
sAppTask.StartTimer(FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
sAppTask.mFunction = kFunction_FactoryReset;
// Turn off all LEDs before starting blink to make sure blink is
// co-ordinated.
// sStatusLED.Set(false);
// sLockLED.Set(false);
// sStatusLED.Blink(500);
// sLockLED.Blink(500);
}
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)
{
Expand Down Expand Up @@ -135,47 +128,6 @@ void AppTask::StartTimer(uint32_t aTimeoutInMs)
}
mFunctionTimerActive = true;
}
void AppTask::ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor)
{
// If the action has been initiated by the lock, update the bolt lock trait
// and start flashing the LEDs rapidly to indicate action initiation.
if (aAction == BoltLockManager::LOCK_ACTION)
{
ESP_LOGI(TAG, "Lock Action has been initiated");
}
else if (aAction == BoltLockManager::UNLOCK_ACTION)
{
ESP_LOGI(TAG, "Unlock Action has been initiated");
}
if (aActor == AppEvent::kEventType_Button)
{
sAppTask.mSyncClusterToButtonAction = true;
}
// sLockLED.Blink(50, 50);
}
void AppTask::ActionCompleted(BoltLockManager::Action_t aAction)
{
// if the action has been completed by the lock, update the bolt lock trait.
// Turn on the lock LED if in a LOCKED state OR
// Turn off the lock LED if in an UNLOCKED state.
if (aAction == BoltLockManager::LOCK_ACTION)
{
ESP_LOGI(TAG, "Lock Action has been completed");
// sLockLED.Set(true);
}
else if (aAction == BoltLockManager::UNLOCK_ACTION)
{
ESP_LOGI(TAG, "Unlock Action has been completed");
// sLockLED.Set(false);
}
}

CHIP_ERROR AppTask::LockInit()
{
ReturnErrorOnFailure(BoltLockMgr().InitLockState());
BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
return CHIP_NO_ERROR;
}

CHIP_ERROR AppTask::Init()
{
Expand Down
2 changes: 0 additions & 2 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/lock"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/mode-support"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd"
Expand Down Expand Up @@ -72,7 +71,6 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/icd-management-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server"
Expand Down
17 changes: 1 addition & 16 deletions examples/all-clusters-app/esp32/main/DeviceWithDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,7 @@ class EditAttributeListModel : public TouchesMatterStackModel

ESP_LOGI(TAG, "editing attribute as string: '%s' (%s)", value.c_str(), i == 0 ? "+" : "-");
ESP_LOGI(TAG, "name and cluster: '%s' (%s)", name.c_str(), cluster.c_str());
if (name == "State" && cluster == "Lock")
{
value = (value == "Closed") ? "Open" : "Closed";
using namespace chip::app::Clusters;
// update the doorlock attribute here
auto attributeValue = value == "Closed" ? DoorLock::DlLockState::kLocked : DoorLock::DlLockState::kUnlocked;
DoorLock::Attributes::LockState::Set(DOOR_LOCK_SERVER_ENDPOINT, attributeValue);
}
else if (name == "Charge level" && cluster == "Power Source")
if (name == "Charge level" && cluster == "Power Source")
{
using namespace chip::app::Clusters::PowerSource;
auto attributeValue = BatChargeLevelEnum::kOk;
Expand Down Expand Up @@ -578,13 +570,6 @@ void SetupPretendDevices()
// write the temp attribute
chip::app::Clusters::TemperatureMeasurement::Attributes::MeasuredValue::Set(1, static_cast<int16_t>(21 * 100));

AddDevice("Door Lock");
AddEndpoint("Default");
AddCluster("Lock");
AddAttribute("State", "Open");
// write the door lock state
chip::app::Clusters::DoorLock::Attributes::LockState::Set(DOOR_LOCK_SERVER_ENDPOINT,
chip::app::Clusters::DoorLock::DlLockState::kUnlocked);
AddDevice("Garage 1");
AddEndpoint("Door 1");
AddCluster("Door");
Expand Down
51 changes: 51 additions & 0 deletions examples/all-clusters-app/esp32/main/include/AppEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
*
* Copyright (c) 2022 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.
*/

#pragma once
#include "esp_system.h"

struct AppEvent;
typedef void (*EventHandler)(AppEvent *);

struct AppEvent
{
enum AppEventTypes
{
kEventType_Button = 0,
kEventType_Timer,
kEventType_Light,
kEventType_Install,
};

uint16_t mType;

union
{
struct
{
uint8_t mPinNo;
uint8_t mAction;
} mButtonEvent;
struct
{
void * mContext;
} mTimerEvent;
};

EventHandler mHandler;
};
7 changes: 1 addition & 6 deletions examples/all-clusters-app/esp32/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

#pragma once
#include <lock/AppEvent.h>
#include <lock/BoltLockManager.h>
#include "AppEvent.h"
#include <platform/CHIPDeviceLayer.h>

// Application-defined error codes in the CHIP_ERROR space.
Expand All @@ -39,14 +38,10 @@ class AppTask
void PostEvent(const AppEvent * event);
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
static void ButtonPressedAction(AppEvent * aEvent);
CHIP_ERROR LockInit();

private:
CHIP_ERROR Init();

static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor);
static void ActionCompleted(BoltLockManager::Action_t aAction);

void StartTimer(uint32_t aTimeoutMs);
void CancelTimer(void);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <vector>

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/clusters/door-lock-server/door-lock-server.h>
#include <app/server/Dnssd.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
Expand Down
11 changes: 3 additions & 8 deletions examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,12 @@ static void InitServer(intptr_t context)
emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false);
#endif

CHIP_ERROR err = GetAppTask().LockInit();
if (err != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize app task lock, err:%" CHIP_ERROR_FORMAT, err.Format());
}

#if CONFIG_DEVICE_TYPE_M5STACK
SetupPretendDevices();
#endif
err = app::Clusters::ModeSelect::StaticSupportedModesManager::getStaticSupportedModesManagerInstance().InitEndpointArray(
FIXED_ENDPOINT_COUNT);
CHIP_ERROR err =
app::Clusters::ModeSelect::StaticSupportedModesManager::getStaticSupportedModesManagerInstance().InitEndpointArray(
FIXED_ENDPOINT_COUNT);
if (err != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize endpoint array for supported-modes, err:%" CHIP_ERROR_FORMAT, err.Format());
Expand Down
2 changes: 0 additions & 2 deletions examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ if (is_libfuzzer) {

deps = [
":chip-all-clusters-common",
":chip-lock-app-common",
"${chip_root}/examples/platform/linux:app-main",
]

Expand All @@ -102,7 +101,6 @@ if (is_libfuzzer) {

deps = [
":chip-all-clusters-common",
":chip-lock-app-common",
"${chip_root}/examples/platform/linux:app-main",
]

Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ target_include_directories(app PRIVATE
target_sources(app PRIVATE
main/AppTask.cpp
main/main.cpp
main/ZclDoorLockCallbacks.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-temperature-levels.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ add_definitions(

target_sources(app PRIVATE
src/AppTask.cpp
src/ZclDoorLockCallbacks.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-temperature-levels.cpp
Expand Down

0 comments on commit 57f0a73

Please sign in to comment.