forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoor-lock-server.h
1282 lines (1115 loc) · 72.2 KB
/
door-lock-server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
*
* Copyright (c) 2020 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****************************************************************************
* @file
* @brief APIs and defines for the Door Lock Server
*plugin.
*******************************************************************************
******************************************************************************/
#pragma once
#include "door-lock-delegate.h"
#include <app-common/zap-generated/cluster-objects.h>
#include <app/AttributeAccessInterface.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/reporting/reporting.h>
#include <app/util/attribute-storage.h>
#include <app/util/config.h>
#include <platform/CHIPDeviceConfig.h>
#include <protocols/interaction_model/StatusCode.h>
#ifndef DOOR_LOCK_SERVER_ENDPOINT
#define DOOR_LOCK_SERVER_ENDPOINT 1
#endif
using chip::Optional;
using chip::app::Clusters::DoorLock::AlarmCodeEnum;
using chip::app::Clusters::DoorLock::CredentialRuleEnum;
using chip::app::Clusters::DoorLock::CredentialTypeEnum;
using chip::app::Clusters::DoorLock::DataOperationTypeEnum;
using chip::app::Clusters::DoorLock::DaysMaskMap;
using chip::app::Clusters::DoorLock::DlLockState;
using chip::app::Clusters::DoorLock::DlStatus;
using chip::app::Clusters::DoorLock::DoorStateEnum;
using chip::app::Clusters::DoorLock::LockDataTypeEnum;
using chip::app::Clusters::DoorLock::LockOperationTypeEnum;
using chip::app::Clusters::DoorLock::OperatingModeEnum;
using chip::app::Clusters::DoorLock::OperationErrorEnum;
using chip::app::Clusters::DoorLock::OperationSourceEnum;
using chip::app::Clusters::DoorLock::UserStatusEnum;
using chip::app::Clusters::DoorLock::UserTypeEnum;
using chip::app::DataModel::List;
using chip::app::DataModel::Nullable;
using chip::app::DataModel::NullNullable;
using CredentialStruct = chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type;
using LockOpCredentials = CredentialStruct;
/**
* Handler for executing remote lock operations.
*
* @param endpointId endpoint for which remote lock command is called
* @param fabricIdx fabric index responsible for operating the lock
* @param nodeId node id responsible for operating the lock
* @param pinCode PIN code (optional)
* @param err error code if door locking failed (set only if retval==false)
*/
typedef bool (*RemoteLockOpHandler)(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pinCode,
OperationErrorEnum & err);
static constexpr size_t DOOR_LOCK_MAX_USER_NAME_SIZE = 10; /**< Maximum size of the user name (in characters). */
static constexpr size_t DOOR_LOCK_USER_NAME_BUFFER_SIZE =
DOOR_LOCK_MAX_USER_NAME_SIZE + 1; /**< Maximum size of the user name string (in bytes). */
struct EmberAfPluginDoorLockCredentialInfo;
struct EmberAfPluginDoorLockUserInfo;
struct EmberAfDoorLockEndpointContext
{
chip::System::Clock::Timestamp lockoutEndTimestamp;
int wrongCodeEntryAttempts;
};
namespace chip {
namespace app {
namespace Clusters {
namespace DoorLock {
void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate);
} // namespace DoorLock
} // namespace Clusters
} // namespace app
} // namespace chip
/**
* @brief Door Lock Server Plugin class.
*/
class DoorLockServer : public chip::app::AttributeAccessInterface
{
public:
DoorLockServer() : AttributeAccessInterface(chip::Optional<chip::EndpointId>::Missing(), chip::app::Clusters::DoorLock::Id) {}
static DoorLockServer & Instance();
using Feature = chip::app::Clusters::DoorLock::Feature;
using OnFabricRemovedCustomCallback = void (*)(chip::EndpointId endpointId, chip::FabricIndex fabricIndex);
void InitServer(chip::EndpointId endpointId);
/**
* Updates the LockState attribute with new value and sends LockOperation event.
*
* @note Does not send an event of opSource is kRemote.
*
* @param endpointId ID of the endpoint to the lock state
* @param newLockState new lock state
* @param opSource source of the operation (will be used in the event).
* @param fabricIdx fabric index responsible for operating the lock
* @param nodeId node id responsible for operating the lock
*
* @return true on success, false on failure.
*/
bool SetLockState(chip::EndpointId endpointId, DlLockState newLockState, OperationSourceEnum opSource,
const Nullable<uint16_t> & userIndex = NullNullable,
const Nullable<List<const LockOpCredentials>> & credentials = NullNullable,
const Nullable<chip::FabricIndex> & fabricIdx = NullNullable,
const Nullable<chip::NodeId> & nodeId = NullNullable);
/**
* Updates the LockState attribute with new value.
*
* @note Does not generate Lock Operation event
*
* @param endpointId ID of the endpoint to the lock state
* @param newLockState new lock state
*
* @return true on success, false on failure.
*/
bool SetLockState(chip::EndpointId endpointId, DlLockState newLockState);
bool SetActuatorEnabled(chip::EndpointId endpointId, bool newActuatorState);
bool SetDoorState(chip::EndpointId endpointId, DoorStateEnum newDoorState);
bool SetLanguage(chip::EndpointId endpointId, chip::CharSpan newLanguage);
bool SetAutoRelockTime(chip::EndpointId endpointId, uint32_t newAutoRelockTimeSec);
bool SetSoundVolume(chip::EndpointId endpointId, uint8_t newSoundVolume);
bool SetOneTouchLocking(chip::EndpointId endpointId, bool isEnabled);
bool SetPrivacyModeButton(chip::EndpointId endpointId, bool isEnabled);
/**
* @brief Handles a wrong code entry attempt for the endpoint. If the number of wrong entry attempts exceeds the max limit,
* engage lockout. Otherwise increment the number of incorrect attempts by 1. This is handled automatically for
* remote operations - lock and unlock. Applications are responsible for calling it for non-remote incorrect credential
* presentation attempts.
*
* @param endpointId
*/
bool HandleWrongCodeEntry(chip::EndpointId endpointId);
bool GetAutoRelockTime(chip::EndpointId endpointId, uint32_t & autoRelockTime);
bool GetNumberOfUserSupported(chip::EndpointId endpointId, uint16_t & numberOfUsersSupported);
bool GetNumberOfPINCredentialsSupported(chip::EndpointId endpointId, uint16_t & numberOfPINCredentials);
bool GetNumberOfRFIDCredentialsSupported(chip::EndpointId endpointId, uint16_t & numberOfRFIDCredentials);
bool GetNumberOfWeekDaySchedulesPerUserSupported(chip::EndpointId endpointId, uint8_t & numberOfWeekDaySchedulesPerUser);
bool GetNumberOfYearDaySchedulesPerUserSupported(chip::EndpointId endpointId, uint8_t & numberOfYearDaySchedulesPerUser);
bool GetNumberOfCredentialsSupportedPerUser(chip::EndpointId endpointId, uint8_t & numberOfCredentialsSupportedPerUser);
bool GetNumberOfHolidaySchedulesSupported(chip::EndpointId endpointId, uint8_t & numberOfHolidaySchedules);
bool SendLockAlarmEvent(chip::EndpointId endpointId, AlarmCodeEnum alarmCode);
static chip::BitFlags<Feature> GetFeatures(chip::EndpointId endpointId);
static inline bool SupportsPIN(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kPinCredential); }
static inline bool SupportsRFID(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kRfidCredential); }
static inline bool SupportsFingers(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kFingerCredentials);
}
static inline bool SupportsFace(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kFaceCredentials); }
static inline bool SupportsWeekDaySchedules(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kWeekDayAccessSchedules);
}
static inline bool SupportsYearDaySchedules(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kYearDayAccessSchedules);
}
static inline bool SupportsHolidaySchedules(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kHolidaySchedules);
}
static inline bool SupportsAnyCredential(chip::EndpointId endpointId)
{
return GetFeatures(endpointId)
.HasAny(Feature::kPinCredential, Feature::kRfidCredential, Feature::kFingerCredentials, Feature::kFaceCredentials,
Feature::kAliroProvisioning);
}
static inline bool SupportsCredentialsOTA(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kCredentialsOverTheAirAccess);
}
static inline bool SupportsUSR(chip::EndpointId endpointId)
{
// appclusters, 5.2.2: USR feature has conformance [PIN | RID | FGP | FACE]
return GetFeatures(endpointId).Has(Feature::kUser) && SupportsAnyCredential(endpointId);
}
static bool SupportsUnbolt(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kUnbolt); }
/**
* @brief Checks if Aliro Provisioning feature is supported on the given endpoint
*
* @param endpointId endpointId ID of the endpoint which contains the lock.
*/
static inline bool SupportsAliroProvisioning(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kAliroProvisioning);
}
/**
* @brief Checks if Aliro BLE UWB feature is supported on the given endpoint
*
* @param endpointId endpointId ID of the endpoint which contains the lock.
*/
static inline bool SupportsAliroBLEUWB(chip::EndpointId endpointId)
{
return GetFeatures(endpointId).Has(Feature::kAliroBLEUWB);
}
/**
* @brief Allows the application to register a custom callback which will be called after the default DoorLock
* OnFabricRemoved implementation. At that point the door lock cluster has done any
* spec-required clearing of state for fabric removal.
*
* @param callback callback to be registered
*/
inline void SetOnFabricRemovedCustomCallback(OnFabricRemovedCustomCallback callback)
{
mOnFabricRemovedCustomCallback = callback;
}
bool OnFabricRemoved(chip::EndpointId endpointId, chip::FabricIndex fabricIndex);
static void DoorLockOnAutoRelockCallback(chip::System::Layer *, void * callbackContext);
/**
* @brief Resets the wrong code entry attempts to 0 for the endpoint. This is done automatically when a
* remote lock operation with credentials succeeds, or when SetLockState is called with a non-empty credentials list.
* Applications that call the two-argument version of SetLockState and handle sending the relevant operation events
* themselves or via SendLockOperationEvent are responsible for calling this API when a valid credential is presented.
*
* @param endpointId
*/
void ResetWrongCodeEntryAttempts(chip::EndpointId endpointId);
/**
* @brief Handles a local lock operation error. This method allows handling a wrong attempt of providing
* user credential entry that has been provided locally by the user. The method will emit the LockOperationEvent
* to inform the controller that a local wrong attempt occurred, and also call HandleWrongEntry method to
* increment wrong entry counter.
*
* @param endpointId
* @param opType Operation source to be registered in the LockOperationEvent.
* @param opSource source of the operation to be registered in the LockOperationEvent.
* @param userId Optional user id to be registered in the LockOperationEvent
*/
void HandleLocalLockOperationError(chip::EndpointId endpointId, LockOperationTypeEnum opType, OperationSourceEnum opSource,
Nullable<uint16_t> userId);
private:
chip::FabricIndex getFabricIndex(const chip::app::CommandHandler * commandObj);
chip::NodeId getNodeId(const chip::app::CommandHandler * commandObj);
bool userIndexValid(chip::EndpointId endpointId, uint16_t userIndex);
bool userIndexValid(chip::EndpointId endpointId, uint16_t userIndex, uint16_t & maxNumberOfUser);
bool userExists(chip::EndpointId endpointId, uint16_t userIndex);
bool credentialIndexValid(chip::EndpointId endpointId, CredentialTypeEnum type, uint16_t credentialIndex);
bool credentialIndexValid(chip::EndpointId endpointId, CredentialTypeEnum type, uint16_t credentialIndex,
uint16_t & maxNumberOfCredentials);
DlStatus credentialLengthWithinRange(chip::EndpointId endpointId, CredentialTypeEnum type,
const chip::ByteSpan & credentialData);
bool getMaxNumberOfCredentials(chip::EndpointId endpointId, CredentialTypeEnum credentialType,
uint16_t & maxNumberOfCredentials);
bool findOccupiedUserSlot(chip::EndpointId endpointId, uint16_t startIndex, uint16_t & userIndex);
bool findUnoccupiedUserSlot(chip::EndpointId endpointId, uint16_t & userIndex);
bool findUnoccupiedUserSlot(chip::EndpointId endpointId, uint16_t startIndex, uint16_t & userIndex);
bool findOccupiedCredentialSlot(chip::EndpointId endpointId, CredentialTypeEnum credentialType, uint16_t startIndex,
uint16_t & credentialIndex);
bool findUnoccupiedCredentialSlot(chip::EndpointId endpointId, CredentialTypeEnum credentialType, uint16_t startIndex,
uint16_t & credentialIndex);
bool findUserIndexByCredential(chip::EndpointId endpointId, CredentialTypeEnum credentialType, uint16_t credentialIndex,
uint16_t & userIndex);
bool findUserIndexByCredential(chip::EndpointId endpointId, CredentialTypeEnum credentialType, chip::ByteSpan credentialData,
uint16_t & userIndex, uint16_t & credentialIndex, EmberAfPluginDoorLockUserInfo & userInfo);
chip::Protocols::InteractionModel::ClusterStatusCode
createUser(chip::EndpointId endpointId, chip::FabricIndex creatorFabricIdx, chip::NodeId sourceNodeId, uint16_t userIndex,
const Nullable<chip::CharSpan> & userName, const Nullable<uint32_t> & userUniqueId,
const Nullable<UserStatusEnum> & userStatus, const Nullable<UserTypeEnum> & userType,
const Nullable<CredentialRuleEnum> & credentialRule,
const Nullable<CredentialStruct> & credential = Nullable<CredentialStruct>());
chip::Protocols::InteractionModel::Status
modifyUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricIndex, chip::NodeId sourceNodeId, uint16_t userIndex,
const Nullable<chip::CharSpan> & userName, const Nullable<uint32_t> & userUniqueId,
const Nullable<UserStatusEnum> & userStatus, const Nullable<UserTypeEnum> & userType,
const Nullable<CredentialRuleEnum> & credentialRule);
chip::Protocols::InteractionModel::Status clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId,
chip::NodeId sourceNodeId, uint16_t userIndex, bool sendUserChangeEvent);
chip::Protocols::InteractionModel::Status clearUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricId,
chip::NodeId sourceNodeId, uint16_t userIndex,
const EmberAfPluginDoorLockUserInfo & user, bool sendUserChangeEvent);
bool clearFabricFromUsers(chip::EndpointId endpointId, chip::FabricIndex fabricIndex);
DlStatus createNewCredentialAndUser(chip::EndpointId endpointId, chip::FabricIndex creatorFabricIdx, chip::NodeId sourceNodeId,
const Nullable<UserStatusEnum> & userStatus, const Nullable<UserTypeEnum> & userType,
const CredentialStruct & credential, const chip::ByteSpan & credentialData,
uint16_t & createdUserIndex);
DlStatus createNewCredentialAndAddItToUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricIdx, uint16_t userIndex,
const CredentialStruct & credential, const chip::ByteSpan & credentialData);
DlStatus addCredentialToUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricIdx, uint16_t userIndex,
const CredentialStruct & credential);
DlStatus modifyCredentialForUser(chip::EndpointId endpointId, chip::FabricIndex modifierFabricIdx, uint16_t userIndex,
const CredentialStruct & credential);
DlStatus createCredential(chip::EndpointId endpointId, chip::FabricIndex creatorFabricIdx, chip::NodeId sourceNodeId,
uint16_t credentialIndex, CredentialTypeEnum credentialType,
const EmberAfPluginDoorLockCredentialInfo & existingCredential, const chip::ByteSpan & credentialData,
Nullable<uint16_t> userIndex, const Nullable<UserStatusEnum> & userStatus,
Nullable<UserTypeEnum> userType, uint16_t & createdUserIndex);
DlStatus modifyProgrammingPIN(chip::EndpointId endpointId, chip::FabricIndex modifierFabricIndex, chip::NodeId sourceNodeId,
uint16_t credentialIndex, CredentialTypeEnum credentialType,
const EmberAfPluginDoorLockCredentialInfo & existingCredential,
const chip::ByteSpan & credentialData);
DlStatus modifyCredential(chip::EndpointId endpointId, chip::FabricIndex modifierFabricIndex, chip::NodeId sourceNodeId,
uint16_t credentialIndex, CredentialTypeEnum credentialType,
const EmberAfPluginDoorLockCredentialInfo & existingCredential, const chip::ByteSpan & credentialData,
uint16_t userIndex, const Nullable<UserStatusEnum> & userStatus, Nullable<UserTypeEnum> userType);
chip::Protocols::InteractionModel::Status clearCredential(chip::EndpointId endpointId, chip::FabricIndex modifier,
chip::NodeId sourceNodeId, CredentialTypeEnum credentialType,
uint16_t credentialIndex, bool sendUserChangeEvent);
chip::Protocols::InteractionModel::Status clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier,
chip::NodeId sourceNodeId);
chip::Protocols::InteractionModel::Status clearCredentials(chip::EndpointId endpointId, chip::FabricIndex modifier,
chip::NodeId sourceNodeId, CredentialTypeEnum credentialType);
bool clearFabricFromCredentials(chip::EndpointId endpointId, CredentialTypeEnum credentialType,
chip::FabricIndex fabricToRemove);
bool clearFabricFromCredentials(chip::EndpointId endpointId, chip::FabricIndex fabricToRemove);
void sendSetCredentialResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
DlStatus status, uint16_t userIndex, uint16_t nextCredentialIndex);
// TODO: Maybe use CHIP_APPLICATION_ERROR instead of boolean in class methods?
// OPTIMIZE: there are a lot of methods such as this that could be made static which could help reduce the stack footprint
// in case of multiple lock endpoints
bool credentialTypeSupported(chip::EndpointId endpointId, CredentialTypeEnum type);
bool weekDayIndexValid(chip::EndpointId endpointId, uint8_t weekDayIndex);
DlStatus clearWeekDaySchedule(chip::EndpointId endpointId, uint16_t userIndex, uint8_t weekDayIndex);
DlStatus clearWeekDaySchedules(chip::EndpointId endpointId, uint16_t userIndex);
DlStatus clearSchedules(chip::EndpointId endpointId, uint16_t userIndex);
void sendGetWeekDayScheduleResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint8_t weekdayIndex, uint16_t userIndex, DlStatus status,
DaysMaskMap daysMask = DaysMaskMap(0), uint8_t startHour = 0, uint8_t startMinute = 0,
uint8_t endHour = 0, uint8_t endMinute = 0);
bool yearDayIndexValid(chip::EndpointId endpointId, uint8_t yearDayIndex);
DlStatus clearYearDaySchedule(chip::EndpointId endpointId, uint16_t userIndex, uint8_t weekDayIndex);
DlStatus clearYearDaySchedules(chip::EndpointId endpointId, uint16_t userIndex);
void sendGetYearDayScheduleResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint8_t yearDayIndex, uint16_t userIndex, DlStatus status, uint32_t localStartTime = 0,
uint32_t localEndTime = 0);
bool holidayIndexValid(chip::EndpointId endpointId, uint8_t holidayIndex);
DlStatus clearHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex);
DlStatus clearHolidaySchedules(chip::EndpointId endpointId);
void sendHolidayScheduleResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint8_t holidayIndex, DlStatus status, uint32_t localStartTime = 0, uint32_t localEndTime = 0,
OperatingModeEnum operatingMode = OperatingModeEnum::kNormal);
bool sendRemoteLockUserChange(chip::EndpointId endpointId, LockDataTypeEnum dataType, DataOperationTypeEnum operation,
chip::NodeId nodeId, chip::FabricIndex fabricIndex, uint16_t userIndex = 0,
uint16_t dataIndex = 0);
LockDataTypeEnum credentialTypeToLockDataType(CredentialTypeEnum credentialType);
bool isUserScheduleRestricted(chip::EndpointId endpointId, const EmberAfPluginDoorLockUserInfo & user);
void setUserCommandHandler(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetUser::DecodableType & commandData);
void getUserCommandHandler(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint16_t userIndex);
void clearUserCommandHandler(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
uint16_t userIndex);
void setCredentialCommandHandler(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetCredential::DecodableType & commandData);
void getCredentialStatusCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, CredentialTypeEnum credentialType,
uint16_t credentialIndex);
void sendGetCredentialResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
CredentialTypeEnum credentialType, uint16_t credentialIndex, uint16_t userIndexWithCredential,
EmberAfPluginDoorLockCredentialInfo * credentialInfo, bool credentialExists);
void clearCredentialCommandHandler(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearCredential::DecodableType & commandData);
void setWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t weekDayIndex,
uint16_t userIndex, const chip::BitMask<DaysMaskMap> & daysMask, uint8_t startHour,
uint8_t startMinute, uint8_t endHour, uint8_t endMinute);
void getWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t weekDayIndex,
uint16_t userIndex);
void clearWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t weekDayIndex,
uint16_t userIndex);
void setYearDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t yearDayIndex,
uint16_t userIndex, uint32_t localStartTime, uint32_t localEndTime);
void getYearDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t yearDayIndex,
uint16_t userIndex);
void clearYearDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t yearDayIndex,
uint16_t userIndex);
void setHolidayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t holidayIndex,
uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode);
void getHolidayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t holidayIndex);
void clearHolidayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, uint8_t holidayIndex);
void setAliroReaderConfigCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath, const chip::ByteSpan & signingKey,
const chip::ByteSpan & verificationKey, const chip::ByteSpan & groupIdentifier,
const Optional<chip::ByteSpan> & groupResolvingKey);
void clearAliroReaderConfigCommandHandler(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath);
bool RemoteOperationEnabled(chip::EndpointId endpointId) const;
EmberAfDoorLockEndpointContext * getContext(chip::EndpointId endpointId);
bool engageLockout(chip::EndpointId endpointId);
static void sendClusterResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
chip::Protocols::InteractionModel::ClusterStatusCode status);
/**
* @brief Common handler for LockDoor, UnlockDoor, UnlockWithTimeout commands
*
* @param commandObj original command context
* @param commandPath original command path
* @param opType remote operation type (lock, unlock)
* @param opHandler plugin handler for specified command
* @param pinCode pin code passed by client
* @return true if locking/unlocking was successful
* @return false if error happened during lock/unlock
*/
bool HandleRemoteLockOperation(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
LockOperationTypeEnum opType, RemoteLockOpHandler opHandler,
const chip::Optional<chip::ByteSpan> & pinCode);
/**
* @brief Send LockOperation event if opSuccess is true, otherwise send LockOperationError with given opErr code
*
* @param endpointId endpoint where DoorLockServer is running
* @param opType lock operation type (lock, unlock, etc)
* @param opSource operation source (remote, keypad, auto, etc)
* @param opErr operation error code (if opSuccess == false)
* @param userId user id
* @param fabricIdx fabric index responsible for operating the lock
* @param nodeId node id responsible for operating the lock
* @param credList list of credentials used in lock operation (can be NULL if no credentials were used)
* @param credListSize size of credentials list (if 0, then no credentials were used)
* @param opSuccess flags if operation was successful or not
*/
void SendLockOperationEvent(chip::EndpointId endpointId, LockOperationTypeEnum opType, OperationSourceEnum opSource,
OperationErrorEnum opErr, const Nullable<uint16_t> & userId,
const Nullable<chip::FabricIndex> & fabricIdx, const Nullable<chip::NodeId> & nodeId,
const Nullable<List<const LockOpCredentials>> & credentials = NullNullable, bool opSuccess = true);
/**
* @brief Schedule auto relocking with a given timeout
*
* @param endpointId endpoint where DoorLockServer is running
* @param timeoutSec timeout in seconds
*/
void ScheduleAutoRelock(chip::EndpointId endpointId, uint32_t timeoutSec);
/**
* @brief Send generic event
*
* @tparam T Any event type supported by Matter
* @param endpointId endpoint where DoorLockServer is running
* @param event event object built by caller
*/
template <typename T>
void SendEvent(chip::EndpointId endpointId, T & event);
/**
* @brief Get generic attribute value
*
* @tparam T attribute value type
* @param endpointId endpoint where DoorLockServer is running
* @param attributeId attribute Id (used for logging only)
* @param getFn attribute getter function as defined in <Accessors.h>
* @param value actual attribute value on success
* @return true on success (value is set to the actual attribute value)
* @return false if attribute reading failed (value is kept unchanged)
*/
template <typename T>
static bool GetAttribute(chip::EndpointId endpointId, chip::AttributeId attributeId,
chip::Protocols::InteractionModel::Status (*getFn)(chip::EndpointId endpointId, T * value), T & value);
/**
* @brief Set generic attribute value
*
* @tparam T attribute value type
* @param endpointId endpoint where DoorLockServer is running
* @param attributeId attribute Id (used for logging only)
* @param setFn attribute setter function as defined in <Accessors.h>
* @param value new attribute value
* @return true on success
* @return false if attribute writing failed
*/
template <typename T>
bool SetAttribute(chip::EndpointId endpointId, chip::AttributeId attributeId,
chip::Protocols::InteractionModel::Status (*setFn)(chip::EndpointId endpointId, T value), T value);
// AttributeAccessInterface's Read API
CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) override;
/**
* @brief Reads AliroExpeditedTransactionSupportedProtocolVersions attribute for door lock
*
* @param aPath attribute path.
* @param aEncoder attribute value encoder.
* @param delegate door lock cluster delegate that will provide the value
*
* @return CHIP_NO_ERROR on success
* @return CHIP_ERROR if attribute read failed
*/
CHIP_ERROR ReadAliroExpeditedTransactionSupportedProtocolVersions(const chip::app::ConcreteReadAttributePath & aPath,
chip::app::AttributeValueEncoder & aEncoder,
chip::app::Clusters::DoorLock::Delegate * delegate);
/**
* @brief Reads AliroSupportedBLEUWBProtocolVersions attribute for door lock
*
* @param aPath attribute path.
* @param aEncoder attribute value encoder.
* @param delegate door lock cluster delegate that will provide the value
*
* @return CHIP_NO_ERROR on success
* @return CHIP_ERROR if attribute read failed
*/
CHIP_ERROR ReadAliroSupportedBLEUWBProtocolVersions(const chip::app::ConcreteReadAttributePath & aPath,
chip::app::AttributeValueEncoder & aEncoder,
chip::app::Clusters::DoorLock::Delegate * delegate);
/**
* @brief Indicates whether an attribute can be nullable or not.
*/
enum class AttributeNullabilityType : uint8_t
{
kNullable = 0, /**< Indicates if an attribute is nullable */
kNotNullable = 1, /**< Indicates if an attribute is not nullable */
};
/**
* @brief Utility to read aliro attributes of type ByteSpan
*
* @param func getter function for the attribute.
* @param data buffer for the data.
* @param delegate door lock cluster delegate that will provide the value
* @param aEncoder attribute value encoder.
* @param nullabilityType enum value indicating whether the attribute is nullable or not.
*
* @return CHIP_NO_ERROR on success
* @return CHIP_ERROR if attribute read failed
*/
CHIP_ERROR ReadAliroByteSpanAttribute(CHIP_ERROR (chip::app::Clusters::DoorLock::Delegate::*func)(chip::MutableByteSpan & data),
chip::MutableByteSpan & data, chip::app::Clusters::DoorLock::Delegate * delegate,
chip::app::AttributeValueEncoder & aEncoder, AttributeNullabilityType nullabilityType);
friend bool
emberAfDoorLockClusterLockDoorCallback(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::LockDoor::DecodableType & commandData);
friend bool emberAfDoorLockClusterUnlockDoorCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::UnlockDoor::DecodableType & commandData);
friend bool emberAfDoorLockClusterUnlockWithTimeoutCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::UnlockWithTimeout::DecodableType & commandData);
friend bool emberAfDoorLockClusterUnboltDoorCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::UnboltDoor::DecodableType & commandData);
friend bool emberAfDoorLockClusterSetHolidayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetHolidaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterGetHolidayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::GetHolidaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterClearHolidayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearHolidaySchedule::DecodableType & commandData);
friend bool
emberAfDoorLockClusterSetUserCallback(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetUser::DecodableType & commandData);
friend bool
emberAfDoorLockClusterGetUserCallback(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::GetUser::DecodableType & commandData);
friend bool
emberAfDoorLockClusterClearUserCallback(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearUser::DecodableType & commandData);
friend bool emberAfDoorLockClusterSetCredentialCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetCredential::DecodableType & commandData);
friend bool emberAfDoorLockClusterGetCredentialStatusCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::GetCredentialStatus::DecodableType & commandData);
friend bool emberAfDoorLockClusterClearCredentialCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearCredential::DecodableType & commandData);
friend bool emberAfDoorLockClusterSetWeekDayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetWeekDaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterGetWeekDayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::GetWeekDaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterClearWeekDayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearWeekDaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterSetYearDayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetYearDaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterGetYearDayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::GetYearDaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterClearYearDayScheduleCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearYearDaySchedule::DecodableType & commandData);
friend bool emberAfDoorLockClusterSetAliroReaderConfigCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::SetAliroReaderConfig::DecodableType & commandData);
friend bool emberAfDoorLockClusterClearAliroReaderConfigCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearAliroReaderConfig::DecodableType & commandData);
static constexpr size_t kDoorLockClusterServerMaxEndpointCount =
MATTER_DM_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;
static_assert(kDoorLockClusterServerMaxEndpointCount <= kEmberInvalidEndpointIndex, "DoorLock Endpoint count error");
std::array<EmberAfDoorLockEndpointContext, kDoorLockClusterServerMaxEndpointCount> mEndpointCtx;
OnFabricRemovedCustomCallback mOnFabricRemovedCustomCallback{ nullptr };
static DoorLockServer instance;
};
/**
* @brief Status of the credential slot in the credentials database.
*/
enum class DlCredentialStatus : uint8_t
{
kAvailable = 0x00, /**< Indicates if credential slot is available. */
kOccupied = 0x01, /**< Indicates if credential slot is already occupied. */
};
enum class DlAssetSource : uint8_t
{
kUnspecified = 0x00,
kMatterIM = 0x01,
};
/**
* @brief Structure that holds the credential information.
*/
struct EmberAfPluginDoorLockCredentialInfo
{
DlCredentialStatus status = DlCredentialStatus::kAvailable; /**< Indicates if credential slot is occupied or not. */
CredentialTypeEnum credentialType; /**< Specifies the type of the credential (PIN, RFID, etc.). */
chip::ByteSpan credentialData; /**< Credential data bytes. */
DlAssetSource creationSource;
chip::FabricIndex createdBy; /**< Index of the fabric that created the user. */
DlAssetSource modificationSource;
chip::FabricIndex lastModifiedBy; /**< ID of the fabric that modified the user. */
};
/**
* @brief Structure that holds user information.
*/
struct EmberAfPluginDoorLockUserInfo
{
chip::CharSpan userName; /**< Name of the user. */
chip::Span<const CredentialStruct> credentials; /**< Credentials that are associated with user (without data).*/
uint32_t userUniqueId; /**< Unique user identifier. */
UserStatusEnum userStatus = UserStatusEnum::kAvailable; /**< Status of the user slot (available/occupied). */
UserTypeEnum userType; /**< Type of the user. */
CredentialRuleEnum credentialRule; /**< Number of supported credentials. */
DlAssetSource creationSource;
chip::FabricIndex createdBy; /**< ID of the fabric that created the user. */
DlAssetSource modificationSource;
chip::FabricIndex lastModifiedBy; /**< ID of the fabric that modified the user. */
};
/**
* @brief Status of the schedule slot in the schedule database.
*/
enum class DlScheduleStatus : uint8_t
{
kAvailable = 0x00, /**< Indicates if schedule slot is available. */
kOccupied = 0x01, /**< Indicates if schedule slot is already occupied. */
};
/**
* @brief Structure that holds week day schedule information.
*/
struct EmberAfPluginDoorLockWeekDaySchedule
{
DaysMaskMap daysMask; /** Indicates the days of the week the Week Day schedule applies for. */
uint8_t startHour; /** Starting hour for the Week Day schedule. */
uint8_t startMinute; /** Starting minute for the Week Day schedule. */
uint8_t endHour; /** Ending hour for the Week Day schedule. */
uint8_t endMinute; /** Ending minute for the Week Day schedule. */
};
/**
* @brief Structure that holds year day schedule information.
*/
struct EmberAfPluginDoorLockYearDaySchedule
{
uint32_t localStartTime; /** The starting time for the Year Day schedule in Epoch Time in Seconds with local time offset based
on the local timezone and DST offset on the day represented by the value. */
uint32_t localEndTime; /** The ending time for the Year Day schedule in Epoch Time in Seconds with local time offset based on
* the local timezone and DST offset on the day represented by the value. */
};
/**
* @brief Structure that holds holiday schedule information.
*/
struct EmberAfPluginDoorLockHolidaySchedule
{
uint32_t localStartTime; /** The starting time for the Holiday schedule in Epoch Time in Seconds with local time offset based
on the local timezone and DST offset on the day represented by the value. */
uint32_t localEndTime; /** The ending time for the Holiday schedule in Epoch Time in Seconds with local time offset based on
* the local timezone and DST offset on the day represented by the value. */
OperatingModeEnum operatingMode; /** Operating mode during the schedule. */
};
/**
* @brief This callback is called when Door Lock cluster needs to access the Week Day schedule in the schedules database.
*
* @param endpointId ID of the endpoint which contains the lock.
* @param weekdayIndex Index of the week day schedule to access. It is guaranteed to be within limits declared in the spec for
* week day schedule (from 1 up to NumberOfWeekDaySchedulesSupportedPerUser).
* @param userIndex Index of the user to get week day schedule. It is guaranteed to be within limits declared in the spec (from 1 up
* to the value of NumberOfUsersSupported attribute).
* @param[out] schedule Resulting week day schedule.
*
* @retval DlStatus::kSuccess if schedule was retrieved successfully
* @retval DlStatus::kNotFound if the schedule or user does not exist
* @retval DlStatus::kFailure in case of any other failure
*/
DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex,
EmberAfPluginDoorLockWeekDaySchedule & schedule);
/**
* @brief This callback is called when Door Lock cluster needs to access the Year Day schedule in the schedules database.
*
* @param endpointId ID of the endpoint which contains the lock.
* @param yearDayIndex Index of the year day schedule to access. It is guaranteed to be within limits declared in the spec for
* year day schedule (from 1 up to NumberOfYearDaySchedulesSupportedPerUser)
* @param userIndex Index of the user to get year day schedule. It is guaranteed to be within limits declared in the spec (from 1 up
* to the value of NumberOfUsersSupported attribute).
* @param[out] schedule Resulting year day schedule.
*
* @retval DlStatus::kSuccess if schedule was retrieved successfully
* @retval DlStatus::kNotFound if the schedule or user does not exist
* @retval DlStatus::kFailure in case of any other failure
*/
DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex,
EmberAfPluginDoorLockYearDaySchedule & schedule);
/**
* @brief This callback is called when Door Lock cluster needs to access the Holiday schedule in the schedules database.
*
* @param endpointId ID of the endpoint which contains the lock.
* @param holidayIndex Index of the holiday schedule to access. It is guaranteed to be within limits declared in the spec for
* holiday schedule (from 1 up to NumberOfHolidaySchedulesSupported)
* @param[out] schedule Resulting holiday schedule.
*
* @retval DlStatus::kSuccess if schedule was retrieved successfully
* @retval DlStatus::kNotFound if the schedule or user does not exist
* @retval DlStatus::kFailure in case of any other failure
*/
DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex,
EmberAfPluginDoorLockHolidaySchedule & schedule);
/**
* @brief This callback is called when Door Lock cluster needs to create, modify or clear the week day schedule in schedules
* database.
*
* @param endpointId ID of the endpoint which contains the lock.
* @param weekdayIndex Index of the week day schedule to access. It is guaranteed to be within limits declared in the spec for
* week day schedule (from 1 up to NumberOfWeekDaySchedulesSupportedPerUser).
* @param userIndex Index of the user to get year day schedule. It is guaranteed to be within limits declared in the spec (from 1 up
* to the value of NumberOfUsersSupported attribute).
* @param status New status of the schedule slot (occupied/available). DlScheduleStatus::kAvailable means that the
* schedules must be deleted.
* @param daysMask Indicates the days of the week the Week Day schedule applies for.
* @param startHour Starting hour for the Week Day schedule.
* @param startMinute Starting minute for the Week Day schedule
* @param endHour Ending hour for the Week Day schedule. Guaranteed to be greater or equal to \p startHour.
* @param endMinute Ending minute for the Week Day schedule. If \p endHour is equal to \p startHour then EndMinute
* is guaranteed to be greater than \p startMinute.
*
* @retval DlStatus::kSuccess if schedule was successfully modified
* @retval DlStatus::kNotFound if the schedule or user does not exist
* @retval DlStatus::kFailure in case of any other failure
*/
DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex,
DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute,
uint8_t endHour, uint8_t endMinute);
/**
* @brief This callback is called when Door Lock cluster needs to create, modify or clear the year day schedule in schedules
* database.
*
* @param endpointId ID of the endpoint which contains the lock.
* @param yearDayIndex Index of the year day schedule to access. It is guaranteed to be within limits declared in the spec for
* year day schedule (from 1 up to NumberOfYearDaySchedulesSupportedPerUser).
* @param userIndex Index of the user to get year day schedule. It is guaranteed to be within limits declared in the spec (from 1 up
* to the value of NumberOfUsersSupported attribute).
* @param status New status of the schedule slot (occupied/available). DlScheduleStatus::kAvailable means that the
* schedules must be deleted.
* @param localStartTime The starting time for the Year Day schedule in Epoch Time in Seconds with local time offset based on the
* local timezone and DST offset on the day represented by the value.
* @param localEndTime The ending time for the Year Day schedule in Epoch Time in Seconds with local time offset based on the local
* timezone and DST offset on the day represented by the value. \p localEndTime is guaranteed to be greater than
* \p localStartTime.
*
* @retval DlStatus::kSuccess if schedule was successfully modified
* @retval DlStatus::kNotFound if the schedule or user does not exist
* @retval DlStatus::kFailure in case of any other failure
*/
DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex,
DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime);
/**
* @brief This callback is called when Door Lock cluster needs to create, modify or clear the holiday schedule in schedules
* database.
*
* @param endpointId ID of the endpoint which contains the lock.
* @param holidayIndex Index of the holiday schedule to access. It is guaranteed to be within limits declared in the spec for
* holiday schedule (from 1 up to NumberOfHolidaySchedulesSupported).
* @param status New status of the schedule slot (occupied/available). DlScheduleStatus::kAvailable means that the
* schedules must be deleted.
* @param localStartTime The starting time for the Year Day schedule in Epoch Time in Seconds with local time offset based on the
* local timezone and DST offset on the day represented by the value.
* @param localEndTime The ending time for the Year Day schedule in Epoch Time in Seconds with local time offset based on the local
* timezone and DST offset on the day represented by the value. \p localEndTime is guaranteed to be greater than
* \p localStartTime.
* @param operatingMode The operating mode to use during this Holiday schedule start/end time.
*
* @retval DlStatus::kSuccess if schedule was successfully modified
* @retval DlStatus::kNotFound if the schedule or user does not exist
* @retval DlStatus::kFailure in case of any other failure
*/
DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status,
uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode);
// =============================================================================
// Pre-change callbacks for cluster attributes
// =============================================================================
/** @brief 'Language' attribute pre-change callback
*
* @param EndpointId endpoint for which attribute is changing
* @param newLanguage language to set
*
* @retval InteractionModel::Status::Success if attribute change is possible
* @retval any other InteractionModel::Status value to forbid attribute change
*/
chip::Protocols::InteractionModel::Status emberAfPluginDoorLockOnLanguageChange(chip::EndpointId EndpointId,
chip::CharSpan newLanguage);
/** @brief 'AutoRelockTime' attribute pre-change callback
*
* @param EndpointId endpoint for which attribute is changing
* @param newTime relock time value to set
*
* @retval InteractionModel::Status::Success if attribute change is possible
* @retval any other InteractionModel::Status value to forbid attribute change
*/
chip::Protocols::InteractionModel::Status emberAfPluginDoorLockOnAutoRelockTimeChange(chip::EndpointId EndpointId,
uint32_t newTime);
/** @brief 'SoundVolume' attribute pre-change callback
*
* @param EndpointId endpoint for which attribute is changing
* @param newVolume volume level to set
*
* @retval InteractionModel::Status::Success if attribute change is possible
* @retval any other InteractionModel::Status value to forbid attribute change
*/
chip::Protocols::InteractionModel::Status emberAfPluginDoorLockOnSoundVolumeChange(chip::EndpointId EndpointId, uint8_t newVolume);
/** @brief 'OperatingMode' attribute pre-change callback
*
* @param EndpointId endpoint for which attribute is changing
* @param newMode operating mode to set
*
* @retval InteractionModel::Status::Success if attribute change is possible
* @retval any other InteractionModel::Status value to forbid attribute change
*/
chip::Protocols::InteractionModel::Status emberAfPluginDoorLockOnOperatingModeChange(chip::EndpointId EndpointId, uint8_t newMode);
/** @brief 'EnableOneTouchLocking' attribute pre-change callback
*
* @param EndpointId endpoint for which attribute is changing
* @param enable true to enable one touch locking, false otherwise
*
* @retval InteractionModel::Status::Success if attribute change is possible
* @retval any other InteractionModel::Status value to forbid attribute change
*/
chip::Protocols::InteractionModel::Status emberAfPluginDoorLockOnEnableOneTouchLockingChange(chip::EndpointId EndpointId,
bool enable);
/** @brief 'EnablePrivacyModeButton' attribute pre-change callback
*