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).
If you want to use the UdpSocket directly without first connecting to a given remote, then
send_to
will notopen
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 firstconnect
to a remote.Fix
~This can easily be fixed by
open
ing the socket whenDeviceRefMut.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 beUdp
).