Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 645728f

Browse files
authoredJun 7, 2025··
Merge branch 'master' into DNSServer-EDNS
2 parents e64e96a + 31d22e6 commit 645728f

File tree

21 files changed

+597
-107
lines changed

21 files changed

+597
-107
lines changed
 

‎.github/CODEOWNERS

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# CODEOWNERS for ESP32 Arduino Core
2+
3+
# This file is used to specify the code owners for the ESP32 Arduino Core.
4+
# Read more about CODEOWNERS:
5+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
6+
# Note that order matters. The last matching pattern will be used.
7+
8+
# The default owners are the active developers of the ESP32 Arduino Core.
9+
# Refrain from using @espressif/arduino-esp32 to avoid spamming non-developers with review requests.
10+
* @espressif/arduino-devs
11+
12+
# CI
13+
/.github/ @lucasssvaz @me-no-dev @P-R-O-C-H-Y
14+
/tests/ @lucasssvaz @P-R-O-C-H-Y
15+
16+
# Tools
17+
/tools/ @me-no-dev
18+
/tools/pre-commit/ @lucasssvaz
19+
/tools/add_lib.sh @P-R-O-C-H-Y
20+
21+
# Pre-commit
22+
/.* @lucasssvaz # Files in root directory that start with a dot.
23+
24+
# Git Files
25+
/.gitignore @espressif/arduino-devs
26+
/.gitmodules @espressif/arduino-devs
27+
28+
# Documentation
29+
/docs/ @pedrominatel
30+
/.github/ISSUE_TEMPLATE/ @pedrominatel
31+
/.github/PULL_REQUEST_TEMPLATE.md @pedrominatel
32+
/.readthedocs.yaml @pedrominatel
33+
/*.md @pedrominatel
34+
35+
# Boards
36+
/variants/ @P-R-O-C-H-Y
37+
/boards.txt @P-R-O-C-H-Y
38+
39+
# Arduino as Component
40+
/idf_component_examples/ @SuGlider
41+
/idf_component.yml @SuGlider @me-no-dev
42+
/CMakeLists.txt @SuGlider @me-no-dev
43+
/Kconfig.projbuild @SuGlider @me-no-dev
44+
45+
# Build System
46+
/package.json @me-no-dev
47+
/platform.txt @me-no-dev
48+
/programmers.txt @me-no-dev
49+
/package/ @me-no-dev
50+
51+
# Libraries
52+
/libraries/ArduinoOTA/ @me-no-dev
53+
/libraries/AsyncUDP/ @me-no-dev
54+
/libraries/BLE/ @lucasssvaz @SuGlider
55+
/libraries/ESP_I2S/ @me-no-dev
56+
/libraries/ESP_NOW/ @P-R-O-C-H-Y @lucasssvaz
57+
/libraries/ESP_SR/ @me-no-dev
58+
/libraries/ESPmDNS/ @me-no-dev
59+
/libraries/Ethernet/ @me-no-dev
60+
/libraries/Matter/ @SuGlider
61+
/libraries/NetBIOS/ @me-no-dev
62+
/libraries/Network/ @me-no-dev
63+
/libraries/OpenThread/ @SuGlider
64+
/libraries/PPP/ @me-no-dev
65+
/libraries/SPI/ @me-no-dev
66+
/libraries/Update/ @me-no-dev
67+
/libraries/USB/ @SuGlider @me-no-dev
68+
/libraries/WiFi/ @me-no-dev
69+
/libraries/WiFiProv/ @me-no-dev
70+
/libraries/Wire/ @me-no-dev
71+
/libraries/Zigbee/ @P-R-O-C-H-Y
72+
73+
# CI JSON
74+
# Keep this after other libraries and tests to avoid being overridden.
75+
**/ci.json @lucasssvaz
76+
77+
# The CODEOWNERS file should be owned by the developers of the ESP32 Arduino Core.
78+
# Leave this entry as the last one to avoid being overridden.
79+
/.github/CODEOWNERS @espressif/arduino-devs

‎boards.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41778,6 +41778,13 @@ Geekble_Nano_ESP32S3.menu.PartitionScheme.custom=Custom
4177841778
Geekble_Nano_ESP32S3.menu.PartitionScheme.custom.build.partitions=
4177941779
Geekble_Nano_ESP32S3.menu.PartitionScheme.custom.upload.maximum_size=16777216
4178041780

41781+
Geekble_Nano_ESP32S3.menu.PSRAM.disabled=Disabled
41782+
Geekble_Nano_ESP32S3.menu.PSRAM.disabled.build.defines=
41783+
Geekble_Nano_ESP32S3.menu.PSRAM.disabled.build.psram_type=qspi
41784+
Geekble_Nano_ESP32S3.menu.PSRAM.enabled=Enabled
41785+
Geekble_Nano_ESP32S3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM
41786+
Geekble_Nano_ESP32S3.menu.PSRAM.enabled.build.psram_type=qspi
41787+
4178141788
Geekble_Nano_ESP32S3.menu.DebugLevel.none=None
4178241789
Geekble_Nano_ESP32S3.menu.DebugLevel.none.build.code_debug=0
4178341790
Geekble_Nano_ESP32S3.menu.DebugLevel.error=Error

‎cores/esp32/esp32-hal-bt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "esp32-hal-bt.h"
1616

1717
#if SOC_BT_SUPPORTED
18-
#ifdef CONFIG_BT_BLUEDROID_ENABLED
18+
#if defined(CONFIG_BT_BLUEDROID_ENABLED) && __has_include("esp_bt.h")
1919

