@@ -35,33 +35,20 @@ void ZigbeeTempSensor::setTolerance(float tolerance) {
3535}
3636
3737void ZigbeeTempSensor::setReporting (uint16_t min_interval, uint16_t max_interval, float delta) {
38- esp_zb_zcl_reporting_info_t reporting_info = {
39- .direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV,
40- .ep = _endpoint,
41- .cluster_id = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT,
42- .cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
43- .attr_id = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID,
44- .u =
45- {
46- .send_info =
47- {
48- .min_interval = min_interval,
49- .max_interval = max_interval,
50- .delta =
51- {
52- .u16 = (uint16_t )(delta * 100 ), // Convert delta to ZCL uint16_t
53- },
54- .def_min_interval = min_interval,
55- .def_max_interval = max_interval,
56- },
57- },
58- .dst =
59- {
60- .profile_id = ESP_ZB_AF_HA_PROFILE_ID,
61- },
62- .manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC,
63- };
64- esp_zb_lock_acquire (portMAX_DELAY);
38+ esp_zb_zcl_reporting_info_t reporting_info;
39+ memset (&reporting_info, 0 , sizeof (esp_zb_zcl_reporting_info_t ));
40+ reporting_info.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV;
41+ reporting_info.ep = _endpoint;
42+ reporting_info.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
43+ reporting_info.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE;
44+ reporting_info.attr_id = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID;
45+ reporting_info.u .send_info .min_interval = min_interval;
46+ reporting_info.u .send_info .max_interval = max_interval;
47+ reporting_info.u .send_info .def_min_interval = min_interval;
48+ reporting_info.u .send_info .def_max_interval = max_interval;
49+ reporting_info.u .send_info .delta .u16 = (uint16_t )(delta * 100 ); // Convert delta to ZCL uint16_t
50+ reporting_info.dst .profile_id = ESP_ZB_AF_HA_PROFILE_ID;
51+ reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC, esp_zb_lock_acquire (portMAX_DELAY);
6552 esp_zb_zcl_update_reporting_info (&reporting_info);
6653 esp_zb_lock_release ();
6754}
@@ -136,32 +123,20 @@ void ZigbeeTempSensor::reportHumidity() {
136123}
137124
138125void ZigbeeTempSensor::setHumidityReporting (uint16_t min_interval, uint16_t max_interval, float delta) {
139- esp_zb_zcl_reporting_info_t reporting_info = {
140- .direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV,
141- .ep = _endpoint,
142- .cluster_id = ESP_ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT,
143- .cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
144- .attr_id = ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID,
145- .u =
146- {
147- .send_info =
148- {
149- .min_interval = min_interval,
150- .max_interval = max_interval,
151- .delta =
152- {
153- .u16 = (uint16_t )(delta * 100 ), // Convert delta to ZCL uint16_t
154- },
155- .def_min_interval = min_interval,
156- .def_max_interval = max_interval,
157- },
158- },
159- .dst =
160- {
161- .profile_id = ESP_ZB_AF_HA_PROFILE_ID,
162- },
163- .manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC,
164- };
126+ esp_zb_zcl_reporting_info_t reporting_info;
127+ memset (&reporting_info, 0 , sizeof (esp_zb_zcl_reporting_info_t ));
128+ reporting_info.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV;
129+ reporting_info.ep = _endpoint;
130+ reporting_info.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT;
131+ reporting_info.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE;
132+ reporting_info.attr_id = ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID;
133+ reporting_info.u .send_info .min_interval = min_interval;
134+ reporting_info.u .send_info .max_interval = max_interval;
135+ reporting_info.u .send_info .def_min_interval = min_interval;
136+ reporting_info.u .send_info .def_max_interval = max_interval;
137+ reporting_info.u .send_info .delta .u16 = (uint16_t )(delta * 100 ); // Convert delta to ZCL uint16_t
138+ reporting_info.dst .profile_id = ESP_ZB_AF_HA_PROFILE_ID;
139+ reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC;
165140 esp_zb_lock_acquire (portMAX_DELAY);
166141 esp_zb_zcl_update_reporting_info (&reporting_info);
167142 esp_zb_lock_release ();
0 commit comments