When does "wifi_on_boot" happen?
-
Hi all!
I'm fiddling with a kind of "smart provisioning"...
What's working:- Setting my LoPy1 to AP mode
- Having a tiny web server, showing of a page with the surrounding wifi networks
- A simple form for giving the wanted ssid and password
Then I save the ssid and password:
pycom.wifi_ssid_sta(set_ssid) pycom.wifi_pwd_sta(set_pwd) pycom.wifi_mode_on_boot(WLAN.STA) pycom.wifi_on_boot(True)and reset the device with machine.reset().
In my boot.py I check if wifi_on_boot is True and set the depending main file with machine.main('main_wifi.py').
In main_wifi.py I simply dofrom network import WLAN import time import machine wlan = WLAN() time.sleep(2) try: while not wlan.isconnected(): time.sleep_ms(50) print(wlan.ifconfig()) rtc = RTC() rtc.ntp_sync("de.pool.ntp.org", 3600) print(rtc.now()) except: print("reboot in 5s") time.sleep(5) machine.reset() pycom.rgbled(0x00FF00) print("Everything is running fine")But it will never connect. It allways runs into a timeout and reboots. SSID and Password are set correct. Is this only working with Pybytes?
I run on the latest firmware but with deactivated Pybytes support.Cheers,
Thomas -
Ok, I can answer my questions by myself now ;-)
Everything works now like expected. I just reset my home AP, after I recognized, that my mobile is also not connecting to my wifi network.
Sometimes things are so stupid... ;-) -
To clarify, the
pycom.wifi_on_boot()sets the wifi settings even before theboot.py. You can use the accompanying functions from the API (https://docs.pycom.io/firmwareapi/pycom/pycom/#boot-methods) to set the SSID, AP or STA mode, and the password. Next to that, the method is only activated after resetting the module (meaning you will not see the behaviour directly after changing the settings, but only after a reset)Best,
Gijs -
-
That is a good point! I'll add it to the FW to-do list.
Though I do not see any issues arise from the parameter missing directly. By default, the on-board antenna is selected for development modules, which you are able to change on the fly if needed. For OEM modules, there's only one option as there's only one antenna port
-
which you are able to change on the fly if needed. For OEM modules, there's only one option as there's only one antenna port
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login