Skip to content

return macaddress #2477

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 3 commits into from
Mar 3, 2019
Merged

return macaddress #2477

merged 3 commits into from
Mar 3, 2019

Conversation

a-c-sreedhar-reddy
Copy link
Contributor

No description provided.

@me-no-dev
Copy link
Member

why? Please argument your changes :)

@a-c-sreedhar-reddy
Copy link
Contributor Author

WiFi.macaddress() returns NULL string when WiFi is not initialized (WiFi.begin()). This change returns macaddress irrespective of WiFi mode.

@atanisoft
Copy link
Collaborator

It will return a value if you call WiFi.mode() prior to calling the Mac address function.

I agree that it isn't ideal though, perhaps in the method it can check the wifi state and if it is not on it can call your method instead?

@a-c-sreedhar-reddy
Copy link
Contributor Author

But what is the use of calling WiFi.mode() when the mac-address is same for any WiFi state.

@atanisoft
Copy link
Collaborator

But what is the use of calling WiFi.mode() when the mac-address is same for any WiFi state.
Agreed, it seems to be a bit of a hack to set the mode prior to calling various functions which don't change based on the mode. I'd suggest the following though:

    if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){
        esp_wifi_get_mac(WIFI_IF_STA, mac);
    }else {
        esp_read_mac(mac, ESP_MAC_WIFI_STA);
    }

This way if the mode has been set it will use the first call and if it hasn't it can use the new call that you have provided. There are a few other places where mode is used and there may be a similar IDF function that will work suitably in the case where mode is null.

the only time I'd expect mode to be null is if WiFi has been turned off.

@a-c-sreedhar-reddy
Copy link
Contributor Author

I updated the changes

@me-no-dev me-no-dev merged commit 2ceab7c into espressif:master Mar 3, 2019
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.

3 participants