Skip to content

Commit 7b54404

Browse files
authored
Merge branch 'espressif:master' into master
2 parents c7dc856 + 5ba4c21 commit 7b54404

File tree

24 files changed

+1315
-10
lines changed

24 files changed

+1315
-10
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ set(ARDUINO_LIBRARY_Zigbee_SRCS
290290
libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp
291291
libraries/Zigbee/src/ep/ZigbeeOccupancySensor.cpp
292292
libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp
293+
libraries/Zigbee/src/ep/ZigbeeContactSwitch.cpp
294+
libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.cpp
295+
libraries/Zigbee/src/ep/ZigbeeWindowCovering.cpp
293296
)
294297

295298
set(ARDUINO_LIBRARY_BLE_SRCS

libraries/ArduinoOTA/src/ArduinoOTA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ArduinoOTAClass::ArduinoOTAClass()
2929
_start_callback(NULL), _end_callback(NULL), _error_callback(NULL), _progress_callback(NULL) {}
3030

3131
ArduinoOTAClass::~ArduinoOTAClass() {
32-
_udp_ota.stop();
32+
end();
3333
}
3434

3535
ArduinoOTAClass &ArduinoOTAClass::onStart(THandlerFunction fn) {

libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ static esp_err_t stream_handler(httpd_req_t *req) {
281281
int64_t fr_end = esp_timer_get_time();
282282

283283
int64_t frame_time = fr_end - last_frame;
284+
last_frame = fr_end;
285+
284286
frame_time /= 1000;
285287
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
286288
uint32_t avg_frame_time = ra_filter_run(&ra_filter, frame_time);

libraries/Network/src/NetworkEvents.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include "esp_task.h"
99
#include "esp32-hal.h"
1010

11+
#ifndef ARDUINO_NETWORK_EVENT_TASK_STACK_SIZE
12+
#define ARDUINO_NETWORK_EVENT_TASK_STACK_SIZE 4096
13+
#endif
14+
1115
NetworkEvents::NetworkEvents() : _arduino_event_group(NULL), _arduino_event_queue(NULL), _arduino_event_task_handle(NULL) {}
1216

1317
NetworkEvents::~NetworkEvents() {
@@ -61,8 +65,8 @@ bool NetworkEvents::initNetworkEvents() {
6165
[](void *self) {
6266
static_cast<NetworkEvents *>(self)->_checkForEvent();
6367
},
64-
"arduino_events", // label
65-
4096, // event task's stack size
68+
"arduino_events", // label
69+
ARDUINO_NETWORK_EVENT_TASK_STACK_SIZE, // event task's stack size
6670
this, ESP_TASKD_EVENT_PRIO - 1, &_arduino_event_task_handle, ARDUINO_EVENT_RUNNING_CORE
6771
);
6872
if (!_arduino_event_task_handle) {

libraries/Network/src/NetworkInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) {
8181
);
8282
#endif
8383
memcpy(&arduino_event.event_info.got_ip, event_data, sizeof(ip_event_got_ip_t));
84-
#if SOC_WIFI_SUPPORTED
84+
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
8585
if (_interface_id == ESP_NETIF_ID_STA) {
8686
arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_GOT_IP;
8787
} else
@@ -96,7 +96,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) {
9696
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
9797
log_v("%s Lost IP", desc());
9898
#endif
99-
#if SOC_WIFI_SUPPORTED
99+
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
100100
if (_interface_id == ESP_NETIF_ID_STA) {
101101
arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_LOST_IP;
102102
} else
@@ -123,7 +123,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) {
123123
);
124124
#endif
125125
memcpy(&arduino_event.event_info.got_ip6, event_data, sizeof(ip_event_got_ip6_t));
126-
#if SOC_WIFI_SUPPORTED
126+
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
127127
if (_interface_id == ESP_NETIF_ID_STA) {
128128
arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_GOT_IP6;
129129
} else if (_interface_id == ESP_NETIF_ID_AP) {
@@ -136,7 +136,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) {
136136
arduino_event.event_id = ARDUINO_EVENT_ETH_GOT_IP6;
137137
}
138138
#endif /* CONFIG_LWIP_IPV6 */
139-
#if SOC_WIFI_SUPPORTED
139+
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
140140
} else if (event_id == IP_EVENT_AP_STAIPASSIGNED && _interface_id == ESP_NETIF_ID_AP) {
141141
setStatusBits(ESP_NETIF_HAS_IP_BIT);
142142
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE

libraries/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
8888
### SPIFFS
8989
SPI Flash Filesystem (see [spiffs-plugin](https://github.com/me-no-dev/arduino-esp32fs-plugin) to upload to device)
9090

91+
### SR
92+
ESP-SR helps users build AI speech solutions based on ESP32-S3 or ESP32-P4 chips
93+
9194
### Ticker
9295
A timer to call functions on an interval
9396

libraries/RainMaker/examples/RMakerCustomAirCooler/ci.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"targets": {
3+
"esp32": false
4+
},
25
"fqbn_append": "PartitionScheme=rainmaker_4MB",
36
"requires": [
47
"CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK=[1-9][0-9]*"

libraries/RainMaker/examples/RMakerSonoffDualR3/ci.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"targets": {
3+
"esp32": false
4+
},
25
"fqbn_append": "PartitionScheme=rainmaker_4MB",
36
"requires": [
47
"CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK=[1-9][0-9]*"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Arduino-ESP32 Zigbee Contact Switch Example
2+
3+
This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) contact switch (IAS Zone),
4+
that can be used for example as window/door sensor having 2 states - closed/open.
5+
6+
# Supported Targets
7+
8+
Currently, this example supports the following targets.
9+
10+
| Supported Targets | ESP32-C6 | ESP32-H2 |
11+
| ----------------- | -------- | -------- |
12+
13+
## Hardware Required
14+
15+
* A USB cable for power supply and programming
16+
17+
### Configure the Project
18+
19+
Set the Button GPIO by changing the `button` variable. By default, it's the pin `BOOT_PIN` (BOOT button on ESP32-C6 and ESP32-H2).
20+
Set the Sensor GPIO by changing the `sensor_pin` variable.
21+
22+
#### Using Arduino IDE
23+
24+
To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).
25+
26+
* Before Compile/Verify, select the correct board: `Tools -> Board`.
27+
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
28+
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
29+
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
30+
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.
31+
32+
## Troubleshooting
33+
34+
If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board.
35+
36+
***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***
37+
38+
* **LED not blinking:** Check the wiring connection and the IO selection.
39+
* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed.
40+
* **COM port not detected:** Check the USB cable and the USB to Serial driver installation.
41+
42+
If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
43+
44+
## Contribute
45+
46+
To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)
47+
48+
If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!
49+
50+
Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.
51+
52+
## Resources
53+
54+
* Official ESP32 Forum: [Link](https://esp32.com)
55+
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
56+
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
57+
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
58+
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @brief This example demonstrates Zigbee contact switch (IAS Zone).
17+
*
18+
* The example demonstrates how to use Zigbee library to create a end device contact switch.
19+
* The contact switch is a Zigbee end device, which is reporting data to the Zigbee network.
20+
*
21+
* Proper Zigbee mode must be selected in Tools->Zigbee mode
22+
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
23+
*
24+
* Please check the README.md for instructions and more detailed description.
25+
*
26+
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
27+
*/
28+
29+
#ifndef ZIGBEE_MODE_ED
30+
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
31+
#endif
32+
33+
#include "Zigbee.h"
34+
35+
/* Zigbee contact sensor configuration */
36+
#define CONTACT_SWITCH_ENDPOINT_NUMBER 10
37+
uint8_t button = BOOT_PIN;
38+
uint8_t sensor_pin = 4;
39+
40+
ZigbeeContactSwitch zbContactSwitch = ZigbeeContactSwitch(CONTACT_SWITCH_ENDPOINT_NUMBER);
41+
42+
void setup() {
43+
Serial.begin(115200);
44+
45+
// Init button + switch
46+
pinMode(button, INPUT_PULLUP);
47+
pinMode(sensor_pin, INPUT_PULLUP);
48+
49+
// Optional: set Zigbee device name and model
50+
zbContactSwitch.setManufacturerAndModel("Espressif", "ZigbeeContactSwitch");
51+
52+
// Add endpoint to Zigbee Core
53+
Zigbee.addEndpoint(&zbContactSwitch);
54+
55+
Serial.println("Starting Zigbee...");
56+
// When all EPs are registered, start Zigbee in End Device mode
57+
if (!Zigbee.begin()) {
58+
Serial.println("Zigbee failed to start!");
59+
Serial.println("Rebooting...");
60+
ESP.restart();
61+
} else {
62+
Serial.println("Zigbee started successfully!");
63+
}
64+
Serial.println("Connecting to network");
65+
while (!Zigbee.connected()) {
66+
Serial.print(".");
67+
delay(100);
68+
}
69+
Serial.println();
70+
}
71+
72+
void loop() {
73+
// Checking pin for contact change
74+
static bool contact = false;
75+
if (digitalRead(sensor_pin) == HIGH && !contact) {
76+
// Update contact sensor value
77+
zbContactSwitch.setOpen();
78+
contact = true;
79+
} else if (digitalRead(sensor_pin) == LOW && contact) {
80+
zbContactSwitch.setClosed();
81+
contact = false;
82+
}
83+
84+
// Checking button for factory reset
85+
if (digitalRead(button) == LOW) { // Push button pressed
86+
// Key debounce handling
87+
delay(100);
88+
int startTime = millis();
89+
while (digitalRead(button) == LOW) {
90+
delay(50);
91+
if ((millis() - startTime) > 3000) {
92+
// If key pressed for more than 3secs, factory reset Zigbee and reboot
93+
Serial.println("Resetting Zigbee to factory and rebooting in 1s.");
94+
delay(1000);
95+
Zigbee.factoryReset();
96+
}
97+
}
98+
}
99+
delay(100);
100+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed",
3+
"requires": [
4+
"CONFIG_SOC_IEEE802154_SUPPORTED=y"
5+
]
6+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Arduino-ESP32 Window Covering Example
2+
3+
This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) window covering device.
4+
5+
To see if the communication with your Zigbee network works, use the Serial monitor and watch for output there.
6+
7+
# Supported Targets
8+
9+
Currently, this example supports the following targets.
10+
11+
| Supported Targets | ESP32-C6 | ESP32-H2 |
12+
| ----------------- | -------- | -------- |
13+
14+
## Hardware Required
15+
16+
* A USB cable for power supply and programming
17+
* Board (ESP32-H2 or ESP32-C6) as Zigbee end device and upload the Zigbee_Window_Covering example
18+
* Zigbee network / coordinator (Other board with switch examples or Zigbee2mqtt or ZigbeeHomeAssistant like application)
19+
20+
### Configure the Project
21+
22+
#### Using Arduino IDE
23+
24+
To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).
25+
26+
* Before Compile/Verify, select the correct board: `Tools -> Board`.
27+
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
28+
* Select Tools / USB CDC On Boot: "Enabled"
29+
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
30+
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
31+
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.
32+
33+
## Troubleshooting
34+
35+
If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
36+
You can do the following:
37+
38+
* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
39+
* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack.
40+
41+
By default, the coordinator network is closed after rebooting or flashing new firmware.
42+
To open the network you have 2 options:
43+
44+
* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
45+
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.
46+
47+
***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***
48+
49+
* **LED not blinking:** Check the wiring connection and the IO selection.
50+
* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed.
51+
* **COM port not detected:** Check the USB cable and the USB to Serial driver installation.
52+
53+
If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
54+
55+
## Contribute
56+
57+
To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)
58+
59+
If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!
60+
61+
Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.
62+
63+
## Resources
64+
65+
* Official ESP32 Forum: [Link](https://esp32.com)
66+
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
67+
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
68+
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
69+
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)

0 commit comments

Comments
 (0)