Skip to content

Commit

Permalink
webrepl: Support LAN as well as WLAN boards.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Romaric-RILLET committed Sep 5, 2024
1 parent 66fa62b commit f46dffd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions micropython/net/webrepl/webrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,25 @@ def setup_conn(port, accept_handler):
listen_s.listen(1)
if accept_handler:
listen_s.setsockopt(socket.SOL_SOCKET, 20, accept_handler)
started = False
for i in (network.AP_IF, network.STA_IF):
iface = network.WLAN(i)
if iface.active():
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))
try:
iface = network.WLAN(i)
if iface.active():
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))
started = True
except AttributeError:
pass
for i in (0, 1):
try:
iface = network.LAN(i)
if iface.active():
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))
started = True
except (AttributeError, ValueError):
pass
if not started:
print("WebREPL no active interface")
return listen_s


Expand Down

0 comments on commit f46dffd

Please sign in to comment.