Skip to content

Wifi multi network support for esp32/esp8266/PicoW #601

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 22 commits into from
Jul 23, 2024
Merged

Conversation

tyeth
Copy link
Member

@tyeth tyeth commented Jul 9, 2024

This adds a new field called `alternative_networks' to the network_type_wifi object in the secrets.json settings file.

It's an array of objects (with fields network_ssid and network_password).

There is a maximum size of 3, although larger arrays will be tolerated only the first 3 entries will be used.

Example config:

{
  "io_username": "tyeth_demo",
  "io_key": "my_super_secret_adafruit_io_key",
  "network_type_wifi": {
    "network_ssid": "free4all",
    "network_password": "password",
    "alternative_networks": [
      {
        "network_ssid": "free4all_2G",
        "network_password": "password"
      },
      {
        "network_ssid": "HOTSPOT",
        "network_password": "password"
      },
      {
        "network_ssid": "Tenda_60C06C",
        "network_password": "password"
      },
      {
        "network_ssid": "THERMAL",
        "network_password": "password"
      }
    ]
  },
  "status_pixel_brightness": 0.2
}

@tyeth tyeth changed the title DRAFT - UF2 test - Wifi multi esp32 DRAFT - UF2 test - Wifi multi esp32/esp8266/PicoW Jul 10, 2024
Copy link
Member Author

@tyeth tyeth left a comment

Choose a reason for hiding this comment

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

cleanup autoformatting and retest pico reconnecting between phone then home wifi

@tyeth tyeth requested a review from brentru July 12, 2024 17:24
@tyeth tyeth marked this pull request as ready for review July 12, 2024 17:24
@tyeth tyeth changed the title DRAFT - UF2 test - Wifi multi esp32/esp8266/PicoW Wifi multi network support for esp32/esp8266/PicoW Jul 12, 2024
Copy link
Member

@brentru brentru left a comment

Choose a reason for hiding this comment

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

Overall this is a very solid feature implementation and I'll test it out on Monday. I've left comments requesting clarity and modifications.

Resolves #376

return true;
}
} // else single network mode
else if (strcmp(_ssid, WiFi.SSID(i).c_str()) == 0)
Copy link
Member

Choose a reason for hiding this comment

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

Consider changing this to else to avoid doing an extra call to strcmp and c_str

Copy link
Member Author

Choose a reason for hiding this comment

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

The normal network ssid doesn't get added to the altNetworks, so this check needs to still happen.
It has just occurred to me that I failed to test one eventuality that the primary ssid could connect when none of the altNetworks were found (which would fail). I always had some alt networks in range.

I should move this to be a separate check, dropping the else, probably above the multi-network/altNetworks check as that will be the less common path.

Copy link
Member Author

@tyeth tyeth left a comment

Choose a reason for hiding this comment

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

@brentru this should be good to go now. All feedback resolved except the "unused networks" error message, but left some not marked resolved so you see the explanations.
Let me know what you think

@tyeth tyeth merged commit e8f0f75 into main Jul 23, 2024
31 checks passed
@tyeth tyeth deleted the wifi_multi_esp32 branch July 23, 2024 18:09
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