Webrepl

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Webrepl

Post by OutoftheBOTS_ » Sat Jan 22, 2022 11:03 pm

I don't seem to be able to get Webrepl to load in my browser.

Here's the code in my Boot.py

Code: Select all

import network
import time

wlan = network.WLAN(network.STA_IF) # create station interface
wlan.active(True)       # activate the interface

print("trying to connect to WiFi")
if not wlan.isconnected(): wlan.connect('#####', '######') # connect to an AP

start_time = time.time()
while not wlan.isconnected():
            if time.time() - start_time > 5:
                print("failed to connect")
                break

if wlan.isconnected():
    print (wlan.ifconfig())         # get the interface's IP/netmask/gw/DNS addresses
    import webrepl
    webrepl.start()
produces this output in the repl connect via USB

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:5656
load:0x40078000,len:12696
load:0x40080400,len:4292
entry 0x400806b0
trying to connect to WiFi
('192.168.0.146', '255.255.255.0', '192.168.0.1', '192.168.0.1')
WebREPL daemon started on ws://192.168.0.146:8266
Started webrepl in normal mode
hellow world from main.py
MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32
Type "help()" for more information.
>>> 
but when I go to my web browser it just says it can't be reached

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Webrepl

Post by OutoftheBOTS_ » Sat Jan 22, 2022 11:20 pm

OK I got a little further and downloaded the "webrepl.html" from the github and opened it with me web browser then put "ws://192.168.0.146:8266" in the address and hit connect.

This is the output from the USB repl

Code: Select all

WebREPL connection from: ('192.168.0.80', 57581)
dupterm: EOF received, deactivating
this is what the web browser shows
Capture.PNG
Capture.PNG (35.04 KiB) Viewed 11407 times

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Webrepl

Post by OutoftheBOTS_ » Sat Jan 22, 2022 11:29 pm

OK I was following old instructions.

it seems you have to goto this page here "http://micropython.org/webrepl/" not sure how well that will work if the ESP32 is in AP mode rather than STA mode.

I now can connect but can't type anything in to the python prompt but can send files
Capture2.PNG
Capture2.PNG (37.4 KiB) Viewed 11400 times

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: Webrepl

Post by marcidy » Sun Jan 23, 2022 3:29 am

Is anything running? Can you connect to the repl over USB and see if anything is printed when you try to connect via webrepl? Is the repl usable over USB while connected via webrepl? Is the webrpel showing output while using the repl over USB?

The only time I've seen the behavior you are showing is when I'm running something and connect to the webrepl. You'll get ">>> " but you cannot interact as the interpreter is busy. This is expected in this case, just like with normal python.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Webrepl

Post by OutoftheBOTS_ » Sun Jan 23, 2022 8:37 am

I get a repl over USB.

I get this in the USB repl

Code: Select all

WebREPL connection from: ('192.168.0.80', 57581)
I can't type in the webrepl at all whether I have code running or not. If I do have code running and my code prints something out then it doesn't appear in the webrepl but will appear in the USB repl. It doesn't make any difference whether I have a USB repl open or not, I still get same behavior in webrepl

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: Webrepl

Post by marcidy » Sun Jan 23, 2022 7:50 pm

ah, ok, thank you. What's the exact hardware are you using?

This indicates to me that os.dupterm and os.dupterm_notify aren't working correctly for whatever reason. Can you also try the 1.18 that was released?

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Webrepl

Post by OutoftheBOTS_ » Sun Jan 23, 2022 8:47 pm

I have exactly the same behavior on this firmware too
MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Webrepl

Post by OutoftheBOTS_ » Sun Jan 23, 2022 8:59 pm

@marcidy

If you're 1 of the devs working on webrepl a suggestion that I would have is that soft reset doesn't reset the webrepl the same as soft reset doesn't reset network connections or USB repl

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: Webrepl

Post by marcidy » Sun Jan 23, 2022 9:46 pm

I'm not a dev working on it, I have read a significant amount of the responsible code and spent time with it, though. The suggestion might get buried if left in this thread, if you feel strongly about it, maybe raise a github issse, as that will get more dev attention.

I tried to reproduce your issue, but I can connect and use it. I looked back over your posts and I missed that you are using webrepl_setup, though. I can use this OK, but i wonder if the issue may be related.

I personally do not use webrepl_setup. I do all my network configuration in boot.py, including launching the webrepl with a password i store on the FS myself. I don't know if this is related to your problem, but I see that webrepl_setup does require overwriting boot.py. Maybe it is possible there may be some issue with webrepl_setup editing boot.py, and then you overwrite it?

For testing purposes, i would do the following:
  • put network configuration and webrepl configuration in boot.py
    use webrepl.start(password="test") instead of webrepl.start()
  • remove webrepl_cfg.py from the filesystem: os.remove("webrepl_cfg.py")
so boot.py might look something like:

Code: Select all

import network
import webrepl

net = network.WLAN(network.STA_IF)
net.active(1)
net.connect(SSID, PASS)

webrepl.start(password="test")
and see if this minimal functionality gets you back to a state where you can connect to the webrepl. You should monitor over USB just to be sure.

I'm trying to assess if there is any ability to use the webrepl with the firmware you have, it's hard to guess at things when I cannot reproduce on my side. I know the endless questions are annoying

JDRBoston
Posts: 21
Joined: Mon Feb 19, 2018 9:43 pm

Re: Webrepl

Post by JDRBoston » Mon Jan 24, 2022 12:05 am

I'm not sure whether this helps, but during one of the upgrades my browser started defaulting to https connections, even though It didn't indicate that it was using https in the URL of the browser window. It seems like Firefox added this as a feature to ensure a secure connection. When I switched to another browser (Safari) that didn't try to make this type of incompatible connection, I had no problem connecting with my ESP32.

Post Reply