Skip to content

Commit a589e81

Browse files
committed
ad mac_address and fix connect per discussion. connect with secrets dict, ssid, password, and ssid-only (open) all work as before.
1 parent 8349d77 commit a589e81

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,12 @@ def MAC_address(self): # pylint: disable=invalid-name
372372
@property
373373
def MAC_address_actual(self): # pylint: disable=invalid-name
374374
"""A bytearray containing the actual MAC address of the ESP32"""
375-
if self._debug:
376-
print("MAC address")
377-
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b"\xFF"])
378-
new_resp = bytearray(resp[0])
379-
new_resp = reversed(new_resp)
380-
return new_resp
375+
return bytearray(reversed(self.MAC_address))
376+
377+
@property
378+
def mac_address(self):
379+
"""A bytes containing the actual MAC address of the ESP32"""
380+
return bytes(reversed(self.MAC_address))
381381

382382
def start_scan_networks(self):
383383
"""Begin a scan of visible access points. Follow up with a call
@@ -573,8 +573,10 @@ def disconnect(self):
573573
if resp[0][0] != 1:
574574
raise OSError("Failed to disconnect")
575575

576-
def connect(self, ssid, password, timeout=10):
576+
def connect(self, ssid, password=None, timeout=10):
577577
"""Connect to an access point with given name and password."""
578+
if isinstance(ssid, dict): # secrets
579+
ssid, password = ssid["ssid"], ssid["password"]
578580
self.connect_AP(ssid, password, timeout_s=timeout)
579581

580582
def connect_AP(self, ssid, password, timeout_s=10): # pylint: disable=invalid-name

0 commit comments

Comments
 (0)