@@ -545,14 +545,19 @@ def ip_address(self):
545
545
return self .network_data ["ip_addr" ]
546
546
547
547
@property
548
- def is_connected (self ):
548
+ def connected (self ):
549
549
"""Whether the ESP32 is connected to an access point"""
550
550
try :
551
551
return self .status == WL_CONNECTED
552
552
except OSError :
553
553
self .reset ()
554
554
return False
555
555
556
+ @property
557
+ def is_connected (self ):
558
+ """Whether the ESP32 is connected to an access point"""
559
+ return self .connected
560
+
556
561
@property
557
562
def ap_listening (self ):
558
563
"""Returns if the ESP32 is in access point mode and is listening for connections"""
@@ -568,10 +573,9 @@ def disconnect(self):
568
573
if resp [0 ][0 ] != 1 :
569
574
raise OSError ("Failed to disconnect" )
570
575
571
- def connect (self , secrets ):
572
- """Connect to an access point using a secrets dictionary
573
- that contains a 'ssid' and 'password' entry"""
574
- self .connect_AP (secrets ["ssid" ], secrets ["password" ])
576
+ def connect (self , ssid , password , timeout = 10 ):
577
+ """Connect to an access point with given name and password."""
578
+ self .connect_AP (ssid , password , timeout_s = timeout )
575
579
576
580
def connect_AP (self , ssid , password , timeout_s = 10 ): # pylint: disable=invalid-name
577
581
"""Connect to an access point with given name and password.
@@ -647,6 +651,11 @@ def create_AP(
647
651
raise ConnectionError ("Failed to create AP" , ssid )
648
652
raise OSError ("Unknown error 0x%02x" % stat )
649
653
654
+ @property
655
+ def ipv4_address (self ):
656
+ """IP address of the station when connected to an access point."""
657
+ return self .pretty_ip (self .ip_address )
658
+
650
659
def pretty_ip (self , ip ): # pylint: disable=no-self-use, invalid-name
651
660
"""Converts a bytearray IP address to a dotted-quad string for printing"""
652
661
return "%d.%d.%d.%d" % (ip [0 ], ip [1 ], ip [2 ], ip [3 ])
0 commit comments