13#include "esp_zigbee.h"
29 template<
typename T>
void add_attr(uint8_t attr_access, T
value);
31 template<
typename T>
void add_attr(uint8_t attr_access, T
value, T *storage);
62 *
static_cast<T *
>(this->
value_p_) = value;
68 static_assert(
sizeof(T) <= 2 || std::is_floating_point_v<T>);
69 if constexpr (std::is_integral<T>::value) {
70 const float scaled = scale *
value;
71 if (std::isnan(
value) || scaled <
static_cast<float>(std::numeric_limits<T>::lowest()) ||
72 scaled >
static_cast<float>(std::numeric_limits<T>::max())) {
75 return static_cast<T
>(lroundf(scaled));
77 return static_cast<T
>(scale *
value);
81 if constexpr (std::is_integral_v<T>) {
82 if constexpr (std::is_signed_v<T>) {
84 return static_cast<T
>(std::numeric_limits<T>::min());
87 if (this->
attr_type_ >= EZB_ZCL_ATTR_TYPE_UINT8 && this->
attr_type_ <= EZB_ZCL_ATTR_TYPE_ENUM16) {
89 return static_cast<T
>(std::numeric_limits<T>::max());
93 return static_cast<T
>(0);
96 return std::numeric_limits<T>::quiet_NaN();
void enable_loop()
Enable this component's loop.
void set_attr(const T &value)
ZigbeeAttributeBase(ZigbeeComponent *parent, uint8_t endpoint_id, uint16_t cluster_id, uint8_t role, uint16_t attr_id, uint8_t attr_type, uint8_t max_size=0)
void set_attr_internal() override
T scale_value_(float value, float scale)
void report_internal(bool has_lock) override
void add_attr(uint8_t attr_access, T value)
void add_attr(ZigbeeAttributeInterface *attr, uint8_t endpoint_id, uint16_t cluster_id, uint8_t role, uint16_t attr_id, uint8_t max_size, uint8_t attr_type, uint8_t attr_access, T value)