@@ -752,15 +752,37 @@ def _tz_from_env(self, default: float = 0.0) -> float:
752752 return tz
753753
754754 def _socketpool_for_wifi (self ):
755+ """Return a SocketPool for whichever Wi-Fi backend is available.
756+ Works with native ESP32-S2/S3/C6 (wifi.radio) and ESP32SPI coprocessors.
757+ Some CP10 board wrappers may not expose .radio/.esp; in that case,
758+ try the native wifi.radio directly.
759+ """
755760 wm = getattr (self , "_wifi" , None )
756761 radio = getattr (wm , "radio" , None )
757762 esp = getattr (wm , "esp" , None ) or getattr (wm , "_esp" , None )
763+
764+ # CP10/MagTag fallback: wrapper didn't expose .radio/.esp -> use native radio
765+ if (radio is None ) and (esp is None ):
766+ try :
767+ import wifi as _wifi_mod # type: ignore
768+
769+ radio = getattr (_wifi_mod , "radio" , None )
770+ except Exception :
771+ radio = None
772+
758773 target = radio if (radio is not None ) else esp
759774 if target is None :
760775 raise RuntimeError ("No WiFi radio/esp found" )
761- from adafruit_connection_manager import get_radio_socketpool # lazy import for tests
762776
763- return get_radio_socketpool (target )
777+ # Prefer connection_manager helper, else direct SocketPool fallback
778+ try :
779+ from adafruit_connection_manager import get_radio_socketpool # lazy import
780+
781+ return get_radio_socketpool (target )
782+ except Exception :
783+ import socketpool # type: ignore
784+
785+ return socketpool .SocketPool (target )
764786
765787 def _wait_for_ready_optional (self , timeout : float = 10.0 , poll : float = 0.05 ) -> None :
766788 wm = getattr (self , "_wifi" , None )
0 commit comments