nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
onoff_light.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#pragma once
8
9#include "matter_bridged_device.h"
10
11class OnOffLightDevice : public Nrf::MatterBridgedDevice {
12public:
13 OnOffLightDevice(const char *nodeLabel);
14
15 bool GetOnOff() { return mOnOff; }
16 void Toggle() { mOnOff = !mOnOff; }
17
18 uint16_t GetDeviceType() const override { return Nrf::MatterBridgedDevice::DeviceType::OnOffLight; }
19 CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
20 uint16_t maxReadLength) override;
21 CHIP_ERROR HandleReadOnOff(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength);
22 CHIP_ERROR HandleReadGroups(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength);
23 CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, size_t size) override;
24 CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data,
25 size_t dataSize) override;
26
27 static constexpr uint16_t GetOnOffClusterRevision() { return 5; }
28 static constexpr uint32_t GetOnOffFeatureMap() { return 1; }
29 static constexpr uint16_t GetGroupsClusterRevision() { return 4; }
30 static constexpr uint32_t GetGroupsFeatureMap() { return 1; }
31 static constexpr uint8_t GetGroupsNameSupportMap() { return 0; }
32
33private:
34 bool mOnOff{ false };
35 bool mGlobalSceneControl{ false };
36 int16_t mOnTime{ 0 };
37 int16_t mOffWaitTime{ 0 };
38 chip::app::Clusters::OnOff::StartUpOnOffEnum mStartUpOnOff{
39 chip::app::Clusters::OnOff::StartUpOnOffEnum::kUnknownEnumValue
40 };
41};
static constexpr uint8_t GetGroupsNameSupportMap()
Definition: onoff_light.h:31
CHIP_ERROR HandleReadGroups(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
static constexpr uint32_t GetOnOffFeatureMap()
Definition: onoff_light.h:28
CHIP_ERROR HandleReadOnOff(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
uint16_t GetDeviceType() const override
Definition: onoff_light.h:18
bool GetOnOff()
Definition: onoff_light.h:15
static constexpr uint32_t GetGroupsFeatureMap()
Definition: onoff_light.h:30
CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength) override
static constexpr uint16_t GetGroupsClusterRevision()
Definition: onoff_light.h:29
void Toggle()
Definition: onoff_light.h:16
static constexpr uint16_t GetOnOffClusterRevision()
Definition: onoff_light.h:27
CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, size_t size) override
OnOffLightDevice(const char *nodeLabel)
CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data, size_t dataSize) override
Definition: onoff_light.h:11