Skip to content

Commit c888831

Browse files
committed
esp8266/scripts/webrepl: Print connection address.
Based on active network interfaces.
1 parent 29c8c8a commit c888831

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

esp8266/scripts/webrepl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This module should be imported from REPL, not run from command line.
22
import socket
33
import uos
4+
import network
45
import websocket
56
import websocket_helper
67

@@ -13,13 +14,15 @@ def setup_conn(port):
1314
listen_s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
1415

1516
ai = socket.getaddrinfo("0.0.0.0", port)
16-
print("Bind address info:", ai)
1717
addr = ai[0][4]
1818

1919
listen_s.bind(addr)
2020
listen_s.listen(1)
2121
listen_s.setsockopt(socket.SOL_SOCKET, 20, accept_conn)
22-
print("WebREPL daemon started on port %d" % port)
22+
for i in (network.AP_IF, network.STA_IF):
23+
iface = network.WLAN(i)
24+
if iface.active():
25+
print("WebREPL daemon started on %s:%d" % (iface.ifconfig()[0], port))
2326

2427

2528
def accept_conn(listen_sock):

0 commit comments

Comments
 (0)