8000 ports/esp32/modnetwork: Fix setting MAC address of ethernet devices. · micropython/micropython@a2c2865 · GitHub
[go: up one dir, main page]

Skip to content

Commit a2c2865

Browse files
committed
ports/esp32/modnetwork: Fix setting MAC address of ethernet devices.
`esp_eth_ioctl(ETH_CMD_S_MAC_ADDR)` sets the MAC address of the hardware device, but we also need to notify the upper layers of the change so that e.g. DHCP work properly.
1 parent fb2a6be commit a2c2865

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ports/esp32/network_lan.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,12 @@ STATIC mp_obj_t lan_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
350350
if (bufinfo.len != 6) {
351351
mp_raise_ValueError(MP_ERROR_TEXT("invalid buffer length"));
352352
}
353-
esp_eth_ioctl(self->eth_handle, ETH_CMD_S_MAC_ADDR, bufinfo.buf);
353+
if (
354+
(esp_eth_ioctl(self->eth_handle, ETH_CMD_S_MAC_ADDR, bufinfo.buf) != ESP_OK) ||
355+
(esp_netif_set_mac(self->eth_netif, bufinfo.buf) != ESP_OK)
356+
) {
357+
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("failed setting MAC address"));
358+
}
354359
break;
355360
}
356361
default:

0 commit comments

Comments
 (0)
0