| /* |
| * |
| * Copyright (c) 2024 Project CHIP Authors |
| * All rights reserved. |
| * |
| * 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. |
| */ |
| #include "ClosureControlEndpoint.h" |
| #include "ClosureDimensionEndpoint.h" |
| #include <AppMain.h> |
| |
| #include <app-common/zap-generated/cluster-objects.h> |
| #include <app/util/attribute-storage.h> |
| #include <platform/CHIPDeviceLayer.h> |
| |
| using namespace chip; |
| using namespace chip::app; |
| using namespace chip::app::Clusters::ClosureControl; |
| using namespace chip::app::Clusters::ClosureDimension; |
| |
| namespace { |
| |
| // Define the endpoint ID for the Closure |
| constexpr chip::EndpointId kClosureEndpoint = 1; |
| constexpr chip::EndpointId kClosurePanel1Endpoint = 2; |
| constexpr chip::EndpointId kClosurePanel2Endpoint = 3; |
| |
| // Closure Endpoints |
| ClosureControlEndpoint ep1(kClosureEndpoint); |
| ClosureDimensionEndpoint ep2(kClosurePanel1Endpoint); |
| ClosureDimensionEndpoint ep3(kClosurePanel2Endpoint); |
| |
| // Define the Namespace and Tag for the endpoint |
| // Derived from https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces/Namespace-Closure.adoc |
| constexpr uint8_t kNamespaceClosure = 0x44; |
| constexpr uint8_t kTagClosureCovering = 0x00; |
| // Derived from |
| // https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces/Namespace-Closure-Covering.adoc |
| constexpr uint8_t kNamespaceCovering = 0x46; |
| constexpr uint8_t kTagCoveringVenetian = 0x03; |
| // Derived from https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces/Namespace-ClosurePanel.adoc |
| constexpr uint8_t kNamespaceClosurePanel = 0x45; |
| constexpr uint8_t kTagClosurePanelLift = 0x00; |
| constexpr uint8_t kTagClosurePanelTilt = 0x01; |
| |
| // Define the list of semantic tags for the endpoint |
| const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp1TagList[] = { |
| { .namespaceID = kNamespaceClosure, |
| .tag = kTagClosureCovering, |
| .label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("Closure.Covering"_span)) }, |
| { .namespaceID = kNamespaceCovering, |
| .tag = kTagCoveringVenetian, |
| .label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("Covering.Venetian"_span)) }, |
| }; |
| |
| const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp2TagList[] = { |
| { .namespaceID = kNamespaceClosurePanel, |
| .tag = kTagClosurePanelLift, |
| .label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("ClosurePanel.Lift"_span)) }, |
| }; |
| |
| const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp3TagList[] = { |
| { .namespaceID = kNamespaceClosurePanel, |
| .tag = kTagClosurePanelTilt, |
| .label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("ClosurePanel.Tilt"_span)) }, |
| }; |
| |
| } // namespace |
| |
| void ApplicationInit() |
| { |
| DeviceLayer::PlatformMgr().LockChipStack(); |
| |
| // Closure endpoints initilization |
| ep1.Init(); |
| ep2.Init(); |
| ep3.Init(); |
| |
| // Set Taglist for Closure endpoints |
| SetTagList(/* endpoint= */ 1, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gEp1TagList)); |
| SetTagList(/* endpoint= */ 2, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gEp2TagList)); |
| SetTagList(/* endpoint= */ 3, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gEp3TagList)); |
| |
| DeviceLayer::PlatformMgr().UnlockChipStack(); |
| } |
| |
| void ApplicationShutdown() |
| { |
| ChipLogDetail(NotSpecified, "ApplicationShutdown()"); |
| } |
| |
| int main(int argc, char * argv[]) |
| { |
| if (ChipLinuxAppInit(argc, argv) != 0) |
| { |
| return -1; |
| } |
| |
| ChipLinuxAppMainLoop(); |
| return 0; |
| } |