Skip to content

Wi-Fi autoconnect and title bar status #6473

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 6 commits into from
Jun 14, 2022
Merged

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Jun 9, 2022

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

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 micropython#6174
@tannewt tannewt requested a review from dhalbert June 9, 2022 21:56
@tannewt tannewt added this to the 8.0.0 milestone Jun 9, 2022
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.

I tested with a Feather ESP32-S2 no PSRAM, and also with a FunHouse.

With both, I saw the title bar of the terminal change (neat!) when I connected successfully.

If I gave SSID that could not be reached in .env, things failed fairly quickly. However, if I gave an incorrect password in .env, there was a long time waiting before the FunHouse showed the status code, and even longer for the /dev/ttyACMx to come up. Sometimes it did not respond at all and I had to disconnect and reconnect (with tio).

I tried going into safe modeso I could edit .env by clicking during the three flashes, but it didn't seem to work. It also didn't work on an older build, so this seems like an existing problem. Eventually, it did come up, even with the bad password, and I was able to edit.

So try these scenarios yourself, and see how it works for you. I'm not sure about having the connect be blocking, especially when the connect is not happening, but not blocking may have its own problems.

tannewt added 5 commits June 13, 2022 09:18
Make them CIRCUITPY_FULL_BUILD = 0 and rework the boards to have
the same modules enabled (ish.)

Also make ZLIB require FULL_BUILD and disable advanced `micropython`
module APIs by default on all builds.
This adds basic timeout support to connect by preventing subsequent
retries if over time. The first connect may still take more than
the timeout.
@tannewt
Copy link
Member Author

tannewt commented Jun 13, 2022

I'm not sure about having the connect be blocking, especially when the connect is not happening, but not blocking may have its own problems.

I've added basic timeout support to connect() now. The failure is still kind of long because connect does a full scan first. It won't retry now though so it should be somewhat faster than before. Before it'd retry 5 times before failing.

I've added a TODO to do our own scan first but didn't give in to doing it now.

@tannewt
Copy link
Member Author

tannewt commented Jun 14, 2022

@dhalbert This is ready for another look

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 improved timeout. With a bad password, I am seeing "authentication failure" after about 7 seconds, and CIRCUITPY appears after about 15 seconds. Eventually I see "off" instead of "authentication failure", as I expect you wanted.

Also thanks for the nRF52833 cleanup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants