Skip to content

Commit 1103645

Browse files
mykrupprestyled-commits
authored andcommitted
[Silabs] Update lock app to send correct lock operation event (#28660)
* fix lock operation event * remove MakeNullable include * Restyled by clang-format --------- Co-authored-by: Restyled.io <[email protected]>
1 parent e95b34a commit 1103645

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

examples/lock-app/silabs/include/LockManager.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,12 @@ class LockManager
143143
typedef void (*Callback_fn_completed)(Action_t);
144144
void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB);
145145

146-
bool Lock(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
147-
bool Unlock(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
148-
bool Unbolt(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
146+
bool Lock(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx, const Nullable<chip::NodeId> & nodeId,
147+
const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
148+
bool Unlock(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx, const Nullable<chip::NodeId> & nodeId,
149+
const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
150+
bool Unbolt(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx, const Nullable<chip::NodeId> & nodeId,
151+
const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
149152

150153
bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user);
151154
bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier,
@@ -183,7 +186,8 @@ class LockManager
183186
bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex);
184187
bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex);
185188

186-
bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional<chip::ByteSpan> & pin,
189+
bool setLockState(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
190+
const Nullable<chip::NodeId> & nodeId, DlLockState lockState, const Optional<chip::ByteSpan> & pin,
187191
OperationErrorEnum & err);
188192
const char * lockStateToString(DlLockState lockState) const;
189193

examples/lock-app/silabs/src/AppTask.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,9 @@ void AppTask::UpdateClusterState(intptr_t context)
352352
bool unlocked = LockMgr().NextState();
353353
DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked;
354354

355-
OperationSourceEnum source = OperationSourceEnum::kUnspecified;
356-
357355
// write the new lock value
358356
EmberAfStatus status =
359-
DoorLockServer::Instance().SetLockState(1, newState, source) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE;
357+
DoorLockServer::Instance().SetLockState(1, newState) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE;
360358

361359
if (status != EMBER_ZCL_STATUS_SUCCESS)
362360
{

examples/lock-app/silabs/src/LockManager.cpp

+15-9
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,22 @@ void LockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent)
288288
}
289289
}
290290

291-
bool LockManager::Lock(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
291+
bool LockManager::Lock(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
292+
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
292293
{
293-
return setLockState(endpointId, DlLockState::kLocked, pin, err);
294+
return setLockState(endpointId, fabricIdx, nodeId, DlLockState::kLocked, pin, err);
294295
}
295296

296-
bool LockManager::Unlock(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
297+
bool LockManager::Unlock(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
298+
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
297299
{
298-
return setLockState(endpointId, DlLockState::kUnlocked, pin, err);
300+
return setLockState(endpointId, fabricIdx, nodeId, DlLockState::kUnlocked, pin, err);
299301
}
300302

301-
bool LockManager::Unbolt(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
303+
bool LockManager::Unbolt(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
304+
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
302305
{
303-
return setLockState(endpointId, DlLockState::kUnlocked, pin, err);
306+
return setLockState(endpointId, fabricIdx, nodeId, DlLockState::kUnlocked, pin, err);
304307
}
305308

306309
bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user)
@@ -664,7 +667,8 @@ const char * LockManager::lockStateToString(DlLockState lockState) const
664667
return "Unknown";
665668
}
666669

667-
bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional<chip::ByteSpan> & pin,
670+
bool LockManager::setLockState(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
671+
const Nullable<chip::NodeId> & nodeId, DlLockState lockState, const Optional<chip::ByteSpan> & pin,
668672
OperationErrorEnum & err)
669673
{
670674

@@ -683,7 +687,8 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat
683687
ChipLogDetail(Zcl, "Door Lock App: setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState),
684688
endpointId);
685689

686-
DoorLockServer::Instance().SetLockState(endpointId, lockState);
690+
DoorLockServer::Instance().SetLockState(endpointId, lockState, OperationSourceEnum::kRemote, NullNullable, NullNullable,
691+
fabricIdx, nodeId);
687692

688693
return true;
689694
}
@@ -708,7 +713,8 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat
708713
"Lock App: specified PIN code was found in the database, setting lock state to \"%s\" [endpointId=%d]",
709714
lockStateToString(lockState), endpointId);
710715

711-
DoorLockServer::Instance().SetLockState(endpointId, lockState);
716+
DoorLockServer::Instance().SetLockState(endpointId, lockState, OperationSourceEnum::kRemote, NullNullable, NullNullable,
717+
fabricIdx, nodeId);
712718

713719
return true;
714720
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const N
6666
OperationErrorEnum & err)
6767
{
6868
ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId);
69-
bool status = LockMgr().Lock(endpointId, pinCode, err);
69+
bool status = LockMgr().Lock(endpointId, fabricIdx, nodeId, pinCode, err);
7070
if (status == true)
7171
{
7272
LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION);
@@ -79,7 +79,7 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const
7979
OperationErrorEnum & err)
8080
{
8181
ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId);
82-
bool status = LockMgr().Unlock(endpointId, pinCode, err);
82+
bool status = LockMgr().Unlock(endpointId, fabricIdx, nodeId, pinCode, err);
8383
if (status == true)
8484
{
8585
LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::UNLOCK_ACTION);
@@ -93,7 +93,7 @@ bool emberAfPluginDoorLockOnDoorUnboltCommand(chip::EndpointId endpointId, const
9393
OperationErrorEnum & err)
9494
{
9595
ChipLogProgress(Zcl, "Door Lock App: Unbolt Command endpoint=%d", endpointId);
96-
bool status = LockMgr().Unlock(endpointId, pinCode, err);
96+
bool status = LockMgr().Unlock(endpointId, fabricIdx, nodeId, pinCode, err);
9797
if (status == true)
9898
{
9999
LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::UNLOCK_ACTION);

0 commit comments

Comments
 (0)