Skip to content

Commit d4dc768

Browse files
committed
Included ethernet example in docs, fixes to emphasized lines
1 parent 9dfaf80 commit d4dc768

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

docs/examples.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ It also manually connects to the WiFi network.
1515
:emphasize-lines: 12-17
1616
:linenos:
1717

18+
It is also possible to use Ethernet instead of WiFi.
19+
The only difference in usage is related to configuring the ``socket_source`` differently.
20+
21+
.. literalinclude:: ../examples/httpserver_ethernet_simpletest.py
22+
:caption: examples/httpserver_ethernet_simpletest.py
23+
:emphasize-lines: 13-23
24+
:linenos:
25+
1826
Although there is nothing wrong with this approach, from the version 8.0.0 of CircuitPython,
1927
`it is possible to use the environment variables <https://docs.circuitpython.org/en/latest/docs/environment.html#circuitpython-behavior>`_
2028
defined in ``settings.toml`` file to store secrets and configure the WiFi network.
@@ -32,6 +40,7 @@ Note that we still need to import ``socketpool`` and ``wifi`` modules.
3240

3341
.. literalinclude:: ../examples/httpserver_simpletest_auto.py
3442
:caption: examples/httpserver_simpletest_auto.py
43+
:emphasize-lines: 11
3544
:linenos:
3645

3746
Serving static files
@@ -76,7 +85,7 @@ a running total of the last 10 samples.
7685

7786
.. literalinclude:: ../examples/httpserver_start_and_poll.py
7887
:caption: examples/httpserver_start_and_poll.py
79-
:emphasize-lines: 24,33
88+
:emphasize-lines: 29,38
8089
:linenos:
8190

8291
Server with MDNS
@@ -145,7 +154,7 @@ Tested on ESP32-S2 Feather.
145154

146155
.. literalinclude:: ../examples/httpserver_neopixel.py
147156
:caption: examples/httpserver_neopixel.py
148-
:emphasize-lines: 25-27,39,51,60,66
157+
:emphasize-lines: 26-28,41,52,68,74
149158
:linenos:
150159

151160
Form data parsing
@@ -293,7 +302,7 @@ This might change in the future, but for now, it is recommended to use Websocket
293302

294303
.. literalinclude:: ../examples/httpserver_websocket.py
295304
:caption: examples/httpserver_websocket.py
296-
:emphasize-lines: 10,16-17,60-67,76,81
305+
:emphasize-lines: 9,16-17,60-67,76,81
297306
:linenos:
298307

299308
Multiple servers

examples/httpserver_ethernet_simpletest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import board
55
import digitalio
6+
67
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
78
import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
89
from adafruit_httpserver import Server, Request, Response
@@ -18,10 +19,10 @@
1819
# Initialize ethernet interface with DHCP
1920
eth = WIZNET5K(spi_bus, cs)
2021

21-
# set the interface on the socket source
22+
# Set the interface on the socket source
2223
socket.set_interface(eth)
2324

24-
# initialize the server
25+
# Initialize the server
2526
server = Server(socket, "/static", debug=True)
2627

2728

0 commit comments

Comments
 (0)