Skip to content

Commit

Permalink
return macaddress (#2477)
Browse files Browse the repository at this point in the history
* WiFi.macaddress() returns mac address

* change description

* return macaddress when WiFi mode is WIFI_MODE_NULL
  • Loading branch information
a-c-sreedhar-reddy authored and me-no-dev committed Mar 3, 2019
1 parent 84e458a commit 2ceab7c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 2ceab7c

Please sign in to comment.