nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
humidity_sensor.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 HumiditySensorDevice : public Nrf::MatterBridgedDevice {
12public:
13 HumiditySensorDevice(const char *nodeLabel);
14
15 uint16_t GetMeasuredValue() { return mMeasuredValue; }
16 uint16_t GetMinMeasuredValue() { return mMinMeasuredValue; }
17 uint16_t GetMaxMeasuredValue() { return mMaxMeasuredValue; }
18
19 uint16_t GetDeviceType() const override { return Nrf::MatterBridgedDevice::DeviceType::HumiditySensor; }
20 CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
21 uint16_t maxReadLength) override;
22 CHIP_ERROR HandleReadRelativeHumidityMeasurement(chip::AttributeId attributeId, uint8_t *buffer,
23 uint16_t maxReadLength);
24 CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
25 size_t size) override
26 {
27 if (clusterId != chip::app::Clusters::BridgedDeviceBasicInformation::Id) {
28 return CHIP_ERROR_INVALID_ARGUMENT;
29 }
30
31 switch (attributeId) {
32 case chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::NodeLabel::Id:
33 return HandleWriteDeviceBasicInformation(clusterId, attributeId, buffer, size);
34 default:
35 return CHIP_ERROR_INVALID_ARGUMENT;
36 }
37 return CHIP_NO_ERROR;
38 }
39 CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data,
40 size_t dataSize) override;
41
42 static constexpr uint16_t GetRelativeHumidityMeasurementClusterRevision() { return 3; }
43 static constexpr uint32_t GetRelativeHumidityMeasurementFeatureMap() { return 0; }
44
45private:
46 void SetMeasuredValue(int16_t value) { mMeasuredValue = value; }
47 void SetMinMeasuredValue(int16_t value) { mMinMeasuredValue = value; }
48 void SetMaxMeasuredValue(int16_t value) { mMaxMeasuredValue = value; }
49
50 uint16_t mMeasuredValue = 0;
51 uint16_t mMinMeasuredValue = CONFIG_BRIDGE_HUMIDITY_SENSOR_MIN_MEASURED_VALUE;
52 uint16_t mMaxMeasuredValue = CONFIG_BRIDGE_HUMIDITY_SENSOR_MAX_MEASURED_VALUE;
53};
CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, size_t size) override
Definition: humidity_sensor.h:24
CHIP_ERROR HandleReadRelativeHumidityMeasurement(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data, size_t dataSize) override
uint16_t GetDeviceType() const override
Definition: humidity_sensor.h:19
uint16_t GetMaxMeasuredValue()
Definition: humidity_sensor.h:17
uint16_t GetMeasuredValue()
Definition: humidity_sensor.h:15
static constexpr uint16_t GetRelativeHumidityMeasurementClusterRevision()
Definition: humidity_sensor.h:42
uint16_t GetMinMeasuredValue()
Definition: humidity_sensor.h:16
CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength) override
static constexpr uint32_t GetRelativeHumidityMeasurementFeatureMap()
Definition: humidity_sensor.h:43
HumiditySensorDevice(const char *nodeLabel)
Definition: humidity_sensor.h:11