-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add Web Workflow #6174
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
Comments
Given that these devices can (in some cases must) have their SSID/KEY set and perhaps an IP, I think it would be good to add a way to set the hostname. In the secrets.py file, an optional parameter named mDNS name or hostname or the like would be super helpful. If that isn't found, then the circuitpython.local would be the default. But this allows a longer-term solution when there are > 1 CP device on the network. Also, why are we using port 7676? That makes the assumption that Windows Firewall won't care (for outbound requests, that's probably safe), but is there a driving requirement for this? There are multiple ways to manage getting the name on the network. mDNS is one (UDP multicast over port 5353), but most DHCP servers will also accept hostnames set in the DHCP client request (I believe it's option 81). My router at home allows you to name servers and "pin" the name/IP lease so that the MAC will always get the same values. If we are supporting DHCP, sending the hostname would be helpful (and having it in the secrets.py file would make it easy). |
This is possible with #6175 allows for changing the unique name through
The proposal above does handle >1 cp devices on the network because they respond to
We were just brainstorming a port number on Discord. I'm open to suggestions. We wanted to avoid 80 because the user may want to use it for their own code.
I believe |
The ability to "pin" or reserve DHCP MAC-to-IPv4 address mappings is a convenience offered by most routers, I'm not aware of any standards that cover it. As I read this, |
If you're making wifi persistent, how about a telnet server for the repl too? |
This is desirable for web workflow. However, users are currently in full control of starting and stopping a Station and connecting to an AP, starting and stopping an AP, starting and stopping wifi, etc. There should be a mechanism where user code still retains full control of whether / when / how the device interacts with a wifi network, during code execution and across reloads and resets. In other words, it should still be possible for a CircuitPython device to reload or reset into a mode where it is not interacting with wifi, but code can later connect or do other wifi actions (presumably including mDNS or web workflow). |
Yup! I mention something similar in #6 but forgot to add it to the TODO list.
Agreed! I'd probably add a |
This is such a neat idea! Looking over the tasks you've outlined with an eye toward finding some part that I might be capable of helping with, I'm curious if the internal HTTP server that you mentioned is something that will get written with python code? or it's internal to the core and thus written in C? |
Hype! This probably won't be useful to anyone, but here's my OTA solution I built for my project. It just fetches from GitHub. |
Generally we need C code for things that run outside the VM. My plan was to look into the HTTP Server that the IDF has and probably use it. It might be pretty big though. We could probably make a smaller one that is purpose built for what we need.
Thanks for the link! It's good to collect ideas. |
A custom built server could also build on top of common_hal and be useful for any port that supports it. |
This allows for CircuitPython to resolve a .local domain and find other devices with MDNS services. First step for #6174
Turns out Android Chrome doesn't do mDNS yet. Here is their feature request: https://crbug.com/405925 |
This adds support for CIRCUITPY_WIFI_SSID and CIRCUITPY_WIFI_PASSWORD in `/.env`. When both are defined, CircuitPython will attempt to connect to the network even when user code isn't running. If the user code attempts to a network with the same SSID, it will return immediately. Connecting to another SSID will disconnect from the auto-connected network. If the user code initiates the connection, then it will be shutdown after user code exits. (Should match <8 behavior.) This PR also reworks the default displayio terminal. It now supports a title bar TileGrid in addition to the (newly renamed) scroll area. The default title bar is the top row of the display and is positioned to the right of the Blinka logo when it is enabled. The scroll area is now below the Blinka logo. The Wi-Fi auto-connect code now uses the title bar to show its state including the IP address when connected. It does this through the "standard" OSC control sequence `ESC ] 0 ; <s> ESC \` where <s> is the title bar string. This is commonly supported by terminals so it should work over USB and UART as well. Related to #6174
Android 12+ now supports MDNS .local in Chrome. 🎉 https://www.androidpolice.com/android-mdns-local-hostname/ |
Hey, how about Webdav ? |
Please open a separate issue for it. I think it'd be good to have a list of clients we want to support. That way we can figure out what subset of webdav they use. I skipped it for now because I was wary of how much space it'd take to implement. |
@FoamyGuy finished this by adding the edit page. Considering this done! Thanks all! |
Coming from #4050. Is there any guide/example for OTA update? |
is it possible to enable Web Workflow on devices that are connected to the network via Ethernet instead of Wi-Fi? |
No, that is not possible at this time. If there's not an open Issue about "web workflow over ethernet", it would be appropriate to open one. That said, it's not likely to be prioritized by Adafruit to work on. |
How can I override the root page and specify my own routes ? Would like to host my own website / api but port 80 is already bound by CircuitPython's Web API |
@kub3let you could try changing Or you could use different names for your WIFI credentials inside settings.toml. If the core system can't find the credentials under those names then it won't start the web workflow server I think. |
@FoamyGuy thank you, to be clear I want to keep the Workflow Web API in order to use the /code functionality. I will change the port for now via settings.toml, seems like the best way. |
Let's add a way to work with CircuitPython over the (local) web!
How it should work
http://circuitpython.local:7676
in a web browser. This uses mDNS to do a local domain lookup.circuitpython.local
host and will return with a 302 redirect to the device's specific domain which will becpy-000000.local
where000000
is the last three bytes of the mac address. (mDNS is also used for thecpy-000000.local
lookup but only on device will reply.)/peers
endpoint that will cause it to do a service discovery mDNS request that finds all other CircuitPython devices on the network. The web editor can then provide links to other devices directly.Getting on WiFi
This method doesn't address how a device gets on the network to begin with. The simplest way is by editing WiFi config settings over USB mass storage. For devices without USB, a webserial based webpage can be provided to write credentials. See how wippersnapper does it.
TODO
AddDepends on CIRCUITPY_WIFI_SSID.supervisor.disable_web_workflow()
to prevent WiFi from running outside of user code.wifi.radio.connect()
could be modified to save credentials.circuitpython.local
requests to its unique hostname.Origin
that isn't in an allowlist so regular insecure pages cannot access it./
/peers
with other device info.Connect the serial input/output to a socket. Likely 23 to match telnet.Should be usable through an insecure websocket as well.The text was updated successfully, but these errors were encountered: