SodaqMoja / Sodaq_nbIOT

Arduino library for the ublox NB-IoT modules
32 stars 16 forks source link

No demultiplexing by socket when receiving UDP data #5

Open akosladanyi opened 6 years ago

akosladanyi commented 6 years ago

The functions related to receiving UDP data (hasPendingUDPBytes, waitForUDPResponse, socketReceiveBytes) do not have a socket argument. This design looks a bit strange to me. Why did you choose it? Would you accept a patch which modifies these functions to receive a socket as parameter?

SodaqMoja commented 6 years ago

All UDP receive stuff are asynchronous, we don't know what will come in before it comes. Hence hasPendingUDPBytes, waitForUDPResponse, socketReceiveBytes do not have a parameter for specifying the socket. After there is something received, the packet that is returned by socketReceiveBytes() et al contains the number of the socket for the application to know where the data came from. So, multiple sockets are supported. (Also when sending, the application passes the number of socket to send to).

akosladanyi commented 6 years ago

...we don't know what will come in before it comes.

Well, you could call waitForUDPResponse for each socket with a short timeout.