Skip to content

Commit

Permalink
[Telink]: Refactor Lock App
Browse files Browse the repository at this point in the history
Added storage to save user credentials, fixed test DRLK-2.10

Signed-off-by: Misha Tkachenko <[email protected]>
  • Loading branch information
mishadesh committed Nov 6, 2023
1 parent a3735f4 commit db864f1
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 489 deletions.
1 change: 1 addition & 0 deletions examples/lock-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ target_sources(app PRIVATE
src/AppTask.cpp
src/ZclCallbacks.cpp
src/LockManager.cpp
src/LockSettingsStorage.cpp
${TELINK_COMMON}/common/src/mainCommon.cpp
${TELINK_COMMON}/common/src/AppTaskCommon.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
Expand Down
7 changes: 7 additions & 0 deletions examples/lock-app/telink/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

// ---- Lock Example App Config ----


#define APP_DEFAULT_USERS_COUNT 5
#define APP_DEFAULT_CREDENTIAL_COUNT 5
#define APP_DEFAULT_WEEKDAY_SCHEDULE_PER_USER_COUNT 5
#define APP_DEFAULT_YEARDAY_SCHEDULE_PER_USER_COUNT 5
#define APP_DEFAULT_HOLYDAY_SCHEDULE_PER_USER_COUNT 5

#define APP_USE_EXAMPLE_START_BUTTON 1
#define APP_USE_BLE_START_BUTTON 0
#define APP_USE_THREAD_START_BUTTON 0
Expand Down
3 changes: 1 addition & 2 deletions examples/lock-app/telink/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include "AppTaskCommon.h"
// #include "BoltLockManager.h"
#include "AppConfig.h"
#include "LockManager.h"

#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01)
Expand Down Expand Up @@ -51,4 +51,3 @@ inline AppTask & GetAppTask(void)
{
return AppTask::sAppTask;
}
CHIP_ERROR InitDoorLockHandler();
9 changes: 6 additions & 3 deletions examples/lock-app/telink/include/LockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ class LockManager
CHIP_ERROR Init(chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::DlLockState> state,
TelinkDoorLock::LockInitParams::LockParam lockParam, StateChangeCallback callback);

bool LockAction(int32_t appSource, Action_t aAction, OperationSource source, chip::EndpointId endpointId);

bool LockAction(int32_t appSource, Action_t aAction, OperationSource source, chip::EndpointId endpointId,
const Nullable<chip::FabricIndex> & fabricIdx = NullNullable, const Nullable<chip::NodeId> & nodeId = NullNullable,
OperationErrorEnum & err, const Nullable<chip::FabricIndex> & fabricIdx = NullNullable,
const Nullable<chip::NodeId> & nodeId = NullNullable,
const Optional<chip::ByteSpan> & pinCode = NullNullable);

bool IsLocked() const { return mState == State_t::kState_LockCompleted; }
Expand Down Expand Up @@ -199,8 +202,8 @@ class LockManager
k_timer mActuatorTimer = {};

bool setLockState(chip::EndpointId endpointId, DlLockState lockState, OperationSource source,
const Nullable<chip::FabricIndex> & fabricIdx, const Nullable<chip::NodeId> & nodeId,
const Optional<chip::ByteSpan> & pin);
OperationErrorEnum & err, const Nullable<chip::FabricIndex> & fabricIdx,
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pin);

static void ActuatorTimerEventHandler(k_timer * timer);
static void ActuatorAppEventHandler(const AppEvent & event);
Expand Down
21 changes: 21 additions & 0 deletions examples/lock-app/telink/include/LockSettingsStorage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <../Zephyr/ZephyrConfig.h>

namespace chip {
namespace DeviceLayer {
namespace Internal {

class LockSettingsStorage: ZephyrConfig
{
public:
static const ZephyrConfig::Key kConfigKey_LockUser;
static const ZephyrConfig::Key kConfigKey_Credential;
static const ZephyrConfig::Key kConfigKey_LockUserName;
static const ZephyrConfig::Key kConfigKey_CredentialData;
static const ZephyrConfig::Key kConfigKey_UserCredentials;
static const ZephyrConfig::Key kConfigKey_WeekDaySchedules;
static const ZephyrConfig::Key kConfigKey_YearDaySchedules;
static const ZephyrConfig::Key kConfigKey_HolidaySchedules;
};
}
}
}
Loading

0 comments on commit db864f1

Please sign in to comment.