Skip to content

Commit 1139467

Browse files
jmartinez-silabspull[bot]
authored andcommitted
[EFR32] Link the door lock relock behaviour with the app UI (#23331)
* Make the relock callback weak, implement it on the app side and link our app ui * address PR comments, Create a new functions that deal with the cluster and calls the application callback
1 parent 3f7660d commit 1139467

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

examples/lock-app/efr32/src/ZclCallbacks.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
4141

4242
if (clusterId == DoorLock::Id && attributeId == DoorLock::Attributes::LockState::Id)
4343
{
44-
ChipLogProgress(Zcl, "Door lock cluster: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
44+
DoorLock::DlLockState lockState = *(reinterpret_cast<DoorLock::DlLockState *>(value));
45+
ChipLogProgress(Zcl, "Door lock cluster: " ChipLogFormatMEI " state %d", ChipLogValueMEI(clusterId),
46+
to_underlying(lockState));
4547
}
4648
}
4749

@@ -146,3 +148,9 @@ DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t h
146148
{
147149
return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode);
148150
}
151+
152+
void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId)
153+
{
154+
// Apply the relock state in the application control
155+
LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION);
156+
}

src/app/clusters/door-lock-server/door-lock-server-callback.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Opti
6161
return false;
6262
}
6363

64+
void __attribute__((weak)) emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId) {}
65+
6466
// =============================================================================
6567
// 'Default' pre-change callbacks for cluster attributes
6668
// =============================================================================

src/app/clusters/door-lock-server/door-lock-server.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class DoorLockClusterFabricDelegate : public chip::FabricTable::Delegate
6969
};
7070
static DoorLockClusterFabricDelegate gFabricDelegate;
7171

72-
void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId);
73-
7472
/**********************************************************
7573
* DoorLockServer public methods
7674
*********************************************************/
@@ -3380,7 +3378,7 @@ void DoorLockServer::ScheduleAutoRelock(chip::EndpointId endpointId, uint32_t ti
33803378
emberEventControlSetInactive(&AutolockEvent);
33813379

33823380
AutolockEvent.endpoint = endpointId;
3383-
AutolockEvent.callback = emberAfPluginDoorLockOnAutoRelock;
3381+
AutolockEvent.callback = DoorLockOnAutoRelockCallback;
33843382

33853383
uint32_t timeoutMs =
33863384
(DOOR_LOCK_MAX_LOCK_TIMEOUT_SEC >= timeoutSec) ? timeoutSec * MILLISECOND_TICKS_PER_SECOND : DOOR_LOCK_MAX_LOCK_TIMEOUT_SEC;
@@ -3751,8 +3749,10 @@ void MatterDoorLockClusterServerAttributeChangedCallback(const app::ConcreteAttr
37513749
// Timer callbacks
37523750
// =============================================================================
37533751

3754-
void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId)
3752+
void DoorLockServer::DoorLockOnAutoRelockCallback(chip::EndpointId endpointId)
37553753
{
3754+
emberAfDoorLockClusterPrintln("Door Auto relock timer expired. Locking...");
37563755
emberEventControlSetInactive(&DoorLockServer::Instance().AutolockEvent);
37573756
DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked, DlOperationSource::kAuto);
3757+
emberAfPluginDoorLockOnAutoRelock(endpointId);
37583758
}

src/app/clusters/door-lock-server/door-lock-server.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ class DoorLockServer
410410
*/
411411
void ScheduleAutoRelock(chip::EndpointId endpointId, uint32_t timeoutSec);
412412

413+
static void DoorLockOnAutoRelockCallback(chip::EndpointId endpointId);
414+
413415
/**
414416
* @brief Send generic event
415417
*
@@ -463,8 +465,6 @@ class DoorLockServer
463465
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
464466
const chip::app::Clusters::DoorLock::Commands::UnlockWithTimeout::DecodableType & commandData);
465467

466-
friend void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId);
467-
468468
friend bool emberAfDoorLockClusterSetHolidayScheduleCallback(
469469
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
470470
const chip::app::Clusters::DoorLock::Commands::SetHolidaySchedule::DecodableType & commandData);
@@ -887,6 +887,13 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O
887887
bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pinCode,
888888
DlOperationError & err);
889889

890+
/**
891+
* @brief This callback is called when the AutoRelock timer is expired.
892+
*
893+
* @param endpointId ID of the endpoint that contains the door lock to be relocked.
894+
*/
895+
void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId);
896+
890897
/**
891898
* @brief This callback is called when Door Lock cluster needs to access the users database.
892899
*

0 commit comments

Comments
 (0)