Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EFR32] Link the door lock relock behaviour with the app UI #23331

Merged
merged 3 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion examples/lock-app/efr32/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &

if (clusterId == DoorLock::Id && attributeId == DoorLock::Attributes::LockState::Id)
{
ChipLogProgress(Zcl, "Door lock cluster: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
DoorLock::DlLockState lockState = *(reinterpret_cast<DoorLock::DlLockState *>(value));
ChipLogProgress(Zcl, "Door lock cluster: " ChipLogFormatMEI " state %d", ChipLogValueMEI(clusterId),
to_underlying(lockState));
}
}

Expand Down Expand Up @@ -146,3 +148,9 @@ DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t h
{
return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode);
}

void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId)
{
// Apply the relock state in the application control
LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Opti
return false;
}

void __attribute__((weak)) emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId) {}

// =============================================================================
// 'Default' pre-change callbacks for cluster attributes
// =============================================================================
Expand Down
8 changes: 4 additions & 4 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class DoorLockClusterFabricDelegate : public chip::FabricTable::Delegate
};
static DoorLockClusterFabricDelegate gFabricDelegate;

void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId);

/**********************************************************
* DoorLockServer public methods
*********************************************************/
Expand Down Expand Up @@ -3380,7 +3378,7 @@ void DoorLockServer::ScheduleAutoRelock(chip::EndpointId endpointId, uint32_t ti
emberEventControlSetInactive(&AutolockEvent);

AutolockEvent.endpoint = endpointId;
AutolockEvent.callback = emberAfPluginDoorLockOnAutoRelock;
AutolockEvent.callback = DoorLockOnAutoRelockCallback;

uint32_t timeoutMs =
(DOOR_LOCK_MAX_LOCK_TIMEOUT_SEC >= timeoutSec) ? timeoutSec * MILLISECOND_TICKS_PER_SECOND : DOOR_LOCK_MAX_LOCK_TIMEOUT_SEC;
Expand Down Expand Up @@ -3751,8 +3749,10 @@ void MatterDoorLockClusterServerAttributeChangedCallback(const app::ConcreteAttr
// Timer callbacks
// =============================================================================

void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId)
void DoorLockServer::DoorLockOnAutoRelockCallback(chip::EndpointId endpointId)
{
emberAfDoorLockClusterPrintln("Door Auto relock timer expired. Locking...");
emberEventControlSetInactive(&DoorLockServer::Instance().AutolockEvent);
DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked, DlOperationSource::kAuto);
emberAfPluginDoorLockOnAutoRelock(endpointId);
}
11 changes: 9 additions & 2 deletions src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ class DoorLockServer
*/
void ScheduleAutoRelock(chip::EndpointId endpointId, uint32_t timeoutSec);

static void DoorLockOnAutoRelockCallback(chip::EndpointId endpointId);

/**
* @brief Send generic event
*
Expand Down Expand Up @@ -463,8 +465,6 @@ class DoorLockServer
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::UnlockWithTimeout::DecodableType & commandData);

friend void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId);

friend bool emberAfDoorLockClusterSetHolidayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetHolidaySchedule::DecodableType & commandData);
Expand Down Expand Up @@ -887,6 +887,13 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O
bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pinCode,
DlOperationError & err);

/**
* @brief This callback is called when the AutoRelock timer is expired.
*
* @param endpointId ID of the endpoint that contains the door lock to be relocked.
*/
void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId);

/**
* @brief This callback is called when Door Lock cluster needs to access the users database.
*
Expand Down