Skip to content
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

WiFi.macAddress(uint8_t mac) doesn't work anymore to retrieve mac, it returns 00:00:00:00:00:00 - Network.macAddress does perform as expected. #9509

Open
1 task done
tyeth opened this issue Apr 14, 2024 · 9 comments
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@tyeth
Copy link
Contributor

tyeth commented Apr 14, 2024

Board

ESP32

Device Description

Hardware Configuration

Version

latest master (checkout manually)

IDE Name

Operating System

Flash frequency

PSRAM enabled

yes

Upload speed

Description

Sketch

-

Debug Message

-

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@tyeth tyeth added the Status: Awaiting triage Issue is waiting for triage label Apr 14, 2024
@tyeth
Copy link
Contributor Author

tyeth commented Apr 14, 2024

@me-no-dev think this is not expected

@tyeth tyeth changed the title WiFi.macAddress doesn't work anymore to retrieve mac, it returns 00:00:00:00:00:00 - Network.macAddress does perform as expected. WiFi.macAddress(uint8_t mac) doesn't work anymore to retrieve mac, it returns 00:00:00:00:00:00 - Network.macAddress does perform as expected. Apr 14, 2024
@JAndrassy
Copy link
Contributor

JAndrassy commented Apr 14, 2024

I can't reproduce it. It returns the MAC address in my test with 3.0.0-rc1

@tyeth
Copy link
Contributor Author

tyeth commented Apr 14, 2024

Oh strange, thanks, I'll investigate further.
I should mention that we were originally accessing via the WiFiClientSecure import, but I've had to add an import for WiFi.h as a result of #9496
If you want to try the full project it's here:
https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
You'll need two extra dependencies for https://github.com/milesburton/Arduino-Temperature-Control-Library and https://github.com/PaulStoffregen/OneWire depending if arduino ide or platformio.

@tyeth
Copy link
Contributor Author

tyeth commented Apr 14, 2024

Strictly speaking I'm on this branch with one commit to make the actions on the main adafruit repo pass (tested on my local using platformio, but action passed all builds except C3 due to size - known internal issue):
https://github.com/tyeth/Adafruit_Wippersnapper_Arduino/tree/add-VL53L4CD

The end of the changeset contains the relevant change:
tyeth/Adafruit_Wippersnapper_Arduino@656f32d#diff-c32ef9a1c2bfd1bc9a7cb064310e7433975912191664669be9dba5fbd743a823

@me-no-dev
Copy link
Member

since the network refactoring, macAdress comes from the interface and you are asking for it before you have started that interface. Network.macAddress gives you the base MAC of the ESP chip. From it are derived STA, AP and ETH MACs

@tyeth
Copy link
Contributor Author

tyeth commented Apr 14, 2024

Thank you so much for the explanation!

So effectively it's not set on either of those three interfaces until they connect or are brought up, does that sound right?
Then presumably just scanning with WiFi for available networks would not be sufficient to populate either of the WiFi interface (or specifically STA) Mac address properties?

@me-no-dev
Copy link
Member

WiFi Scan will enable STA, so it should give you the MAC after it runs. You can get the MAC right after the proper WiFi.mode() also. No need to connect to anything.

By far the best way is to use the new network interfaces:

// Get the base MAC of the ESP chip (works always)
Network.macAddress(mac);

// Get the MAC address of WiFi STA (must first start interface)
WiFi.STA.begin();
WiFi.STA.macAddress(mac);

// Get the MAC address of WiFi AP (must first start interface)
WiFi.AP.begin();
WiFi.AP.macAddress(mac);

// Get the MAC address of ETH (must first start interface)
ETH.begin();
ETH.macAddress(mac);

@JAndrassy
Copy link
Contributor

off topic: it would be nice if the mac in the examples above could be of MacAddress type

@me-no-dev
Copy link
Member

@JAndrassy yup. on the way also :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

3 participants