2020
#if CONFIG_IDF_TARGET_ESP32
2121
bool btInUse() {

‎idf_component.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ dependencies:
6868
# RainMaker Start (Fixed versions, because Matter supports only Insights 1.0.1)
6969
espressif/network_provisioning:
7070
version: "1.0.2"
71+
rules:
72+
- if: "target != esp32c2"
7173
espressif/esp_rainmaker:
7274
version: "1.5.2"
7375
rules:

‎libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ void handleNotFound() {
3434

3535
void setup() {
3636
Serial.begin(115200);
37-
WiFi.mode(WIFI_AP);
38-
WiFi.softAP("ESP32-DNSServer");
37+
WiFi.AP.begin();
38+
WiFi.AP.create("ESP32-DNSServer");
39+
WiFi.AP.enableDhcpCaptivePortal();
3940

4041
// by default DNSServer is started serving any "*" domain name. It will reply
4142
// AccessPoint's IP to all DNS request (this is required for Captive Portal detection)

‎libraries/HTTPUpdate/src/HTTPUpdate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient &http, const String &curren
356356
log_e("Content-Length was 0 or wasn't set by Server?!\n");
357357
}
358358
break;
359+
case HTTP_CODE_NO_CONTENT:
359360
case HTTP_CODE_NOT_MODIFIED:
360361
///< Not Modified (No updates)
361362
ret = HTTP_UPDATE_NO_UPDATES;

‎libraries/WiFi/src/AP.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,45 @@ bool APClass::enableNAPT(bool enable) {
305305
return true;
306306
}
307307

308+
bool APClass::enableDhcpCaptivePortal() {
309+
esp_err_t err = ESP_OK;
310+
static char captiveportal_uri[32] = {
311+
0,
312+
};
313+
314+
if (!started()) {
315+
log_e("AP must be first started to enable DHCP Captive Portal");
316+
return false;
317+
}
318+
319+
// Create Captive Portal URL: http://192.168.0.4
320+
strcpy(captiveportal_uri, "http://");
321+
strcat(captiveportal_uri, String(localIP()).c_str());
322+
323+
// Stop DHCPS
324+
err = esp_netif_dhcps_stop(_esp_netif);
325+
if (err && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
326+
log_e("DHCPS Stop Failed! 0x%04x: %s", err, esp_err_to_name(err));
327+
return false;
328+
}
329+
330+
// Enable DHCP Captive Portal
331+
err = esp_netif_dhcps_option(_esp_netif, ESP_NETIF_OP_SET, ESP_NETIF_CAPTIVEPORTAL_URI, captiveportal_uri, strlen(captiveportal_uri));
332+
if (err) {
333+
log_e("Could not set enable DHCP Captive Portal! 0x%x: %s", err, esp_err_to_name(err));
334+
return false;
335+
}
336+
337+
// Start DHCPS
338+
err = esp_netif_dhcps_start(_esp_netif);
339+
if (err) {
340+
log_e("DHCPS Start Failed! 0x%04x: %s", err, esp_err_to_name(err));
341+
return false;
342+
}
343+
344+
return true;
345+
}
346+
308347
String APClass::SSID(void) const {
309348
if (!started()) {
310349
return String();

‎libraries/WiFi/src/WiFiAP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class APClass : public NetworkInterface {
5353

5454
bool bandwidth(wifi_bandwidth_t bandwidth);
5555
bool enableNAPT(bool enable = true);
56+
bool enableDhcpCaptivePortal();
5657

5758
String SSID(void) const;
5859
uint8_t stationCount();

‎libraries/Zigbee/examples/Zigbee_Analog_Input_Output/Zigbee_Analog_Input_Output.ino

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* Modified by Pat Clay
2727
*/
2828

29-
#ifndef ZIGBEE_MODE_ED
30-
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
29+
#ifndef ZIGBEE_MODE_ZCZR
30+
#error "Zigbee coordinator/router device mode is not selected in Tools->Zigbee mode"
3131
#endif
3232

3333
#include "Zigbee.h"
@@ -70,6 +70,7 @@ void setup() {
7070
zbAnalogDevice.addAnalogOutput();
7171
zbAnalogDevice.setAnalogOutputApplication(ESP_ZB_ZCL_AI_RPM_OTHER);
7272
zbAnalogDevice.setAnalogOutputDescription("Fan Speed (RPM)");
73+
zbAnalogDevice.setAnalogOutputResolution(1);
7374

7475
// If analog output cluster is added, set callback function for analog output change
7576
zbAnalogDevice.onAnalogOutputChange(onAnalogOutputChange);
@@ -99,8 +100,8 @@ void setup() {
99100
Zigbee.addEndpoint(&zbAnalogPercent);
100101

101102
Serial.println("Starting Zigbee...");
102-
// When all EPs are registered, start Zigbee in End Device mode
103-
if (!Zigbee.begin()) {
103+
// When all EPs are registered, start Zigbee in Router Device mode
104+
if (!Zigbee.begin(ZIGBEE_ROUTER)) {
104105
Serial.println("Zigbee failed to start!");
105106
Serial.println("Rebooting...");
106107
ESP.restart();
@@ -151,6 +152,9 @@ void loop() {
151152
Zigbee.factoryReset();
152153
}
153154
}
155+
// For demonstration purposes, increment the analog output value by 100
156+
zbAnalogDevice.setAnalogOutput(zbAnalogDevice.getAnalogOutput() + 100);
157+
zbAnalogDevice.reportAnalogOutput();
154158
}
155159
delay(100);
156160
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed",
2+
"fqbn_append": "PartitionScheme=zigbee_zczr,ZigbeeMode=zczr",
33
"requires": [
4-
"CONFIG_SOC_IEEE802154_SUPPORTED=y",
54
"CONFIG_ZB_ENABLED=y"
65
]
76
}

‎libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
#include "Zigbee.h"
3535

3636
/* Zigbee thermostat configuration */
37-
#define THERMOSTAT_ENDPOINT_NUMBER 5
37+
#define THERMOSTAT_ENDPOINT_NUMBER 1
38+
#define USE_RECEIVE_TEMP_WITH_SOURCE 1
3839
uint8_t button = BOOT_PIN;
3940

4041
ZigbeeThermostat zbThermostat = ZigbeeThermostat(THERMOSTAT_ENDPOINT_NUMBER);
@@ -48,13 +49,28 @@ float sensor_tolerance;
4849
struct tm timeinfo = {}; // Time structure for Time cluster
4950

5051
/****************** Temperature sensor handling *******************/
51-
void recieveSensorTemp(float temperature) {
52+
#if USE_RECEIVE_TEMP_WITH_SOURCE == 0
53+
void receiveSensorTemp(float temperature) {
5254
Serial.printf("Temperature sensor value: %.2f°C\n", temperature);
5355
sensor_temp = temperature;
5456
}
57+
#else
58+
void receiveSensorTempWithSource(float temperature, uint8_t src_endpoint, esp_zb_zcl_addr_t src_address) {
59+
if (src_address.addr_type == ESP_ZB_ZCL_ADDR_TYPE_SHORT) {
60+
Serial.printf("Temperature sensor value: %.2f°C from endpoint %d, address 0x%04x\n", temperature, src_endpoint, src_address.u.short_addr);
61+
} else {
62+
Serial.printf(
63+
"Temperature sensor value: %.2f°C from endpoint %d, address %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", temperature, src_endpoint,
64+
src_address.u.ieee_addr[7], src_address.u.ieee_addr[6], src_address.u.ieee_addr[5], src_address.u.ieee_addr[4], src_address.u.ieee_addr[3],
65+
src_address.u.ieee_addr[2], src_address.u.ieee_addr[1], src_address.u.ieee_addr[0]
66+
);
67+
}
68+
sensor_temp = temperature;
69+
}
70+
#endif
5571

56-
void recieveSensorConfig(float min_temp, float max_temp, float tolerance) {
57-
Serial.printf("Temperature sensor settings: min %.2f°C, max %.2f°C, tolerance %.2f°C\n", min_temp, max_temp, tolerance);
72+
void receiveSensorConfig(float min_temp, float max_temp, float tolerance) {
73+
Serial.printf("Temperature sensor config: min %.2f°C, max %.2f°C, tolerance %.2f°C\n", min_temp, max_temp, tolerance);
5874
sensor_min_temp = min_temp;
5975
sensor_max_temp = max_temp;
6076
sensor_tolerance = tolerance;
@@ -66,9 +82,15 @@ void setup() {
6682
// Init button switch
6783
pinMode(button, INPUT_PULLUP);
6884

69-
// Set callback functions for temperature and configuration receive
70-
zbThermostat.onTempRecieve(recieveSensorTemp);
71-
zbThermostat.onConfigRecieve(recieveSensorConfig);
85+
// Set callback function for receiving temperature from sensor - Use only one option
86+
#if USE_RECEIVE_TEMP_WITH_SOURCE == 0
87+
zbThermostat.onTempReceive(receiveSensorTemp); // If you bound only one sensor or you don't need to know the source of the temperature
88+
#else
89+
zbThermostat.onTempReceiveWithSource(receiveSensorTempWithSource);
90+
#endif
91+
92+
// Set callback function for receiving sensor configuration
93+
zbThermostat.onConfigReceive(receiveSensorConfig);
7294

7395
//Optional: set Zigbee device name and model
7496
zbThermostat.setManufacturerAndModel("Espressif", "ZigbeeThermostat");
@@ -107,19 +129,30 @@ void setup() {
107129

108130
Serial.println();
109131

110-
// Get temperature sensor configuration
111-
zbThermostat.getSensorSettings();
132+
// Get temperature sensor configuration for all bound sensors by endpoint number and address
133+
std::list<zb_device_params_t *> boundSensors = zbThermostat.getBoundDevices();
134+
for (const auto &device : boundSensors) {
135+
Serial.println("--------------------------------");
136+
if (device->short_addr == 0x0000 || device->short_addr == 0xFFFF) { //End devices never have 0x0000 short address or 0xFFFF group address
137+
Serial.printf(
138+
"Device on endpoint %d, IEEE Address: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\r\n", device->endpoint, device->ieee_addr[7], device->ieee_addr[6],
139+
device->ieee_addr[5], device->ieee_addr[4], device->ieee_addr[3], device->ieee_addr[2], device->ieee_addr[1], device->ieee_addr[0]
140+
);
141+
zbThermostat.getSensorSettings(device->endpoint, device->ieee_addr);
142+
} else {
143+
Serial.printf("Device on endpoint %d, short address: 0x%x\r\n", device->endpoint, device->short_addr);
144+
zbThermostat.getSensorSettings(device->endpoint, device->short_addr);
145+
}
146+
}
112147
}
113148

114149
void loop() {
115150
// Handle button switch in loop()
116151
if (digitalRead(button) == LOW) { // Push button pressed
117-
118152
// Key debounce handling
119153
while (digitalRead(button) == LOW) {
120154
delay(50);
121155
}
122-
123156
// Set reporting interval for temperature sensor
124157
zbThermostat.setTemperatureReporting(0, 10, 2);
125158
}
@@ -130,5 +163,6 @@ void loop() {
130163
last_print = millis();
131164
int temp_percent = (int)((sensor_temp - sensor_min_temp) / (sensor_max_temp - sensor_min_temp) * 100);
132165
Serial.printf("Loop temperature info: %.2f°C (%d %%)\n", sensor_temp, temp_percent);
166+
zbThermostat.printBoundDevices(Serial);
133167
}
134168
}

‎libraries/Zigbee/keywords.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ setLightColor KEYWORD2
107107
# ZigbeeThermostat
108108
onTempRecieve KEYWORD2
109109
onConfigRecieve KEYWORD2
110+
onTempReceiveWithSource KEYWORD2
110111
getTemperature KEYWORD2
111112
getSensorSettings KEYWORD2
112113
setTemperatureReporting KEYWORD2
@@ -142,14 +143,21 @@ setSensorType KEYWORD2
142143
setCarbonDioxide KEYWORD2
143144

144145
# ZigbeeAnalog
145-
addAnalogValue KEYWORD2
146146
addAnalogInput KEYWORD2
147147
addAnalogOutput KEYWORD2
148148
onAnalogOutputChange KEYWORD2
149-
setAnalogValue KEYWORD2
150149
setAnalogInput KEYWORD2
150+
setAnalogOutput KEYWORD2
151+
getAnalogOutput KEYWORD2
151152
reportAnalogInput KEYWORD2
153+
reportAnalogOutput KEYWORD2
152154
setAnalogInputReporting KEYWORD2
155+
setAnalogInputApplication KEYWORD2
156+
setAnalogInputDescription KEYWORD2
157+
setAnalogInputResolution KEYWORD2
158+
setAnalogOutputApplication KEYWORD2
159+
setAnalogOutputDescription KEYWORD2
160+
setAnalogOutputResolution KEYWORD2
153161

154162
# ZigbeeCarbonDioxideSensor
155163
setCarbonDioxide KEYWORD2
@@ -191,4 +199,4 @@ ZIGBEE_DEFAULT_COORDINATOR_CONFIG LITERAL1
191199
ZIGBEE_DEFAULT_RADIO_CONFIG LITERAL1
192200
ZIGBEE_DEFAULT_UART_RCP_RADIO_CONFIG LITERAL1
193201
ZIGBEE_DEFAULT_HOST_CONFIG LITERAL1
194-
ZB_ARRAY_LENTH LITERAL1
202+
ZB_ARRAY_LENGHT LITERAL1

‎libraries/Zigbee/src/ZigbeeEP.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool ZigbeeEP::setBatteryVoltage(uint8_t voltage) {
145145

146146
bool ZigbeeEP::reportBatteryPercentage() {
147147
/* Send report attributes command */
148-
esp_zb_zcl_report_attr_cmd_t report_attr_cmd;
148+
esp_zb_zcl_report_attr_cmd_t report_attr_cmd = {0};
149149
report_attr_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
150150
report_attr_cmd.attributeID = ESP_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_REMAINING_ID;
151151
report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI;
@@ -166,7 +166,7 @@ bool ZigbeeEP::reportBatteryPercentage() {
166166

167167
char *ZigbeeEP::readManufacturer(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_addr_t ieee_addr) {
168168
/* Read peer Manufacture Name & Model Identifier */
169-
esp_zb_zcl_read_attr_cmd_t read_req;
169+
esp_zb_zcl_read_attr_cmd_t read_req = {0};
170170

171171
if (short_addr != 0) {
172172
read_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
@@ -183,7 +183,7 @@ char *ZigbeeEP::readManufacturer(uint8_t endpoint, uint16_t short_addr, esp_zb_i
183183
uint16_t attributes[] = {
184184
ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID,
185185
};
186-
read_req.attr_number = ZB_ARRAY_LENTH(attributes);
186+
read_req.attr_number = ZB_ARRAY_LENGHT(attributes);
187187
read_req.attr_field = attributes;
188188

189189
if (_read_manufacturer != NULL) {
@@ -204,7 +204,7 @@ char *ZigbeeEP::readManufacturer(uint8_t endpoint, uint16_t short_addr, esp_zb_i
204204

205205
char *ZigbeeEP::readModel(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_addr_t ieee_addr) {
206206
/* Read peer Manufacture Name & Model Identifier */
207-
esp_zb_zcl_read_attr_cmd_t read_req;
207+
esp_zb_zcl_read_attr_cmd_t read_req = {0};
208208

209209
if (short_addr != 0) {
210210
read_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
@@ -221,7 +221,7 @@ char *ZigbeeEP::readModel(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_add
221221
uint16_t attributes[] = {
222222
ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID,
223223
};
224-
read_req.attr_number = ZB_ARRAY_LENTH(attributes);
224+
read_req.attr_number = ZB_ARRAY_LENGHT(attributes);
225225
read_req.attr_field = attributes;
226226

227227
if (_read_model != NULL) {
@@ -375,7 +375,7 @@ bool ZigbeeEP::setTimezone(int32_t gmt_offset) {
375375

376376
tm ZigbeeEP::getTime(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_addr_t ieee_addr) {
377377
/* Read peer time */
378-
esp_zb_zcl_read_attr_cmd_t read_req;
378+
esp_zb_zcl_read_attr_cmd_t read_req = {0};
379379

380380
if (short_addr >= 0) {
381381
read_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
@@ -386,7 +386,7 @@ tm ZigbeeEP::getTime(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_addr_t ie
386386
}
387387

388388
uint16_t attributes[] = {ESP_ZB_ZCL_ATTR_TIME_TIME_ID};
389-
read_req.attr_number = ZB_ARRAY_LENTH(attributes);
389+
read_req.attr_number = ZB_ARRAY_LENGHT(attributes);
390390
read_req.attr_field = attributes;
391391

392392
read_req.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TIME;
@@ -427,7 +427,7 @@ tm ZigbeeEP::getTime(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_addr_t ie
427427

428428
int32_t ZigbeeEP::getTimezone(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_addr_t ieee_addr) {
429429
/* Read peer timezone */
430-
esp_zb_zcl_read_attr_cmd_t read_req;
430+
esp_zb_zcl_read_attr_cmd_t read_req = {0};
431431

432432
if (short_addr >= 0) {
433433
read_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
@@ -438,7 +438,7 @@ int32_t ZigbeeEP::getTimezone(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_
438438
}
439439

440440
uint16_t attributes[] = {ESP_ZB_ZCL_ATTR_TIME_TIME_ZONE_ID};
441-
read_req.attr_number = ZB_ARRAY_LENTH(attributes);
441+
read_req.attr_number = ZB_ARRAY_LENGHT(attributes);
442442
read_req.attr_field = attributes;
443443

444444
read_req.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TIME;
@@ -543,7 +543,7 @@ static void findOTAServer(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t
543543
}
544544

545545
void ZigbeeEP::requestOTAUpdate() {
546-
esp_zb_zdo_match_desc_req_param_t req;
546+
esp_zb_zdo_match_desc_req_param_t req = {0};
547547
uint16_t cluster_list[] = {ESP_ZB_ZCL_CLUSTER_ID_OTA_UPGRADE};
548548

549549
/* Match the OTA server of coordinator */

‎libraries/Zigbee/src/ZigbeeEP.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define ZB_CMD_TIMEOUT 10000 // 10 seconds
1313
#define OTA_UPGRADE_QUERY_INTERVAL (1 * 60) // 1 hour = 60 minutes
1414

15-
#define ZB_ARRAY_LENTH(arr) (sizeof(arr) / sizeof(arr[0]))
15+
#define ZB_ARRAY_LENGHT(arr) (sizeof(arr) / sizeof(arr[0]))
1616

1717
#define RGB_TO_XYZ(r, g, b, X, Y, Z) \
1818
{ \
@@ -131,7 +131,7 @@ class ZigbeeEP {
131131

132132
// list of all handlers function calls, to be override by EPs implementation
133133
virtual void zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) {};
134-
virtual void zbAttributeRead(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute) {};
134+
virtual void zbAttributeRead(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute, uint8_t src_endpoint, esp_zb_zcl_addr_t src_address) {};
135135
virtual void zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute); //already implemented
136136
virtual void zbIdentify(const esp_zb_zcl_set_attr_value_message_t *message);
137137
virtual void zbWindowCoveringMovementCmd(const esp_zb_zcl_window_covering_movement_message_t *message) {};

‎libraries/Zigbee/src/ZigbeeHandlers.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_mes
108108
// List through all Zigbee EPs and call the callback function, with the message
109109
for (std::list<ZigbeeEP *>::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) {
110110
if (message->dst_endpoint == (*it)->getEndpoint()) {
111-
(*it)->zbAttributeRead(message->cluster, &message->attribute); //method zbAttributeRead must be implemented in specific EP class
111+
(*it)->zbAttributeRead(
112+
message->cluster, &message->attribute, message->src_endpoint, message->src_address
113+
); //method zbAttributeRead must be implemented in specific EP class
112114
}
113115
}
114116
return ESP_OK;
@@ -142,7 +144,9 @@ static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_re
142144
} else if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_TIME) {
143145
(*it)->zbReadTimeCluster(&variable->attribute); //method zbReadTimeCluster implemented in the common EP class
144146
} else {
145-
(*it)->zbAttributeRead(message->info.cluster, &variable->attribute); //method zbAttributeRead must be implemented in specific EP class
147+
(*it)->zbAttributeRead(
148+
message->info.cluster, &variable->attribute, message->info.src_endpoint, message->info.src_address
149+
); //method zbAttributeRead must be implemented in specific EP class
146150
}
147151
}
148152
variable = variable->next;

‎libraries/Zigbee/src/ep/ZigbeeAnalog.cpp

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ bool ZigbeeAnalog::setAnalogOutputApplication(uint32_t application_type) {
129129
void ZigbeeAnalog::zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) {
130130
if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_ANALOG_OUTPUT) {
131131
if (message->attribute.id == ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_PRESENT_VALUE_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_SINGLE) {
132-
float analog_output = *(float *)message->attribute.data.value;
133-
analogOutputChanged(analog_output);
132+
_output_state = *(float *)message->attribute.data.value;
133+
analogOutputChanged();
134134
} else {
135135
log_w("Received message ignored. Attribute ID: %d not supported for Analog Output", message->attribute.id);
136136
}
@@ -139,9 +139,9 @@ void ZigbeeAnalog::zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *mes
139139
}
140140
}
141141

142-
void ZigbeeAnalog::analogOutputChanged(float analog_output) {
142+
void ZigbeeAnalog::analogOutputChanged() {
143143
if (_on_analog_output_change) {
144-
_on_analog_output_change(analog_output);
144+
_on_analog_output_change(_output_state);
145145
} else {
146146
log_w("No callback function set for analog output change");
147147
}
@@ -166,6 +166,26 @@ bool ZigbeeAnalog::setAnalogInput(float analog) {
166166
return true;
167167
}
168168

169+
bool ZigbeeAnalog::setAnalogOutput(float analog) {
170+
esp_zb_zcl_status_t ret = ESP_ZB_ZCL_STATUS_SUCCESS;
171+
_output_state = analog;
172+
analogOutputChanged();
173+
174+
log_v("Updating analog output to %.2f", analog);
175+
/* Update analog output */
176+
esp_zb_lock_acquire(portMAX_DELAY);
177+
ret = esp_zb_zcl_set_attribute_val(
178+
_endpoint, ESP_ZB_ZCL_CLUSTER_ID_ANALOG_OUTPUT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_PRESENT_VALUE_ID, &_output_state, false
179+
);
180+
esp_zb_lock_release();
181+
182+
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
183+
log_e("Failed to set analog output: 0x%x: %s", ret, esp_zb_zcl_status_to_name(ret));
184+
return false;
185+
}
186+
return true;
187+
}
188+
169189
bool ZigbeeAnalog::reportAnalogInput() {
170190
/* Send report attributes command */
171191
esp_zb_zcl_report_attr_cmd_t report_attr_cmd;
@@ -187,6 +207,27 @@ bool ZigbeeAnalog::reportAnalogInput() {
187207
return true;
188208
}
189209

210+
bool ZigbeeAnalog::reportAnalogOutput() {
211+
/* Send report attributes command */
212+
esp_zb_zcl_report_attr_cmd_t report_attr_cmd;
213+
report_attr_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
214+
report_attr_cmd.attributeID = ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_PRESENT_VALUE_ID;
215+
report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI;
216+
report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_ANALOG_OUTPUT;
217+
report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint;
218+
report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC;
219+
220+
esp_zb_lock_acquire(portMAX_DELAY);
221+
esp_err_t ret = esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd);
222+
esp_zb_lock_release();
223+
if (ret != ESP_OK) {
224+
log_e("Failed to send Analog Output report: 0x%x: %s", ret, esp_err_to_name(ret));
225+
return false;
226+
}
227+
log_v("Analog Output report sent");
228+
return true;
229+
}
230+
190231
bool ZigbeeAnalog::setAnalogInputReporting(uint16_t min_interval, uint16_t max_interval, float delta) {
191232
esp_zb_zcl_reporting_info_t reporting_info;
192233
memset(&reporting_info, 0, sizeof(esp_zb_zcl_reporting_info_t));

‎libraries/Zigbee/src/ep/ZigbeeAnalog.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ class ZigbeeAnalog : public ZigbeeEP {
4646
_on_analog_output_change = callback;
4747
}
4848

49-
// Set the analog input value
49+
// Set the Analog Input/Output value
5050
bool setAnalogInput(float analog);
51+
bool setAnalogOutput(float analog);
5152

52-
// Report Analog Input value
53+
// Get the Analog Output value
54+
float getAnalogOutput() {
55+
return _output_state;
56+
}
57+
58+
// Report Analog Input/Output
5359
bool reportAnalogInput();
60+
bool reportAnalogOutput();
5461

5562
// Set reporting for Analog Input
5663
bool setAnalogInputReporting(uint16_t min_interval, uint16_t max_interval, float delta);
@@ -59,9 +66,10 @@ class ZigbeeAnalog : public ZigbeeEP {
5966
void zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) override;
6067

6168
void (*_on_analog_output_change)(float);
62-
void analogOutputChanged(float analog_output);
69+
void analogOutputChanged();
6370

6471
uint8_t _analog_clusters;
72+
float _output_state;
6573
};
6674

6775
#endif // CONFIG_ZB_ENABLED

‎libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void ZigbeeColorDimmerSwitch::findCb(esp_zb_zdp_status_t zdo_status, uint16_t ad
5353
ZigbeeColorDimmerSwitch *instance = static_cast<ZigbeeColorDimmerSwitch *>(user_ctx);
5454
if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
5555
log_d("Found light endpoint");
56-
esp_zb_zdo_bind_req_param_t bind_req;
56+
esp_zb_zdo_bind_req_param_t bind_req = {0};
5757
zb_device_params_t *light = (zb_device_params_t *)malloc(sizeof(zb_device_params_t));
5858
light->endpoint = endpoint;
5959
light->short_addr = addr;
@@ -97,7 +97,7 @@ void ZigbeeColorDimmerSwitch::findEndpoint(esp_zb_zdo_match_desc_req_param_t *cm
9797
// Methods to control the light
9898
void ZigbeeColorDimmerSwitch::lightToggle() {
9999
if (_is_bound) {
100-
esp_zb_zcl_on_off_cmd_t cmd_req;
100+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
101101
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
102102
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
103103
cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_TOGGLE_ID;
@@ -112,7 +112,7 @@ void ZigbeeColorDimmerSwitch::lightToggle() {
112112

113113
void ZigbeeColorDimmerSwitch::lightToggle(uint16_t group_addr) {
114114
if (_is_bound) {
115-
esp_zb_zcl_on_off_cmd_t cmd_req;
115+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
116116
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
117117
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
118118
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -128,7 +128,7 @@ void ZigbeeColorDimmerSwitch::lightToggle(uint16_t group_addr) {
128128

129129
void ZigbeeColorDimmerSwitch::lightToggle(uint8_t endpoint, uint16_t short_addr) {
130130
if (_is_bound) {
131-
esp_zb_zcl_on_off_cmd_t cmd_req;
131+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
132132
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
133133
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
134134
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -145,7 +145,7 @@ void ZigbeeColorDimmerSwitch::lightToggle(uint8_t endpoint, uint16_t short_addr)
145145

146146
void ZigbeeColorDimmerSwitch::lightToggle(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
147147
if (_is_bound) {
148-
esp_zb_zcl_on_off_cmd_t cmd_req;
148+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
149149
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
150150
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
151151
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -165,7 +165,7 @@ void ZigbeeColorDimmerSwitch::lightToggle(uint8_t endpoint, esp_zb_ieee_addr_t i
165165

166166
void ZigbeeColorDimmerSwitch::lightOn() {
167167
if (_is_bound) {
168-
esp_zb_zcl_on_off_cmd_t cmd_req;
168+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
169169
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
170170
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
171171
cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_ON_ID;
@@ -180,7 +180,7 @@ void ZigbeeColorDimmerSwitch::lightOn() {
180180

181181
void ZigbeeColorDimmerSwitch::lightOn(uint16_t group_addr) {
182182
if (_is_bound) {
183-
esp_zb_zcl_on_off_cmd_t cmd_req;
183+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
184184
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
185185
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
186186
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -196,7 +196,7 @@ void ZigbeeColorDimmerSwitch::lightOn(uint16_t group_addr) {
196196

197197
void ZigbeeColorDimmerSwitch::lightOn(uint8_t endpoint, uint16_t short_addr) {
198198
if (_is_bound) {
199-
esp_zb_zcl_on_off_cmd_t cmd_req;
199+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
200200
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
201201
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
202202
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -213,7 +213,7 @@ void ZigbeeColorDimmerSwitch::lightOn(uint8_t endpoint, uint16_t short_addr) {
213213

214214
void ZigbeeColorDimmerSwitch::lightOn(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
215215
if (_is_bound) {
216-
esp_zb_zcl_on_off_cmd_t cmd_req;
216+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
217217
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
218218
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
219219
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -233,7 +233,7 @@ void ZigbeeColorDimmerSwitch::lightOn(uint8_t endpoint, esp_zb_ieee_addr_t ieee_
233233

234234
void ZigbeeColorDimmerSwitch::lightOff() {
235235
if (_is_bound) {
236-
esp_zb_zcl_on_off_cmd_t cmd_req;
236+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
237237
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
238238
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
239239
cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_OFF_ID;
@@ -248,7 +248,7 @@ void ZigbeeColorDimmerSwitch::lightOff() {
248248

249249
void ZigbeeColorDimmerSwitch::lightOff(uint16_t group_addr) {
250250
if (_is_bound) {
251-
esp_zb_zcl_on_off_cmd_t cmd_req;
251+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
252252
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
253253
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
254254
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -264,7 +264,7 @@ void ZigbeeColorDimmerSwitch::lightOff(uint16_t group_addr) {
264264

265265
void ZigbeeColorDimmerSwitch::lightOff(uint8_t endpoint, uint16_t short_addr) {
266266
if (_is_bound) {
267-
esp_zb_zcl_on_off_cmd_t cmd_req;
267+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
268268
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
269269
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
270270
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -281,7 +281,7 @@ void ZigbeeColorDimmerSwitch::lightOff(uint8_t endpoint, uint16_t short_addr) {
281281

282282
void ZigbeeColorDimmerSwitch::lightOff(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
283283
if (_is_bound) {
284-
esp_zb_zcl_on_off_cmd_t cmd_req;
284+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
285285
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
286286
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
287287
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -301,7 +301,7 @@ void ZigbeeColorDimmerSwitch::lightOff(uint8_t endpoint, esp_zb_ieee_addr_t ieee
301301

302302
void ZigbeeColorDimmerSwitch::lightOffWithEffect(uint8_t effect_id, uint8_t effect_variant) {
303303
if (_is_bound) {
304-
esp_zb_zcl_on_off_off_with_effect_cmd_t cmd_req;
304+
esp_zb_zcl_on_off_off_with_effect_cmd_t cmd_req = {0};
305305
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
306306
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
307307
cmd_req.effect_id = effect_id;
@@ -317,7 +317,7 @@ void ZigbeeColorDimmerSwitch::lightOffWithEffect(uint8_t effect_id, uint8_t effe
317317

318318
void ZigbeeColorDimmerSwitch::lightOnWithSceneRecall() {
319319
if (_is_bound) {
320-
esp_zb_zcl_on_off_on_with_recall_global_scene_cmd_t cmd_req;
320+
esp_zb_zcl_on_off_on_with_recall_global_scene_cmd_t cmd_req = {0};
321321
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
322322
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
323323
log_v("Sending 'light on with scene recall' command");
@@ -331,7 +331,7 @@ void ZigbeeColorDimmerSwitch::lightOnWithSceneRecall() {
331331

332332
void ZigbeeColorDimmerSwitch::lightOnWithTimedOff(uint8_t on_off_control, uint16_t time_on, uint16_t time_off) {
333333
if (_is_bound) {
334-
esp_zb_zcl_on_off_on_with_timed_off_cmd_t cmd_req;
334+
esp_zb_zcl_on_off_on_with_timed_off_cmd_t cmd_req = {0};
335335
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
336336
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
337337
cmd_req.on_off_control = on_off_control; //TODO: Test how it works, then maybe change API
@@ -348,7 +348,7 @@ void ZigbeeColorDimmerSwitch::lightOnWithTimedOff(uint8_t on_off_control, uint16
348348

349349
void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level) {
350350
if (_is_bound) {
351-
esp_zb_zcl_move_to_level_cmd_t cmd_req;
351+
esp_zb_zcl_move_to_level_cmd_t cmd_req = {0};
352352
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
353353
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
354354
cmd_req.level = level;
@@ -364,7 +364,7 @@ void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level) {
364364

365365
void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level, uint16_t group_addr) {
366366
if (_is_bound) {
367-
esp_zb_zcl_move_to_level_cmd_t cmd_req;
367+
esp_zb_zcl_move_to_level_cmd_t cmd_req = {0};
368368
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
369369
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
370370
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -381,7 +381,7 @@ void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level, uint16_t group_addr)
381381

382382
void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level, uint8_t endpoint, uint16_t short_addr) {
383383
if (_is_bound) {
384-
esp_zb_zcl_move_to_level_cmd_t cmd_req;
384+
esp_zb_zcl_move_to_level_cmd_t cmd_req = {0};
385385
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
386386
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
387387
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -399,7 +399,7 @@ void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level, uint8_t endpoint, uin
399399

400400
void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level, uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
401401
if (_is_bound) {
402-
esp_zb_zcl_move_to_level_cmd_t cmd_req;
402+
esp_zb_zcl_move_to_level_cmd_t cmd_req = {0};
403403
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
404404
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
405405
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -422,7 +422,7 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t
422422
if (_is_bound) {
423423
espXyColor_t xy_color = espRgbToXYColor(red, green, blue);
424424

425-
esp_zb_zcl_color_move_to_color_cmd_t cmd_req;
425+
esp_zb_zcl_color_move_to_color_cmd_t cmd_req = {0};
426426
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
427427
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
428428
cmd_req.color_x = xy_color.x;
@@ -441,7 +441,7 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t
441441
if (_is_bound) {
442442
espXyColor_t xy_color = espRgbToXYColor(red, green, blue);
443443

444-
esp_zb_zcl_color_move_to_color_cmd_t cmd_req;
444+
esp_zb_zcl_color_move_to_color_cmd_t cmd_req = {0};
445445
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
446446
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
447447
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -461,7 +461,7 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t
461461
if (_is_bound) {
462462
espXyColor_t xy_color = espRgbToXYColor(red, green, blue);
463463

464-
esp_zb_zcl_color_move_to_color_cmd_t cmd_req;
464+
esp_zb_zcl_color_move_to_color_cmd_t cmd_req = {0};
465465
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
466466
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
467467
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -482,7 +482,7 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t
482482
if (_is_bound) {
483483
espXyColor_t xy_color = espRgbToXYColor(red, green, blue);
484484

485-
esp_zb_zcl_color_move_to_color_cmd_t cmd_req;
485+
esp_zb_zcl_color_move_to_color_cmd_t cmd_req = {0};
486486
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
487487
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
488488
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;

‎libraries/Zigbee/src/ep/ZigbeeSwitch.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void ZigbeeSwitch::findCb(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t
5252
ZigbeeSwitch *instance = static_cast<ZigbeeSwitch *>(user_ctx);
5353
if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
5454
log_d("Found light endpoint");
55-
esp_zb_zdo_bind_req_param_t bind_req;
55+
esp_zb_zdo_bind_req_param_t bind_req = {0};
5656
zb_device_params_t *light = (zb_device_params_t *)malloc(sizeof(zb_device_params_t));
5757
light->endpoint = endpoint;
5858
light->short_addr = addr;
@@ -94,7 +94,7 @@ void ZigbeeSwitch::findEndpoint(esp_zb_zdo_match_desc_req_param_t *cmd_req) {
9494
// Methods to control the light
9595
void ZigbeeSwitch::lightToggle() {
9696
if (_is_bound) {
97-
esp_zb_zcl_on_off_cmd_t cmd_req;
97+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
9898
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
9999
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
100100
cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_TOGGLE_ID;
@@ -109,7 +109,7 @@ void ZigbeeSwitch::lightToggle() {
109109

110110
void ZigbeeSwitch::lightToggle(uint16_t group_addr) {
111111
if (_is_bound) {
112-
esp_zb_zcl_on_off_cmd_t cmd_req;
112+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
113113
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
114114
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
115115
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -125,7 +125,7 @@ void ZigbeeSwitch::lightToggle(uint16_t group_addr) {
125125

126126
void ZigbeeSwitch::lightToggle(uint8_t endpoint, uint16_t short_addr) {
127127
if (_is_bound) {
128-
esp_zb_zcl_on_off_cmd_t cmd_req;
128+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
129129
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
130130
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
131131
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -142,7 +142,7 @@ void ZigbeeSwitch::lightToggle(uint8_t endpoint, uint16_t short_addr) {
142142

143143
void ZigbeeSwitch::lightToggle(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
144144
if (_is_bound) {
145-
esp_zb_zcl_on_off_cmd_t cmd_req;
145+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
146146
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
147147
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
148148
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -162,7 +162,7 @@ void ZigbeeSwitch::lightToggle(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
162162

163163
void ZigbeeSwitch::lightOn() {
164164
if (_is_bound) {
165-
esp_zb_zcl_on_off_cmd_t cmd_req;
165+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
166166
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
167167
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
168168
cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_ON_ID;
@@ -177,7 +177,7 @@ void ZigbeeSwitch::lightOn() {
177177

178178
void ZigbeeSwitch::lightOn(uint16_t group_addr) {
179179
if (_is_bound) {
180-
esp_zb_zcl_on_off_cmd_t cmd_req;
180+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
181181
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
182182
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
183183
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -193,7 +193,7 @@ void ZigbeeSwitch::lightOn(uint16_t group_addr) {
193193

194194
void ZigbeeSwitch::lightOn(uint8_t endpoint, uint16_t short_addr) {
195195
if (_is_bound) {
196-
esp_zb_zcl_on_off_cmd_t cmd_req;
196+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
197197
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
198198
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
199199
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -210,7 +210,7 @@ void ZigbeeSwitch::lightOn(uint8_t endpoint, uint16_t short_addr) {
210210

211211
void ZigbeeSwitch::lightOn(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
212212
if (_is_bound) {
213-
esp_zb_zcl_on_off_cmd_t cmd_req;
213+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
214214
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
215215
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
216216
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -230,7 +230,7 @@ void ZigbeeSwitch::lightOn(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
230230

231231
void ZigbeeSwitch::lightOff() {
232232
if (_is_bound) {
233-
esp_zb_zcl_on_off_cmd_t cmd_req;
233+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
234234
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
235235
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
236236
cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_OFF_ID;
@@ -245,7 +245,7 @@ void ZigbeeSwitch::lightOff() {
245245

246246
void ZigbeeSwitch::lightOff(uint16_t group_addr) {
247247
if (_is_bound) {
248-
esp_zb_zcl_on_off_cmd_t cmd_req;
248+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
249249
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
250250
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr;
251251
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT;
@@ -261,7 +261,7 @@ void ZigbeeSwitch::lightOff(uint16_t group_addr) {
261261

262262
void ZigbeeSwitch::lightOff(uint8_t endpoint, uint16_t short_addr) {
263263
if (_is_bound) {
264-
esp_zb_zcl_on_off_cmd_t cmd_req;
264+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
265265
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
266266
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
267267
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr;
@@ -278,7 +278,7 @@ void ZigbeeSwitch::lightOff(uint8_t endpoint, uint16_t short_addr) {
278278

279279
void ZigbeeSwitch::lightOff(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
280280
if (_is_bound) {
281-
esp_zb_zcl_on_off_cmd_t cmd_req;
281+
esp_zb_zcl_on_off_cmd_t cmd_req = {0};
282282
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
283283
cmd_req.zcl_basic_cmd.dst_endpoint = endpoint;
284284
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
@@ -298,7 +298,7 @@ void ZigbeeSwitch::lightOff(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) {
298298

299299
void ZigbeeSwitch::lightOffWithEffect(uint8_t effect_id, uint8_t effect_variant) {
300300
if (_is_bound) {
301-
esp_zb_zcl_on_off_off_with_effect_cmd_t cmd_req;
301+
esp_zb_zcl_on_off_off_with_effect_cmd_t cmd_req = {0};
302302
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
303303
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
304304
cmd_req.effect_id = effect_id;
@@ -314,7 +314,7 @@ void ZigbeeSwitch::lightOffWithEffect(uint8_t effect_id, uint8_t effect_variant)
314314

315315
void ZigbeeSwitch::lightOnWithSceneRecall() {
316316
if (_is_bound) {
317-
esp_zb_zcl_on_off_on_with_recall_global_scene_cmd_t cmd_req;
317+
esp_zb_zcl_on_off_on_with_recall_global_scene_cmd_t cmd_req = {0};
318318
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
319319
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
320320
log_v("Sending 'light on with scene recall' command");
@@ -327,7 +327,7 @@ void ZigbeeSwitch::lightOnWithSceneRecall() {
327327
}
328328
void ZigbeeSwitch::lightOnWithTimedOff(uint8_t on_off_control, uint16_t time_on, uint16_t time_off) {
329329
if (_is_bound) {
330-
esp_zb_zcl_on_off_on_with_timed_off_cmd_t cmd_req;
330+
esp_zb_zcl_on_off_on_with_timed_off_cmd_t cmd_req = {0};
331331
cmd_req.zcl_basic_cmd.src_endpoint = _endpoint;
332332
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
333333
cmd_req.on_off_control = on_off_control; //TODO: Test how it works, then maybe change API

‎libraries/Zigbee/src/ep/ZigbeeThermostat.cpp

Lines changed: 263 additions & 16 deletions
Large diffs are not rendered by default.

‎libraries/Zigbee/src/ep/ZigbeeThermostat.h

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,39 @@ class ZigbeeThermostat : public ZigbeeEP {
3434
ZigbeeThermostat(uint8_t endpoint);
3535
~ZigbeeThermostat() {}
3636

37-
void onTempRecieve(void (*callback)(float)) {
38-
_on_temp_recieve = callback;
37+
void onTempReceive(void (*callback)(float)) {
38+
_on_temp_receive = callback;
3939
}
40-
void onConfigRecieve(void (*callback)(float, float, float)) {
41-
_on_config_recieve = callback;
40+
void onTempReceiveWithSource(void (*callback)(float, uint8_t, esp_zb_zcl_addr_t)) {
41+
_on_temp_receive_with_source = callback;
42+
}
43+
void onConfigReceive(void (*callback)(float, float, float)) {
44+
_on_config_receive = callback;
4245
}
4346

4447
void getTemperature();
48+
void getTemperature(uint16_t group_addr);
49+
void getTemperature(uint8_t endpoint, uint16_t short_addr);
50+
void getTemperature(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
51+
4552
void getSensorSettings();
53+
void getSensorSettings(uint16_t group_addr);
54+
void getSensorSettings(uint8_t endpoint, uint16_t short_addr);
55+
void getSensorSettings(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
56+
4657
void setTemperatureReporting(uint16_t min_interval, uint16_t max_interval, float delta);
58+
void setTemperatureReporting(uint16_t group_addr, uint16_t min_interval, uint16_t max_interval, float delta);
59+
void setTemperatureReporting(uint8_t endpoint, uint16_t short_addr, uint16_t min_interval, uint16_t max_interval, float delta);
60+
void setTemperatureReporting(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr, uint16_t min_interval, uint16_t max_interval, float delta);
4761

4862
private:
4963
// save instance of the class in order to use it in static functions
5064
static ZigbeeThermostat *_instance;
5165
zb_device_params_t *_device;
5266

53-
void (*_on_temp_recieve)(float);
54-
void (*_on_config_recieve)(float, float, float);
67+
void (*_on_temp_receive)(float);
68+
void (*_on_temp_receive_with_source)(float, uint8_t, esp_zb_zcl_addr_t);
69+
void (*_on_config_receive)(float, float, float);
5570
float _min_temp;
5671
float _max_temp;
5772
float _tolerance;
@@ -62,7 +77,7 @@ class ZigbeeThermostat : public ZigbeeEP {
6277
static void bindCbWrapper(esp_zb_zdp_status_t zdo_status, void *user_ctx);
6378
static void findCbWrapper(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t endpoint, void *user_ctx);
6479

65-
void zbAttributeRead(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute) override;
80+
void zbAttributeRead(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute, uint8_t src_endpoint, esp_zb_zcl_addr_t src_address) override;
6681
};
6782

6883
#endif // CONFIG_ZB_ENABLED

0 commit comments

Comments
 (0)
Please sign in to comment.