Skip to content

Commit f2026f1

Browse files
3.0.0 Network Refactoring (#8760)
* Create ESP_NetworkInterface class and have Ethernet extending it * Update CMakeLists.txt * Split networking from WiFi (H2 can now use Ethernet) Now all libs have been checked yet. More to do on WiFi side * Fix build errors * Guard WiFi classes and fix RMII ETH examples * Decouple network related libraries from WiFi * Fix examples and WiFiUpdate * Guard WiFiProv lib to compile only on WiFi chips * Add periman string for network and "fix" mdns on the first ETH * Revert back location of Client/Server/Udp in order to accept some PRs * Fix periman * Some fixes from merging master * Fix web server missing fs.h * Move Client, Server and Udp out of WiFi * More fixes * more fixes * Fix CMakekLists and rework lib menu dependencies * Fix CMake issues * move back WiFiClient to rebase with master * Update ETH_TLK110.ino * Move back WiFiClient * Update progress * Update WiFiGeneric.cpp * More fixes * Switch AP to the new interface * Cleanup * Rename AP methods * Add extra interface info for Printable * Rename IPv6 getters to clarify that they are returning LinkLocal address cc @sgryphon * Rename network classes cc @sgryphon * Update NetworkManager.h * Rename WiFi Server and UDP * Rename WiFiClient and WiFiClientSecure * Update CMakeLists.txt * Update on-push.sh * Rename Network library * Remove unnecessary guard * Get the correct interface MAC address for mDND Workstation service * Apply suggestions from code review Co-authored-by: Lucas Saavedra Vaz <[email protected]> --------- Co-authored-by: Lucas Saavedra Vaz <[email protected]>
1 parent e92b4ca commit f2026f1

File tree

119 files changed

+4103
-3153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+4103
-3153
lines changed

.github/scripts/on-push.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then
7272
FQBN_ESP32H2="espressif:esp32:esp32h2:PartitionScheme=huge_app"
7373

7474
SKETCHES_ESP32="\
75-
$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino\
75+
$ARDUINO_ESP32_PATH/libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino\
7676
$ARDUINO_ESP32_PATH/libraries/BLE/examples/Server/Server.ino\
7777
$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino\
7878
$ARDUINO_ESP32_PATH/libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino\
@@ -90,7 +90,7 @@ else
9090
BOARD="esp32dev"
9191
OPTIONS="board_build.partitions = huge_app.csv"
9292
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino" && \
93-
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
93+
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
9494
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino" && \
9595
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/BLE/examples/Server/Server.ino" && \
9696
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"

CMakeLists.txt

+15-7
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ set(ARDUINO_ALL_LIBRARIES
9393
Insights
9494
LittleFS
9595
NetBIOS
96+
Network
9697
Preferences
9798
RainMaker
9899
SD_MMC
@@ -104,7 +105,7 @@ set(ARDUINO_ALL_LIBRARIES
104105
Update
105106
USB
106107
WebServer
107-
WiFiClientSecure
108+
NetworkClientSecure
108109
WiFi
109110
WiFiProv
110111
Wire
@@ -198,20 +199,27 @@ set(ARDUINO_LIBRARY_WebServer_SRCS
198199
libraries/WebServer/src/Parsing.cpp
199200
libraries/WebServer/src/detail/mimetable.cpp)
200201

201-
set(ARDUINO_LIBRARY_WiFiClientSecure_SRCS
202-
libraries/WiFiClientSecure/src/ssl_client.cpp
203-
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp)
202+
set(ARDUINO_LIBRARY_NetworkClientSecure_SRCS
203+
libraries/NetworkClientSecure/src/ssl_client.cpp
204+
libraries/NetworkClientSecure/src/NetworkClientSecure.cpp)
205+
206+
set(ARDUINO_LIBRARY_Network_SRCS
207+
libraries/Network/src/NetworkInterface.cpp
208+
libraries/Network/src/NetworkEvents.cpp
209+
libraries/Network/src/NetworkManager.cpp
210+
libraries/Network/src/NetworkClient.cpp
211+
libraries/Network/src/NetworkServer.cpp
212+
libraries/Network/src/NetworkUdp.cpp)
204213

205214
set(ARDUINO_LIBRARY_WiFi_SRCS
206215
libraries/WiFi/src/WiFiAP.cpp
207-
libraries/WiFi/src/WiFiClient.cpp
208216
libraries/WiFi/src/WiFi.cpp
209217
libraries/WiFi/src/WiFiGeneric.cpp
210218
libraries/WiFi/src/WiFiMulti.cpp
211219
libraries/WiFi/src/WiFiScan.cpp
212-
libraries/WiFi/src/WiFiServer.cpp
213220
libraries/WiFi/src/WiFiSTA.cpp
214-
libraries/WiFi/src/WiFiUdp.cpp)
221+
libraries/WiFi/src/STA.cpp
222+
libraries/WiFi/src/AP.cpp)
215223

216224
set(ARDUINO_LIBRARY_WiFiProv_SRCS libraries/WiFiProv/src/WiFiProv.cpp)
217225

Kconfig.projbuild

+63-82
Original file line numberDiff line numberDiff line change
@@ -256,157 +256,138 @@ config ARDUINO_SELECTIVE_COMPILATION
256256
bool "Include only specific Arduino libraries"
257257
default n
258258

259-
config ARDUINO_SELECTIVE_ArduinoOTA
260-
bool "Enable ArduinoOTA"
261-
depends on ARDUINO_SELECTIVE_COMPILATION
262-
select ARDUINO_SELECTIVE_WiFi
263-
select ARDUINO_SELECTIVE_ESPmDNS
264-
default y
265-
266-
config ARDUINO_SELECTIVE_AsyncUDP
267-
bool "Enable AsyncUDP"
268-
depends on ARDUINO_SELECTIVE_COMPILATION
269-
default y
270-
271-
config ARDUINO_SELECTIVE_AzureIoT
272-
bool "Enable AzureIoT"
273-
depends on ARDUINO_SELECTIVE_COMPILATION
274-
select ARDUINO_SELECTIVE_HTTPClient
275-
default y
276-
277-
config ARDUINO_SELECTIVE_BLE
278-
bool "Enable BLE"
279-
depends on ARDUINO_SELECTIVE_COMPILATION
280-
default y
281-
282-
config ARDUINO_SELECTIVE_BluetoothSerial
283-
bool "Enable BluetoothSerial"
259+
config ARDUINO_SELECTIVE_SPI
260+
bool "Enable SPI"
284261
depends on ARDUINO_SELECTIVE_COMPILATION
285262
default y
286263

287-
config ARDUINO_SELECTIVE_DNSServer
288-
bool "Enable DNSServer"
264+
config ARDUINO_SELECTIVE_Wire
265+
bool "Enable Wire"
289266
depends on ARDUINO_SELECTIVE_COMPILATION
290-
select ARDUINO_SELECTIVE_WiFi
291267
default y
292268

293269
config ARDUINO_SELECTIVE_EEPROM
294270
bool "Enable EEPROM"
295271
depends on ARDUINO_SELECTIVE_COMPILATION
296272
default y
297273

298-
config ARDUINO_SELECTIVE_ESP32
299-
bool "Enable ESP32"
274+
config ARDUINO_SELECTIVE_Preferences
275+
bool "Enable Preferences"
300276
depends on ARDUINO_SELECTIVE_COMPILATION
301277
default y
302278

303-
config ARDUINO_SELECTIVE_ESPmDNS
304-
bool "Enable ESPmDNS"
279+
config ARDUINO_SELECTIVE_Ticker
280+
bool "Enable Ticker"
305281
depends on ARDUINO_SELECTIVE_COMPILATION
306-
select ARDUINO_SELECTIVE_WiFi
307282
default y
308283

309-
config ARDUINO_SELECTIVE_FFat
310-
bool "Enable FFat"
284+
config ARDUINO_SELECTIVE_Update
285+
bool "Enable Update"
311286
depends on ARDUINO_SELECTIVE_COMPILATION
312-
select ARDUINO_SELECTIVE_FS
313287
default y
314288

315289
config ARDUINO_SELECTIVE_FS
316290
bool "Enable FS"
317291
depends on ARDUINO_SELECTIVE_COMPILATION
318292
default y
319293

320-
config ARDUINO_SELECTIVE_HTTPClient
321-
bool "Enable HTTPClient"
322-
depends on ARDUINO_SELECTIVE_COMPILATION
323-
select ARDUINO_SELECTIVE_WiFi
324-
select ARDUINO_SELECTIVE_WiFiClientSecure
294+
config ARDUINO_SELECTIVE_SD
295+
bool "Enable SD"
296+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS
325297
default y
326298

327-
config ARDUINO_SELECTIVE_LITTLEFS
328-
bool "Enable LITTLEFS"
329-
depends on ARDUINO_SELECTIVE_COMPILATION
330-
select ARDUINO_SELECTIVE_FS
299+
config ARDUINO_SELECTIVE_SD_MMC
300+
bool "Enable SD_MMC"
301+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS
331302
default y
332303

333-
config ARDUINO_SELECTIVE_NetBIOS
334-
bool "Enable NetBIOS"
335-
depends on ARDUINO_SELECTIVE_COMPILATION
336-
select ARDUINO_SELECTIVE_WiFi
304+
config ARDUINO_SELECTIVE_SPIFFS
305+
bool "Enable SPIFFS"
306+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS
337307
default y
338308

339-
config ARDUINO_SELECTIVE_Preferences
340-
bool "Enable Preferences"
341-
depends on ARDUINO_SELECTIVE_COMPILATION
309+
config ARDUINO_SELECTIVE_FFat
310+
bool "Enable FFat"
311+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS
342312
default y
343313

344-
config ARDUINO_SELECTIVE_SD
345-
bool "Enable SD"
346-
depends on ARDUINO_SELECTIVE_COMPILATION
347-
select ARDUINO_SELECTIVE_FS
314+
config ARDUINO_SELECTIVE_LITTLEFS
315+
bool "Enable LITTLEFS"
316+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS
348317
default y
349318

350-
config ARDUINO_SELECTIVE_SD_MMC
351-
bool "Enable SD_MMC"
319+
config ARDUINO_SELECTIVE_Networking
320+
bool "Enable Networking"
352321
depends on ARDUINO_SELECTIVE_COMPILATION
353-
select ARDUINO_SELECTIVE_FS
354322
default y
355323

356-
config ARDUINO_SELECTIVE_SimpleBLE
357-
bool "Enable SimpleBLE"
358-
depends on ARDUINO_SELECTIVE_COMPILATION
324+
config ARDUINO_SELECTIVE_ArduinoOTA
325+
bool "Enable ArduinoOTA"
326+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
327+
select ARDUINO_SELECTIVE_ESPmDNS
359328
default y
360329

361-
config ARDUINO_SELECTIVE_SPI
362-
bool "Enable SPI"
363-
depends on ARDUINO_SELECTIVE_COMPILATION
330+
config ARDUINO_SELECTIVE_AsyncUDP
331+
bool "Enable AsyncUDP"
332+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
364333
default y
365334

366-
config ARDUINO_SELECTIVE_SPIFFS
367-
bool "Enable SPIFFS"
368-
depends on ARDUINO_SELECTIVE_COMPILATION
369-
select ARDUINO_SELECTIVE_FS
335+
config ARDUINO_SELECTIVE_DNSServer
336+
bool "Enable DNSServer"
337+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
370338
default y
371339

372-
config ARDUINO_SELECTIVE_Ticker
373-
bool "Enable Ticker"
374-
depends on ARDUINO_SELECTIVE_COMPILATION
340+
config ARDUINO_SELECTIVE_ESPmDNS
341+
bool "Enable ESPmDNS"
342+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
375343
default y
376344

377-
config ARDUINO_SELECTIVE_Update
378-
bool "Enable Update"
379-
depends on ARDUINO_SELECTIVE_COMPILATION
345+
config ARDUINO_SELECTIVE_HTTPClient
346+
bool "Enable HTTPClient"
347+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
348+
select ARDUINO_SELECTIVE_WiFiClientSecure
349+
default y
350+
351+
config ARDUINO_SELECTIVE_NetBIOS
352+
bool "Enable NetBIOS"
353+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
380354
default y
381355

382356
config ARDUINO_SELECTIVE_WebServer
383357
bool "Enable WebServer"
384-
depends on ARDUINO_SELECTIVE_COMPILATION
358+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
385359
default y
386360
select ARDUINO_SELECTIVE_FS
387361

388362
config ARDUINO_SELECTIVE_WiFi
389363
bool "Enable WiFi"
390-
depends on ARDUINO_SELECTIVE_COMPILATION
364+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
391365
default y
392366

393367
config ARDUINO_SELECTIVE_WiFiClientSecure
394368
bool "Enable WiFiClientSecure"
395-
depends on ARDUINO_SELECTIVE_COMPILATION
396-
select ARDUINO_SELECTIVE_WiFi
369+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking
397370
default y
398371

399372
config ARDUINO_SELECTIVE_WiFiProv
400373
bool "Enable WiFiProv"
374+
depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking && ARDUINO_SELECTIVE_WiFi
375+
default y
376+
377+
config ARDUINO_SELECTIVE_BLE
378+
bool "Enable BLE"
401379
depends on ARDUINO_SELECTIVE_COMPILATION
402-
select ARDUINO_SELECTIVE_WiFi
403380
default y
404381

405-
config ARDUINO_SELECTIVE_Wire
406-
bool "Enable Wire"
382+
config ARDUINO_SELECTIVE_BluetoothSerial
383+
bool "Enable BluetoothSerial"
407384
depends on ARDUINO_SELECTIVE_COMPILATION
408385
default y
409386

387+
config ARDUINO_SELECTIVE_SimpleBLE
388+
bool "Enable SimpleBLE"
389+
depends on ARDUINO_SELECTIVE_COMPILATION
390+
default y
410391

411392
endmenu
412393

docs/en/api/wifi.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ Function to get the IPv6 address.
345345

346346
.. code-block:: arduino
347347
348-
IPAddress softAPIPv6();
348+
IPAddress softAPlinkLocalIPv6();
349349
350350
The function will return the AP IPv6 address in ``IPAddress`` format.
351351

libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <WiFi.h>
22
#include <ESPmDNS.h>
3-
#include <WiFiUdp.h>
3+
#include <NetworkUdp.h>
44
#include <ArduinoOTA.h>
55

66
const char* ssid = "..........";

libraries/ArduinoOTA/src/ArduinoOTA.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define LWIP_OPEN_SRC
33
#endif
44
#include <functional>
5-
#include <WiFiUdp.h>
65
#include "ArduinoOTA.h"
6+
#include "NetworkClient.h"
77
#include "ESPmDNS.h"
88
#include "MD5Builder.h"
99
#include "Update.h"
@@ -128,7 +128,7 @@ void ArduinoOTAClass::begin() {
128128
if (!_hostname.length()) {
129129
char tmp[20];
130130
uint8_t mac[6];
131-
WiFi.macAddress(mac);
131+
Network.macAddress(mac);
132132
sprintf(tmp, "esp32-%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
133133
_hostname = tmp;
134134
}
@@ -266,7 +266,7 @@ void ArduinoOTAClass::_runUpdate() {
266266
_progress_callback(0, _size);
267267
}
268268

269-
WiFiClient client;
269+
NetworkClient client;
270270
if (!client.connect(_ota_ip, _ota_port)) {
271271
if (_error_callback) {
272272
_error_callback(OTA_CONNECT_ERROR);

libraries/ArduinoOTA/src/ArduinoOTA.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef __ARDUINO_OTA_H
22
#define __ARDUINO_OTA_H
33

4-
#include <WiFi.h>
5-
#include <functional>
4+
#include "Network.h"
65
#include "Update.h"
6+
#include <functional>
77

88
#define INT_BUFFER_SIZE 16
99

@@ -86,7 +86,7 @@ class ArduinoOTAClass
8686
String _hostname;
8787
String _partition_label;
8888
String _nonce;
89-
WiFiUDP _udp_ota;
89+
NetworkUDP _udp_ota;
9090
bool _initialized;
9191
bool _rebootOnSuccess;
9292
bool _mdnsEnabled;

libraries/DNSServer/src/DNSServer.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ DNSServer::DNSServer(const String &domainName) : _port(DNS_DEFAULT_PORT), _ttl(h
2020

2121
bool DNSServer::start(){
2222
if (_resolvedIP.operator uint32_t() == 0){ // no address is set, try to obtain AP interface's IP
23+
#if SOC_WIFI_SUPPORTED
2324
if (WiFi.getMode() & WIFI_AP){
2425
_resolvedIP = WiFi.softAPIP();
25-
} else return false; // won't run if WiFi is not in AP mode
26+
return true;
27+
}
28+
#endif
29+
return false; // won't run if WiFi is not in AP mode
2630
}
2731

2832
_udp.close();

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626

2727
// Face Detection will not work on boards without (or with disabled) PSRAM
2828
#ifdef BOARD_HAS_PSRAM
29-
#define CONFIG_ESP_FACE_DETECT_ENABLED 1
3029
// Face Recognition takes upward from 15 seconds per frame on chips other than ESP32S3
3130
// Makes no sense to have it enabled for them
3231
#if CONFIG_IDF_TARGET_ESP32S3
3332
#define CONFIG_ESP_FACE_RECOGNITION_ENABLED 1
33+
#define CONFIG_ESP_FACE_DETECT_ENABLED 1
3434
#else
3535
#define CONFIG_ESP_FACE_RECOGNITION_ENABLED 0
36+
#define CONFIG_ESP_FACE_DETECT_ENABLED 0
3637
#endif
3738
#else
3839
#define CONFIG_ESP_FACE_DETECT_ENABLED 0

0 commit comments

Comments
 (0)