return macaddress (#2477)

* WiFi.macaddress() returns mac address

* change description

* return macaddress when WiFi mode is WIFI_MODE_NULL
This commit is contained in:
A C SREEDHAR REDDY 2019-03-03 20:18:30 +05:30 committed by Me No Dev
parent 84e458a9e1
commit 2ceab7c279

View File

@ -1,5 +1,5 @@
/*
ESP8266WiFiSTA.cpp - WiFi library for esp8266
WiFiSTA.cpp - WiFi library for esp32
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
@ -416,7 +416,10 @@ IPAddress WiFiSTAClass::localIP()
uint8_t* WiFiSTAClass::macAddress(uint8_t* mac)
{
if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){
esp_wifi_get_mac(WIFI_IF_STA, mac);
esp_wifi_get_mac(WIFI_IF_STA, mac);
}
else{
esp_read_mac(mac, ESP_MAC_WIFI_STA);
}
return mac;
}
@ -430,10 +433,11 @@ String WiFiSTAClass::macAddress(void)
uint8_t mac[6];
char macStr[18] = { 0 };
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
return String();
esp_read_mac(mac, ESP_MAC_WIFI_STA);
}
else{
esp_wifi_get_mac(WIFI_IF_STA, mac);
}
esp_wifi_get_mac(WIFI_IF_STA, mac);
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return String(macStr);
}