Merge pull request #106 from dhalbert/update-ether-example

Update Ethernet library usage
This commit is contained in:
Dan Halbert 2025-06-24 14:17:48 -04:00 committed by GitHub
commit c43147a016
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 8 deletions

View file

@ -28,13 +28,11 @@ it may not be able to access the internet.
Manual Ethernet
---------------
Most of the time, the WiFi will be a preferred way of connecting to the network.
Nevertheless it is also possible to use Ethernet instead of WiFi.
The only difference in usage is related to configuring the ``socket_source`` differently.
Ethernet can also be used to connect to the location network.
.. literalinclude:: ../examples/httpserver_simpletest_manual_ethernet.py
:caption: examples/httpserver_simpletest_manual_ethernet.py
:emphasize-lines: 7,10,12-24,37
:emphasize-lines: 11-20
:linenos:
Automatic WiFi using ``settings.toml``

View file

@ -2,9 +2,9 @@
#
# SPDX-License-Identifier: MIT
import adafruit_connection_manager
import board
import digitalio
from adafruit_wiznet5k import adafruit_wiznet5k_socket as socket
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
from adafruit_httpserver import Request, Response, Server
@ -20,10 +20,9 @@ spi_bus = board.SPI()
# Initialize ethernet interface with DHCP
eth = WIZNET5K(spi_bus, cs)
# Set the interface on the socket source
socket.set_interface(eth)
pool = adafruit_connection_manager.get_radio_socketpool(eth)
server = Server(socket, "/static", debug=True)
server = Server(pool, "/static", debug=True)
@server.route("/")