Commit 13a1acc7 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

esp8266/scripts/webrepl: Add start_foreground() method.

Starts WebREPL server in foreground and waits for (single) connection.
parent c4587e24
......@@ -10,7 +10,7 @@ listen_s = None
client_s = None
def setup_conn(port, accept_handler):
global listen_s, client_s
global listen_s
listen_s = socket.socket()
listen_s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
......@@ -19,11 +19,13 @@ def setup_conn(port, accept_handler):
listen_s.setsockopt(socket.SOL_SOCKET, 20, accept_handler)
if accept_handler:
listen_s.setsockopt(socket.SOL_SOCKET, 20, accept_handler)
for i in (network.AP_IF, network.STA_IF):
iface = network.WLAN(i)
print("WebREPL daemon started on ws://%s:%d" % (iface.ifconfig()[0], port))
return listen_s
def accept_conn(listen_sock):
......@@ -65,3 +67,9 @@ def start(port=8266, password=None):
setup_conn(port, accept_conn)
print("Started webrepl in normal mode")
def start_foreground(port=8266):
s = setup_conn(port, None)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment