Closed anecdata closed 2 years ago
Is there any benefit to returning a dictionary as opposed to a tuple of the two values?
Not particularly, I was just mimicking the return from network_data
, which is also a dictionary with an "ip_addr"
element. Readability vs. byte count? I don't have a strong opinion either way. At the next layer down (sockets), there is a commonly-used tuple for address
which is (host, port)
, but in that case host
is a string
like "localhost" or "127.0.0.1". In the present case, the "ip_addr"
value for both network data
and get_remote_data
is a bytes
. The only other return in the module that isn't just a single value is the return from scan_networks
, which is a list of dictionaries.
Expose NINA getRemoteData() function https://github.com/adafruit/nina-fw/blob/d73fe315cc7f9148a0918490d3b75430c8444bf7/main/CommandHandler.cpp#L779 This returns the IP address and port number of the remote host. Especially useful for UDP server.
Adafruit CircuitPython 7.2.0 on 2022-02-24; Adafruit PyPortal with samd51j20
UDP server code:Result:
CPython UDP client code: