Skip to content

Comments

Support flashing with multiple wifi configs#640

Open
addshore wants to merge 3 commits intotoitlang:mainfrom
addshore:multiple-wifis
Open

Support flashing with multiple wifi configs#640
addshore wants to merge 3 commits intotoitlang:mainfrom
addshore:multiple-wifis

Conversation

@addshore
Copy link
Contributor

@addshore addshore commented Oct 8, 2025

Fixes #158

High level changes:

  • New jag commands for interacting with a list of
    wifi settings, rather than just one
  • Changed the underlying computer and device config
    structure to support mutliple wifis
  • Added a scan to the jag startup to look for wifis
    that actually exist, connecting to ones we can see

This is very much a first iteration that I have confirmed
working on my local device, but I expect it could do with
some tidying, but it works now and is something to look
at!

@addshore addshore marked this pull request as draft October 8, 2025 12:35
@addshore addshore marked this pull request as draft October 8, 2025 12:35
@addshore
Copy link
Contributor Author

addshore commented Oct 8, 2025

So, this does change behaviour a little, as I for example had an app that depended on effective := firmware.config["wifi"] to try and figure out if wifi was configured..

  has-wifi-configured -> bool:
    // Check if we have wifi configured (for web server)
    effective := firmware.config["wifi"]
    if effective == null:
      return false
    ssid := effective.get wifi.CONFIG-SSID
    if ssid != null and ssid != "":
      return true
    return false

And that now totally crashes.

This ties into my desire to be able to tell if wifi is configured or connected, without opening it

https://discord.com/channels/918498540232253480/1420350603338584166

Fixes toitlang#158

High level changes:
 - New jag commands for interacting with a list of
   wifi settings, rather than just one
 - Changed the underlying computer and device config
   structure to support mutliple wifis
 - Added a scan to the jag startup to look for wifis
   that actually exist, connecting to ones we can see

This is very much a first iteration that I have confirmed
working on my local device, but I expect it could do with
some tidying, but it works now and is something to look
at!
The WiFi config structure now uses proper keys ("ssid"/"password")
instead of dotted keys ("wifi.ssid"/"wifi.password") so that existing
Toit apps that check firmware.config["wifi"].get wifi.CONFIG-SSID
continue to work correctly.
@addshore addshore marked this pull request as ready for review January 30, 2026 00:03
Copy link
Member

@floitsch floitsch left a comment

Choose a reason for hiding this comment

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

I like it.

defines[JAG-DISABLE-UDP] = true
if header := headers.single HEADER-CONTAINER-TIMEOUT:
timeout := int.parse header --if-error=: null
timeout := int.parse header --on-error=: null
Copy link
Member

Choose a reason for hiding this comment

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

It's if-error now.

Suggested change
timeout := int.parse header --on-error=: null
timeout := int.parse header --if-error=: null

@floitsch
Copy link
Member

I wonder if we can make the PR simpler by using the fact that the jag and the firmware are always of the same version.
As such, we can transition (without backwards-compatibility) to the new format.
However, we would need to be able to read the old config file (on the desktop). The rest should be able to assume that both sides use the new format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support flashing with multiple wifi configurations

2 participants