Skip to content

Commit

Permalink
Door lock cluster relocking support (project-chip#14881)
Browse files Browse the repository at this point in the history
* Remove obsolete EmberEventControl contexts from DoorLock server and af-gen-event.h

* Refactored cluster attributes getting/setting + enabled forgotten 'RequirePINforRemoteOperation' in door-lock-app

* Auto relocking support
1. UnlockDoor command + AutoRelockTime timeout
2. UnlockWithTimeout command + user timeout

* Update autogenerated files
  • Loading branch information
truebiker authored Feb 8, 2022
1 parent 07df686 commit 68b451e
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ server cluster DoorLock = 257 {
attribute boolean enablePrivacyModeButton = 43;
attribute int8u wrongCodeEntryLimit = 48;
attribute int8u userCodeTemporaryDisableTime = 49;
attribute boolean requirePINforRemoteOperation = 51;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
4 changes: 2 additions & 2 deletions examples/door-lock-app/door-lock-common/door-lock-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -6868,12 +6868,12 @@
"code": 51,
"mfgCode": null,
"side": "server",
"included": 0,
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 0,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
Expand Down
294 changes: 135 additions & 159 deletions src/app/clusters/door-lock-server/door-lock-server.cpp

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DoorLockServer
bool SetOneTouchLocking(chip::EndpointId endpointId, bool isEnabled);
bool SetPrivacyModeButton(chip::EndpointId endpointId, bool isEnabled);

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);
Expand Down Expand Up @@ -293,6 +294,14 @@ class DoorLockServer
Nullable<chip::NodeId> nodeId, LockOpCredentials * credList, size_t credListSize,
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
*
Expand All @@ -303,6 +312,36 @@ class DoorLockServer
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>
bool GetAttribute(chip::EndpointId endpointId, chip::AttributeId attributeId,
EmberAfStatus (*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,
EmberAfStatus (*setFn)(chip::EndpointId endpointId, T value), T value);

friend bool
emberAfDoorLockClusterLockDoorCallback(chip::app::CommandHandler * commandObj,
const chip::app::ConcreteCommandPath & commandPath,
Expand All @@ -316,6 +355,10 @@ 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);

EmberEventControl AutolockEvent; /**< for automatic relock scheduling */

static DoorLockServer instance;
};

Expand Down
4 changes: 0 additions & 4 deletions zzz_generated/all-clusters-app/zap-generated/af-gen-event.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions zzz_generated/door-lock-app/zap-generated/endpoint_config.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions zzz_generated/thermostat/zap-generated/af-gen-event.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions zzz_generated/tv-casting-app/zap-generated/af-gen-event.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 68b451e

Please sign in to comment.