Skip to content

Commit

Permalink
[ESP32/Linux] Added support of door-lock for esp32 and moved linux
Browse files Browse the repository at this point in the history
door-lock code to common
  • Loading branch information
jadhavrohit924 committed Dec 21, 2022
1 parent 07fe190 commit f21434d
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions examples/lock-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ idf_component_register(INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lock-app/lock-common/door-lock-common"
PRIV_REQUIRES bt chip QRCode)
add_dependencies(${COMPONENT_LIB} app-codegen)

Expand Down Expand Up @@ -186,6 +187,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lock-app/lock-common/door-lock-common"
PRIV_REQUIRES chip QRCode bt)

add_dependencies(${COMPONENT_LIB} app-codegen)
Expand Down
20 changes: 20 additions & 0 deletions examples/lock-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus
OnOnOffPostAttributeChangeCallback(endpointId, attributeId, value);
break;

case app::Clusters::DoorLock::Id:
OnDoorLockPostAttributeChangeCallback(endpointId, attributeId, value);
break;

default:
ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId);
break;
Expand All @@ -72,3 +76,19 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI
exit:
return;
}

void AppDeviceCallbacks::OnDoorLockPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
VerifyOrExit(attributeId == ZCL_LOCK_STATE_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId));
VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));
if (*value)
{
BoltLockMgr().InitiateAction(AppEvent::kEventType_Lock, BoltLockManager::LOCK_ACTION);
}
else
{
BoltLockMgr().InitiateAction(AppEvent::kEventType_Lock, BoltLockManager::UNLOCK_ACTION);
}
exit:
return;
}
1 change: 1 addition & 0 deletions examples/lock-app/esp32/main/include/DeviceCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AppDeviceCallbacks : public CommonDeviceCallbacks

private:
void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
void OnDoorLockPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value);
};

Expand Down
7 changes: 4 additions & 3 deletions examples/lock-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ executable("chip-lock-app") {
sources = [
"main.cpp",
"src/LockAppCommandDelegate.cpp",
"src/LockEndpoint.cpp",
"src/LockManager.cpp",
"src/ZCLDoorLockCallbacks.cpp",
"${chip_root}/examples/lock-app/lock-common/door-lock-common/LockEndpoint.cpp",
"${chip_root}/examples/lock-app/lock-common/door-lock-common/LockManager.cpp",
"${chip_root}/examples/lock-app/lock-common/door-lock-common/ZCLDoorLockCallbacks.cpp",
]

deps = [
Expand All @@ -33,6 +33,7 @@ executable("chip-lock-app") {

include_dirs = [
"${chip_root}/examples/lock-app/lock-common/include",
"${chip_root}/examples/lock-app/lock-common/door-lock-common",
"include",
]

Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/linux/src/LockAppCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "LockAppCommandDelegate.h"
#include <platform/PlatformManager.h>

#include <LockManager.h>
#include "LockManager.h"
#include <utility>

using chip::to_underlying;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#pragma once

#include <LockEndpoint.h>
#include "LockEndpoint.h"
#include <app/clusters/door-lock-server/door-lock-server.h>
#include <cstdint>

Expand Down

0 comments on commit f21434d

Please sign in to comment.