kellerkindt / w5500

W5500 ethernet module driver written in rust
Apache License 2.0
40 stars 18 forks source link

When `Device.connect` is not called, Udp socket is not being opened #46

Closed elpiel closed 1 year ago

elpiel commented 1 year ago

If you want to use the UdpSocket directly without first connecting to a given remote, then send_to will not open the socket. From the data sheet it seems that this is needed to initialize the TX & RX buffers and other stuff which makes the UdpSocket unusable if you don't first connect to a remote.

Fix

~This can easily be fixed by opening the socket when DeviceRefMut.socket is called to make sure that the given socket is always ready to be used.~ This is not a good approach due to the Multicasting Udp mode. Instead, introduce a new error and make sure to return it if the socket is not opened by checking it's status (it should be Udp).