Skip to content

Conversation

@sylvioalves
Copy link
Contributor

Allows set the device macaddress.

net iface set_mac 1 aa:bb:cc:dd:ee:ff
wifi connect -s ssid -p password -k 1

Comment on lines 905 to 909
esp_err_t ret = esp_wifi_set_mac(WIFI_IF_STA, dev_data->mac_addr);

if (ret != ESP_OK) {
printk("Failed to set mac address: %d\n", ret);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we call

		memcpy(dev_data->mac_addr, config->mac_address.addr, 6);
		net_if_set_link_addr(esp32_wifi_iface, dev_data->mac_addr,
				     sizeof(dev_data->mac_addr), NET_LINK_ETHERNET);

after the esp_wifi_set_mac() has succeeded. Otherwise if the call fails, we have inconsistent mac address in upper net stack compared to esp32 driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I will update/polish this once the user confirms it works on his side. Thanks for the suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, let's update it now.

Allows set the device macaddress.

> net iface set_mac 1 aa:bb:cc:dd:ee:ff
> wifi connect -s ssid -p password -k 1

Signed-off-by: Sylvio Alves <[email protected]>
@sylvioalves sylvioalves force-pushed the feature/esp32-wifi-macaddr-l2 branch from 93f2f8c to e0b95bf Compare November 3, 2025 09:08
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

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.

2 participants