nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
temperature_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 TemperatureSensorDevice : public Nrf::MatterBridgedDevice {
12public:
13 TemperatureSensorDevice(const char *nodeLabel);
14
15 int16_t GetMeasuredValue() { return mMeasuredValue; }
16 int16_t GetMinMeasuredValue() { return mMinMeasuredValue; }
17 int16_t GetMaxMeasuredValue() { return mMaxMeasuredValue; }
18
19 uint16_t GetDeviceType() const override { return Nrf::MatterBridgedDevice::DeviceType::TemperatureSensor; }
20 CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
21 uint16_t maxReadLength) override;
22 CHIP_ERROR HandleReadTemperatureMeasurement(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 GetTemperatureMeasurementClusterRevision() { return 4; }
43 static constexpr uint32_t GetTemperatureMeasurementFeatureMap() { 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 int16_t mMeasuredValue = 0;
51 int16_t mMinMeasuredValue = CONFIG_BRIDGE_TEMPERATURE_SENSOR_MIN_MEASURED_VALUE;
52 int16_t mMaxMeasuredValue = CONFIG_BRIDGE_TEMPERATURE_SENSOR_MAX_MEASURED_VALUE;
53};
uint16_t GetDeviceType() const override
Definition: temperature_sensor.h:19
CHIP_ERROR HandleReadTemperatureMeasurement(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
TemperatureSensorDevice(const char *nodeLabel)
CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, size_t size) override
Definition: temperature_sensor.h:24
CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data, size_t dataSize) override
CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength) override
static constexpr uint32_t GetTemperatureMeasurementFeatureMap()
Definition: temperature_sensor.h:43
int16_t GetMaxMeasuredValue()
Definition: temperature_sensor.h:17
int16_t GetMeasuredValue()
Definition: temperature_sensor.h:15
int16_t GetMinMeasuredValue()
Definition: temperature_sensor.h:16
static constexpr uint16_t GetTemperatureMeasurementClusterRevision()
Definition: temperature_sensor.h:42
Definition: temperature_sensor.h:11