From 2885a4d66d8146fc6b7a7dbb17538839994e7963 Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Thu, 6 Jun 2024 15:07:16 -0700 Subject: [PATCH] Fix inconsistencies: - Add ipv4_address to match native wifi and esp32spi - Fix recvfrom_into to return the correct address info --- adafruit_wiznet5k/adafruit_wiznet5k.py | 10 ++++++++++ adafruit_wiznet5k/adafruit_wiznet5k_socketpool.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/adafruit_wiznet5k/adafruit_wiznet5k.py b/adafruit_wiznet5k/adafruit_wiznet5k.py index 7c5a44c..04d94b6 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k.py @@ -336,6 +336,16 @@ def ip_address(self) -> bytes: """ return self._read(_REG_SIPR[self._chip_type], 0x00, 4) + @property + def ipv4_address(self) -> bytes: + """ + Configured IP address for the WIZnet Ethernet hardware. + + :return str: The IP address (a string of the form '255.255.255.255') + """ + return self.pretty_ip(self.ip_address) + + @staticmethod def pretty_ip(ipv4: bytes) -> str: """ diff --git a/adafruit_wiznet5k/adafruit_wiznet5k_socketpool.py b/adafruit_wiznet5k/adafruit_wiznet5k_socketpool.py index d68452f..6694bef 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k_socketpool.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k_socketpool.py @@ -655,8 +655,8 @@ def recvfrom_into( # pylint: disable=unused-argument return ( self.recv_into(buffer, nbytes), ( - self._interface.remote_ip(self._socknum), - self._interface.remote_port(self._socknum), + self._interface.pretty_ip(self._interface.udp_from_ip[self._socknum]), + self._interface.udp_from_port[self._socknum], ), )