* lib Network: add cpp syntax to structs
* [Network] deprecate NetworkEvents::removeEvent() for std::function callbacks
removing event callback via std::function pointer does not work as expected for lambdas (issue #10365)
here mark NetworkEvents::removeEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX)
as deprecated in favor of removing by callback's id
for NetworkEvents::onEvent remove checking for dublicate event handler, this does not work for lambdas too
remove NetworkEvents::find methods as unnecessary
move cbEventList container inside the class
declare NetworkEventCbList_t as a cpp struct with constructor, allows using std::vector.emplace() when adding new items to container
optimize NetworkEvents::remove() calls to use erase-remove idiom for std::vector
* [Network] hide event task under private member of NetworkEvents class
prevent checkForEvent loop to be callable from outside the task's thread
* refactor(NetworkEvents) code polishing and comments
- rename NetworkEvents::cbEventList as private member NetworkEvents_cbEventList
- NetworkEvents::getStatusBits() add const qualifier
- turn statics into constexpr
- add indexes to enum::arduino_event_id_t to make events indexing consistent for SOCs with/without WiFi
also leave some index gaps to minimize renumbering on adding new events
- add doxygen help to NetworkEvents:: methods
- declare NetworkEvents::eventName() as static, that could be used without creating class scope
- potential mem leak in postEvent
* refactor(NetworkEvents) add (optional) mutex lock for container operations
provide thread safety for dual core SoCs
since std::mutex brings additional componetns of libstdc++ lib it impacts resulting image size significantly (around 50k)
Might be enabled on-demand if thread-safety is required
* ci(pre-commit): Apply automatic fixes
* fix(spelling): Fix spelling mistakes
---------
Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
* feat(p4): Add support for WiFi to ESP32-P4
Implements support for external MCU connected through SDIO
* fix(p4): Init SDIO host properly on Network boot
esp-hosted has one function marked as "constructor" that did not run in the boot phase of the chip. This calls the function when network is started
* Fix(NetworkEvents): Don't skip event callbacks in NetworkEvents::removeEvent
Fixes Issue 10318
Includes pull request 10321 that fixes 10316
This change:
* Adds code to find the event callbacks
* Issues error when duplicate callbacks insertion attempts are made
* Issues error when callbacks are not found during removal
* Fix(NetworkEvents): Don't skip event callbacks in NetworkEvents::removeEvent
Fixes Issue 10318
Includes pull request 10321 that fixes 10316
This change:
* Adds code to find the event callbacks
* Issues warning when duplicate callbacks insertion attempts are made
* Issues warning when callbacks are not found during removal
---------
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
* fix(lwip): Add early out in `NetworkUDP::parsePacket()` when socket has no data
Previously, `NetworkUDP::parsePacket()` would take the time to allocate a 1460 byte buffer
to call `recvfrom()` with, immediately freeing it if there was no data read.
This change has it check if there is available data via `ioctl()` with `FIONREAD` first,
saving the allocation and thus significantly increasing performance in no data situations.
* fix(lwip): Initialize `len` to ensure it's set before check
* IDF release/v5.1 dc859c1e67
* fix(lwip): Filter out V6 packets if V6 is not enabled
the ESP might accept and act on some IPv6 packets, even though IPv6 is not enabled for the interface in Arduino. This change makes the ESP ignore all IPv6 packets if IPv6 address is not available.
* fix(lwip): DNS header is not required
* fix(ot): Add LWIP_HOOK_IP6_INPUT_CUSTOM support
If the interface is already connected, try to enable IPv6 immediately. Otherwise the interface would need to go through disconnect/connect cycle for IPv6 to be enabled.
* fix(net): Don't unreg events if there are netifs
Unregister IP events only if all other netifs are stopped.
* fix(eth): Delete mac and phy on end
* fix(net): Update pin naming and log levels
* fix: NetworkClient - close the connection in stop() method
for all copies referring it
* ci(pre-commit): Apply automatic fixes
---------
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Work around because AF_UNSPEC does not check available addresses when
determining result.
If you have a global scope IPv6 address, then first check for IPv6 DNS result;
if you don't have an IPv6, or there is no IPv6 result, then check IPv4.
This allows IPv6-only networks to connect to dual-stack destinations, as they
will get the IPv6 address (rather than the unusable IPv4).
It also means a dual-stack host to a dual-stack destination will preference
IPv6.
There is no effect if you are on an IPv4-only network, or it is an IPv4-only
destination.
* feat(net): Add support for esp_netif flags
Provides better automation for setting IP/DNS
* feat(net): Show DHCPC status as OFF when static IP is used
* fix(dns): Handle IPv6 DNS server address results
If the result from esp_netif_get_dns_info is an IPv6 address, then parse to an IPAddress.
* fix(dns): Use getaddrinfo for DNS, to fix some IPv6 issues
Replace hostbyname with getaddrinfo for better IPv6 support. The API is also
simpler, as it has no callbacks (they are handled internally). Allows
dual-stack networks to connect to IPv6-only destinations.
Still does not work for IPv6-only networks, as IPv6 DNS is not enabled in the
pre-built ESP-IDF libraries.
* 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 <32426024+lucasssvaz@users.noreply.github.com>
---------
Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>