-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Description
Port, board and/or hardware
stm32 on Portenta H7 + Vision Shield ETH
MicroPython version
MicroPython v1.23.0 on 2024-06-02; Arduino Portenta H7 with STM32H747
Reproduction
import network
import socket
import pyb
# Initialize the LAN interface with PHY parameters
lan = network.LAN()
lan.config(trace=8, low_power=False)
lan.ifconfig('dhcp')
# Activate the LAN interface
lan.active(True)
print("MAC Address:", lan.config("mac").hex())
# Wait until the link is up
while not lan.isconnected():
pass
print("Network configuration:", lan.ifconfig())
# Get the IP address of www.google.com
try:
ip_address = socket.getaddrinfo('www.google.com', 80)[0][-1][0]
print("IP address of www.google.com:", ip_address)
except Exception as e:
print("Error:", e)
Expected behaviour
We should get the DHCP IP address.
Observed behaviour
15:27:36.010 -> Traceback (most recent call last):
15:27:36.010 -> File "main.py", line 9, in <module>
15:27:36.010 -> OSError: timeout waiting for DHCP to get IP address
15:27:37.495 -> MicroPython v1.23.0 on 2024-06-02; Arduino Portenta H7 with STM32H747
15:27:37.529 -> Type "help()" for more information.
15:27:37.529 -> >>>
Additional Information
I actually tried with setting a static IP instead, like this:
lan.ifconfig(('192.168.10.231', '255.255.255.0', '192.168.10.1', '8.8.8.8'))
And somehow it gets the DHCP lease successfully, but not using the specified IP.
It also works if I just call: lan.ifconfig()
but it does not work with: lan.ifconfig('dhcp')
15:39:14.146 -> File "main.py", line 8, in <module>
15:39:14.204 -> OSError: timeout waiting for DHCP to get IP address
In OpenMV v4.5.9
this trick does not work, I could not use network.LAN
there at all. CC @kwagyeman, not sure what is different, since the MP version is the same 🙁
Can it be because of the MAC address? I see a generic one being assigned (02:37:47:12:32:bb
).
This should be in another issue, but it would be nice to be able to set the MAC address:
mac_bytes = b'\xA8\x61\x0A\xAE\x44\xE0'
network.LAN.config(trace=8, low_power=False, mac=mac_bytes)
Code of Conduct
Yes, I agree