Skip to content

Rewrite wifi menu #140

Merged
rreichenbach merged 39 commits into
TreeFallSound:pistomp-v3from
sastraxi:feat/multi-wifi
May 21, 2026
Merged

Rewrite wifi menu #140
rreichenbach merged 39 commits into
TreeFallSound:pistomp-v3from
sastraxi:feat/multi-wifi

Conversation

@sastraxi

@sastraxi sastraxi commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Wifi system overview

modalapi/wifi.py has been refactored into a modalapi.wifi package with five modules:

  • types.py: shared data types
  • nmcli.py: subprocess wrapper and nmcli output parsers
  • ops.py: wifi operations that use nmcli under the hood
  • commands.py: Command[T] and concrete command dataclasses (ConnectSavedCmd, ConnectScannedCmd, ScanCmd, etc.), plus a single-worker serialized CommandQueue executor
  • manager.py: integrates with mod/modhandler, owns the polling thread, status cache, and queue instance

Bugfixes

  1. I suggest you apply Disable wifi powersaving pi-gen-pistomp#12 to improve scan UX.
  2. Includes Fix RGBA image rendering #146. This affects a lot of snapshots as it subtly changes how icons are rendered.

Demo (out-of-date)

While not accurate to what the current wifi menu looks like, it's accurate in terms of functionality.

Wifi.Menu.mov

Author checklist

  • port over tests
  • end-to-end testing with emulator and debug calls
  • test on-device (pistomp-arch)

sastraxi and others added 18 commits April 30, 2026 22:01
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cherry-picks (non-emulator portions):
- 08c57d3 Fix multi-wifi / test / emulator integration (test hunks only)
- aa0560f Snapshot updates
- 1a9f520 Test update for nearby networks
- 2c70da1 Snapshot updates
- 1b89fe8 Tests for wifi menu upgrades (conflict on conftest.py:
  kept wifi helpers, dropped blend_system fixture per blend-stack
  separation)
- bcacfe2 Tests for wifi menu: open glyph and BadNet failure
- b7800e1 Tests for wifi menu pt 3
- e40fb24 Snapshot updates (will be regenerated locally — these
  baselines were rendered against the release/current bouquet)

Fixes pre-existing failures on feat/multi-wifi:
  tests/integration/test_wifi.py::test_configure_wifi_credentials[v2,v3]
  tests/test_lcd320x240.py::test_wifi_menu_snapshot

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previous baselines (from e40fb24) were rendered with the release/current
bouquet active, which includes a system menu icon source branch that
isn't part of feat/multi-wifi alone. Diffs are icon-only, no test logic.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sastraxi sastraxi marked this pull request as draft May 12, 2026 01:51

@rreichenbach rreichenbach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is super cool, but not ready. Switching to Hotspot works, but I can't get it back to WiFi. It sometimes wouldn't even show Nearby networks. When it did, it made me re-enter a password for the original wifi network. To avoid frustration, it should remember the password previously used so one can toggle back and forth between hotspot and wifi.

FWIW, I found that working/testing this kind of stuff gets really frustrating if you switch modes and rely on that connection for making your code changes. It's good to have a wired connection that's always available.

@sastraxi

Copy link
Copy Markdown
Collaborator Author

This is super cool, but not ready. Switching to Hotspot works, but I can't get it back to WiFi. It sometimes wouldn't even show Nearby networks. When it did, it made me re-enter a password for the original wifi network. To avoid frustration, it should remember the password previously used so one can toggle back and forth between hotspot and wifi.

FWIW, I found that working/testing this kind of stuff gets really frustrating if you switch modes and rely on that connection for making your code changes. It's good to have a wired connection that's always available.

Randall, I apologise. I accidentally did not push up my latest round of changes 🙈 I'll see if I can repro your bug on the current tip.

@sastraxi

Copy link
Copy Markdown
Collaborator Author

Fixed and added some tests for what you found.

@sastraxi sastraxi changed the title [WIP] Support multiple WiFi networks Support multiple WiFi networks May 15, 2026
@sastraxi sastraxi marked this pull request as ready for review May 15, 2026 02:51

@rreichenbach rreichenbach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Better, but I'm still having problems using this. When I first switched to Hotspot mode, the pi crashed. I power-cycled, it did come up in hotspot mode, so from that point maybe ok.

But then I disabled Hotspot mode and it does remember my previous network and connect - that's good, but the dialog title shows "WiFi - Disconnected". And if I choose that network, it will require I enter a password. It would be nice if the currently connected was identified that way (eg. "YYZ (current)" or has an icon), and maybe even not allowing it to be clicked, so the user doesn't waste time entering a password not knowing they don't need to.

Another UX issue: it's not intuitively obvious to me that clicking "Hotspot Mode" will toggle it on or off. I like the little dot indicator, but actually think it would be more clear if it showed "Switch to Hotspot Mode" when connected to WiFi, and "Disable Hotspot Mode" when in Hotspot mode.

Also when I click the wifi toolbar button, there's usually some significant lag time. I believe it's finding the networks. I wonder since that initial dialog doesn't show all the networks, if the network load could be lazy (after the dialog appears).

I know I'm asking for a lot of UX here and that's the UI lib isn't exactly robust. But lack of connectivity can cause major frustration, so if we're going to improve this, it should work rather smoothly.

@sastraxi sastraxi changed the title Support multiple WiFi networks Rewrite wifi menu May 17, 2026
Comment thread modalapi/mod.py
if self.wifi_status[key]:
hotspot_active = True
key = 'ip_address'
key = 'ip4_address'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unrelated bugfix

Comment thread pistomp/lcd320x240.py
Comment on lines +264 to +268
def draw_selection_menu(self, items, title="", auto_dismiss=False, dismiss_option=False,
font=None, title_font=None, default_item=None):
# items is a list of tuples: (label, callback, arg) or (label, callback, arg, is_active)
# or (label, callback, arg, is_active, long_callback) where long_callback is called
# instead of callback on a long press.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is getting pretty out-of-hand, will tackle in a future PR

@rreichenbach rreichenbach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems to work great and usage feels intuitive. I know that was a lot of work. Thanks!

@rreichenbach rreichenbach merged commit b77ba28 into TreeFallSound:pistomp-v3 May 21, 2026
1 check passed
sastraxi added a commit to sastraxi/pi-stomp that referenced this pull request May 23, 2026
The new WifiManager (now on pistomp-v3 via PR TreeFallSound#140) is command-queue-based:
callers invoke the queue with Cmd objects, poll() drains via on_status_change
callback, saved profiles surface through get_cached_saved(), and
connect_scanned/saved gained extra args (security, wait, reconnect).
StubWifiManager still used the pre-queue interface and crashed the emulator
on first wifi tick. Reuse the real CommandQueue against the stub (its run()
methods match the new shape), add the missing methods, and drop the
orphaned configure_wifi path which no caller invokes anymore.

Relocated from release/patch bridge 54c590a now that feat/multi-wifi has
landed on base.
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