|
| 1 | +/* |
| 2 | + * |
| 3 | + * Copyright (c) 2024 Project CHIP Authors |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#include <app/CommandHandler.h> |
| 19 | +#include <app/clusters/occupancy-sensor-server/occupancy-hal.h> |
| 20 | +#include <app/clusters/occupancy-sensor-server/occupancy-sensor-server.h> |
| 21 | +#include <platform/CHIPDeviceLayer.h> |
| 22 | + |
| 23 | +using namespace chip; |
| 24 | +using namespace chip::app::Clusters; |
| 25 | +using namespace chip::app::Clusters::OccupancySensing; |
| 26 | +using namespace chip::app::Clusters::OccupancySensing::Structs; |
| 27 | +using namespace chip::DeviceLayer; |
| 28 | + |
| 29 | +using chip::Protocols::InteractionModel::Status; |
| 30 | + |
| 31 | +static std::unique_ptr<OccupancySensingAttrAccess> |
| 32 | + gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; |
| 33 | + |
| 34 | +void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId) |
| 35 | +{ |
| 36 | + VerifyOrDie(!gAttrAccess[endpointId]); |
| 37 | + |
| 38 | + gAttrAccess[endpointId] = std::make_unique<OccupancySensingAttrAccess>( |
| 39 | + BitMask<OccupancySensing::Feature, uint32_t>(OccupancySensing::Feature::kOther)); |
| 40 | + |
| 41 | + OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = { |
| 42 | + .holdTimeMin = 1, |
| 43 | + .holdTimeMax = 300, |
| 44 | + .holdTimeDefault = 10, |
| 45 | + }; |
| 46 | + |
| 47 | + uint16_t holdTime = 10; |
| 48 | + |
| 49 | + if (gAttrAccess[endpointId]) |
| 50 | + { |
| 51 | + gAttrAccess[endpointId]->Init(); |
| 52 | + |
| 53 | + SetHoldTimeLimits(endpointId, holdTimeLimits); |
| 54 | + |
| 55 | + SetHoldTime(endpointId, holdTime); |
| 56 | + } |
| 57 | +} |
0 commit comments