|
15 | 15 | * See the License for the specific language governing permissions and
|
16 | 16 | * limitations under the License.
|
17 | 17 | */
|
18 |
| -#ifdef MATTER_DM_PLUGIN_DOOR_LOCK_SERVER |
19 |
| -#include "chef-lock-endpoint.h" |
20 |
| -#include <app-common/zap-generated/attributes/Accessors.h> |
| 18 | + |
| 19 | + |
21 | 20 | #include <cstring>
|
| 21 | +#include <app/util/af.h> |
| 22 | +#include <app-common/zap-generated/attributes/Accessors.h> |
22 | 23 | #include <platform/CHIPDeviceLayer.h>
|
23 | 24 | #include <platform/internal/CHIPDeviceLayerInternal.h>
|
24 | 25 |
|
| 26 | +#ifdef MATTER_DM_PLUGIN_DOOR_LOCK_SERVER |
| 27 | +#include "chef-lock-endpoint.h" |
| 28 | + |
25 | 29 | using chip::to_underlying;
|
26 | 30 | using chip::app::DataModel::MakeNullable;
|
27 | 31 |
|
@@ -83,7 +87,7 @@ bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & u
|
83 | 87 | return true;
|
84 | 88 | }
|
85 | 89 |
|
86 |
| - user.userName = chip::CharSpan(userInDb.userName, strlen(userInDb.userName)); |
| 90 | + user.userName = userInDb.userName; |
87 | 91 | user.credentials = chip::Span<const CredentialStruct>(userInDb.credentials.data(), userInDb.credentials.size());
|
88 | 92 | user.userUniqueId = userInDb.userUniqueId;
|
89 | 93 | user.userType = userInDb.userType;
|
@@ -145,8 +149,8 @@ bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::
|
145 | 149 | return false;
|
146 | 150 | }
|
147 | 151 |
|
148 |
| - chip::Platform::CopyString(userInStorage.userName, userName); |
149 |
| - userInStorage.userName[userName.size()] = 0; |
| 152 | + userInStorage.userName = chip::MutableCharSpan(userInStorage.userNameBuf, DOOR_LOCK_USER_NAME_BUFFER_SIZE); |
| 153 | + CopyCharSpanToMutableCharSpan(userName, userInStorage.userName); |
150 | 154 | userInStorage.userUniqueId = uniqueId;
|
151 | 155 | userInStorage.userStatus = userStatus;
|
152 | 156 | userInStorage.userType = usertype;
|
@@ -606,9 +610,7 @@ bool LockEndpoint::weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveS
|
606 | 610 | [currentTime, calendarTime](const WeekDaysScheduleInfo & s) {
|
607 | 611 | auto startTime = s.schedule.startHour * chip::kSecondsPerHour + s.schedule.startMinute * chip::kSecondsPerMinute;
|
608 | 612 | auto endTime = s.schedule.endHour * chip::kSecondsPerHour + s.schedule.endMinute * chip::kSecondsPerMinute;
|
609 |
| - bool ret = |
610 |
| - (s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) && |
611 |
| - startTime <= currentTime && currentTime <= endTime); |
| 613 | + |
612 | 614 | return s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) &&
|
613 | 615 | startTime <= currentTime && currentTime <= endTime;
|
614 | 616 | });
|
|
0 commit comments