Skip to content

Add web workflow to ESP boards #6528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jul 1, 2022
Merged

Add web workflow to ESP boards #6528

merged 21 commits into from
Jul 1, 2022

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Jun 28, 2022

This adds a web server to CircuitPython that runs on port 80 and provides workflow related APIs. See docs/workflows.md for details.

Related to #6174

@tannewt tannewt added supervisor network espressif applies to multiple Espressif chips labels Jun 28, 2022
@tannewt tannewt added this to the 8.0.0 milestone Jun 28, 2022
@tannewt tannewt requested a review from dhalbert June 28, 2022 17:38
@dhalbert
Copy link
Collaborator

new merge conflict just appeared

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

I tried giving an incorrect password again. When connected to the REPL, I see a long delay before the REPL produces output, and even after producing output, I cannot type at the REPL for 10-15 seconds after "Press any key" shows up.

If I have two boards web-capable boards, at least on Linux, and unplug one, and plug in the other, the avahi caching will resolve circuitpython.local to the old board's IP address for some time (minutes, it appears). I don't know how well it works on Windows or macOS. There doesn't seem to be an easy way to clear the cache except to restart the avahi daemon.

Rather mysteriously, the first board I tried did not show up in the browser for some time. This seems like a DNS issue.

I could not get the Javacript buttons to work in the file browser -- they were all gray all the time.

I think we could still merge this soon for people to try, and say it's rough and we want feedback.

@dhalbert
Copy link
Collaborator

I'm thinking about a CIRCUITPY_WEB_API_ENABLE in .env. By default it would be off, so that you have set it to enable the web workflow to have it be on. This allows .env to store SSID and password as an eventual replacement for secrets.py. I can open this up as a separate issue later.

It also brings up the question of how to represent boolean values in .env.

@tannewt
Copy link
Member Author

tannewt commented Jun 30, 2022

I tried giving an incorrect password again. When connected to the REPL, I see a long delay before the REPL produces output, and even after producing output, I cannot type at the REPL for 10-15 seconds after "Press any key" shows up.

This should be the same as before. I didn't change anything with the auto-connect.

If I have two boards web-capable boards, at least on Linux, and unplug one, and plug in the other, the avahi caching will resolve circuitpython.local to the old board's IP address for some time (minutes, it appears). I don't know how well it works on Windows or macOS. There doesn't seem to be an easy way to clear the cache except to restart the avahi daemon.

I haven't noticed this on Arch. Though I've been mainly using the same board. You should be able to enter the others IP and it'll do the MDNS search for you (and use the others' IPs in the list.)

Rather mysteriously, the first board I tried did not show up in the browser for some time. This seems like a DNS issue.

MDNS uses UDP so it can take some time.

I could not get the Javacript buttons to work in the file browser -- they were all gray all the time.

This is likely because you had USB storage enabled. I'll add a notice.

I think we could still merge this soon for people to try, and say it's rough and we want feedback.

100%. puts the alpha in alpha. :-)

@tannewt
Copy link
Member Author

tannewt commented Jun 30, 2022

I'm thinking about a CIRCUITPY_WEB_API_ENABLE in .env. By default it would be off, so that you have set it to enable the web workflow to have it be on. This allows .env to store SSID and password as an eventual replacement for secrets.py. I can open this up as a separate issue later.

I'm open to doing this though I'd prefer it default on when using the auto-wifi. Folks can use other env variables if they want to control it themselves (maybe HOME_WIFI and HOME_WIFI_PASSWORD or PORTAL_WIFI_SSID and PORTAL_WIFI_PASSWORD for the portal library). CIRCUITPY_ prefixed variables should be reserved for internal use.

It also brings up the question of how to represent boolean values in .env.

.env doesn't have the concept of anything but a string: theskumar/python-dotenv#293 (comment) Probably better to think of all values as enums instead of booleans. enums are also expandable which is nice. For webserver enable, maybe we want a key that is a comma separated list of ok ssids. That would turn it off if user code joins a different network.

@tannewt
Copy link
Member Author

tannewt commented Jun 30, 2022

Ok, @dhalbert please take another look when you have time.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes. Looking forward to feedback.

@dhalbert dhalbert merged commit 63873e2 into adafruit:main Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
espressif applies to multiple Espressif chips network supervisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants