Skip to content

Commit 8349d77

Browse files
committed
Fully deprecate secrets and improve native wifi API compatibility.
1 parent a48d516 commit 8349d77

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,19 @@ def ip_address(self):
545545
return self.network_data["ip_addr"]
546546

547547
@property
548-
def is_connected(self):
548+
def connected(self):
549549
"""Whether the ESP32 is connected to an access point"""
550550
try:
551551
return self.status == WL_CONNECTED
552552
except OSError:
553553
self.reset()
554554
return False
555555

556+
@property
557+
def is_connected(self):
558+
"""Whether the ESP32 is connected to an access point"""
559+
return self.connected
560+
556561
@property
557562
def ap_listening(self):
558563
"""Returns if the ESP32 is in access point mode and is listening for connections"""
@@ -568,10 +573,9 @@ def disconnect(self):
568573
if resp[0][0] != 1:
569574
raise OSError("Failed to disconnect")
570575

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)
575579

576580
def connect_AP(self, ssid, password, timeout_s=10): # pylint: disable=invalid-name
577581
"""Connect to an access point with given name and password.
@@ -647,6 +651,11 @@ def create_AP(
647651
raise ConnectionError("Failed to create AP", ssid)
648652
raise OSError("Unknown error 0x%02x" % stat)
649653

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+
650659
def pretty_ip(self, ip): # pylint: disable=no-self-use, invalid-name
651660
"""Converts a bytearray IP address to a dotted-quad string for printing"""
652661
return "%d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3])

0 commit comments

Comments
 (0)