Commit 2ceab7c2 authored by A C SREEDHAR REDDY's avatar A C SREEDHAR REDDY Committed by Me No Dev

return macaddress (#2477)

* WiFi.macaddress() returns mac address

* change description

* return macaddress when WiFi mode is WIFI_MODE_NULL
parent 84e458a9
/* /*
ESP8266WiFiSTA.cpp - WiFi library for esp8266 WiFiSTA.cpp - WiFi library for esp32
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment. This file is part of the esp8266 core for Arduino environment.
...@@ -418,6 +418,9 @@ uint8_t* WiFiSTAClass::macAddress(uint8_t* mac) ...@@ -418,6 +418,9 @@ uint8_t* WiFiSTAClass::macAddress(uint8_t* mac)
if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){ 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; return mac;
} }
...@@ -430,10 +433,11 @@ String WiFiSTAClass::macAddress(void) ...@@ -430,10 +433,11 @@ String WiFiSTAClass::macAddress(void)
uint8_t mac[6]; uint8_t mac[6];
char macStr[18] = { 0 }; char macStr[18] = { 0 };
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ 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]); sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return String(macStr); return String(macStr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment