-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Mac address change with initVariant() lost after ESP.restart() #3024
Comments
@torntrousers did you test setting with the following: |
No feedback in over a month, closing. |
This is still broken on the latest code in git. The comment above about WiFi.macAddress(mac); |
The mac setter/getters in the core are a thin wrapper around Espressif's SDK functions wifi_s|get_macaddr(). From the SDK doc 2c esp8266 nonos sdk api reference, these functions are supposed to be called from user_init() on bootup, and there is no mention of storing the values in flash along with the wifi credentials et al. |
There is clearly a bug somewhere here though. Would you reopen this and I can put give a simple sketch that shows the problem. |
Open a new issue, fill everything out, include the sketch and explanation, and I'll take a look. |
Writing the minimal sketch for you I found out more what the issue is. It still seems like a bug to me but now I understand I wont bother raising a new issue. I will explain here for posterity... The reason is that wifi_set_macaddr in initVariant only seems to work correctly setting the mac on the interface if the Wifi mode is using that interface. As initVariant runs before setup() the wifi mode when initVariant runs is the previously used mode. So if a sketch sets the mode to WIFI_STA then the ESP restarts the mode will still be WIFI_STA when initVariant runs so wifi_set_macaddr(SOFTAP_IF, &mac[0]); doesn't appear to work and the AP MAC will remain the default. The reason erasing the flash appears to fix it is because that sets the default wifi mode which is WIFI_AP_STA - so using both the AP and STA interfaces. Here's and example:
|
I need to change the AP mac address so use the approach from #1221:
And that works fine, however then doing an ESP.restart() and that mac change is forgotten and it reverts back to the default mac address.
Is there some way to get that initVariant() code to run on the restart too?
(I'm using the latest Github code)
The text was updated successfully, but these errors were encountered: