Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7fb3453

Browse files
committedSep 5, 2024··
webrepl: Support LAN as well as WLAN boards.
When webrepl starts, it prints out the IP address, however it does this by querying the network.WLAN object. This fail for board with an Ethernet interface but no WiFi interface. We try both type of interface (and print error if none exist) Signed-off-by: Romaric-RILLET <romaric.rillet@gmail.com>
1 parent 66fa62b commit 7fb3453

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed
 

‎micropython/net/webrepl/webrepl.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,25 @@ def setup_conn(port, accept_handler):
102102
listen_s.listen(1)
103103
if accept_handler:
104104
listen_s.setsockopt(socket.SOL_SOCKET, 20, accept_handler)
105+
started = False
105106
for i in (network.AP_IF, network.STA_IF):
106-
iface = network.WLAN(i)
107-
if iface.active():
108-
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))
107+
try:
108+
iface = network.WLAN(i)
109+
if iface.active():
110+
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))
111+
started = True
112+
except AttributeError:
113+
pass
114+
for i in (0, 1):
115+
try:
116+
iface = network.LAN(i)
117+
if iface.active():
118+
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))
119+
started = True
120+
except (AttributeError, ValueError):
121+
pass
122+
if not started:
123+
print("WebREPL no active interface")
109124
return listen_s
110125

111126

0 commit comments

Comments
 (0)
Please sign in to comment.