pico-extras
pico-extras copied to clipboard
Add wifi_settings_connect library
This Pico library provides a way to store WiFi hotspot details in Flash and connect automatically, avoiding the need to specify build-time flags such as WIFI_SSID and WIFI_PASSWORD, as is required for all of the Pico W WiFi examples in the pico-examples repo.
The library loads WiFi settings from a configurable Flash location. The default is 16kb before the end of Flash, i.e. 0x101fc000 for Pico, 0x0103fc000 for Pico 2. This avoids locations already used for Bluetooth and for the RP2350-E10 workaround.
The library searches for hotspots using cyw43 API functions, and, if a known hotspot is found, uses the details from Flash to connect to it. It will also automatically reconnect if the connection is lost.
This part of the library is useful by itself, and the documentation should also be self-contained, though in some places it does refer to the pico-wifi-settings homepage at https://github.com/jwhitham/pico-wifi-settings where a larger version of the library can be found. Additional features in the full library include support for OTA updates of WiFi settings and firmware, and a setup application for creating the WiFi settings file.
There is a second PR for pico-playground which adds a usage example: https://github.com/raspberrypi/pico-playground/pull/55
FYI I've changed the base-branch on both your PRs to develop.
@peterharperuk and @kilograham If both BT (see https://github.com/raspberrypi/pico-sdk/pull/2412) and now this library are using "reserved space" at the end of Flash to store persistent settings, I wonder if there could / should be some mechanism in pico-sdk so that if the BT or wifi_settings_connect libraries are being used, those libraries could indicate to the SDK build-system that N bytes at the end of Flash are reserved, so that the sdk doesn't create huge binaries that would inadvertently overwrite these persistent settings? :thinking: (I have no idea how such a mechanism would work, but if you think it's a good idea I guess I could create a pico-sdk issue)
https://github.com/raspberrypi/pico-sdk/issues/1378
Thank you for looking at this PR. I have made some changes to the upstream library to improve configurability and avoid a conflict with the Bluetooth library. I have also made the documentation more self-contained. Please could you look at it again? Thanks.
Thanks for responding to all my comments; your speed of updates has been very commendable :+1:
I don't want to give you false hopes though, so I probably ought to let you know that whilst I "help out" by commenting on issues and PRs in pico-sdk, pico-extras, etc., it's not my call to decide which PRs get merged or not.