Skip to content

Commit 87095f6

Browse files
Fixed MAC reverse byte order issue within the ESP32SPI library as it was originally echoing the MAC address in reverse byte order. Added portable MAC function call within WSGISERVER.PY example to properly echo MAC address when running example.
1 parent ea860b2 commit 87095f6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ def MAC_address(self): # pylint: disable=invalid-name
337337
if self._debug:
338338
print("MAC address")
339339
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b'\xFF'])
340-
return resp[0]
340+
new_resp = bytearray(resp[0])
341+
new_resp = reversed(new_resp)
342+
return new_resp
341343

342344
def start_scan_networks(self):
343345
"""Begin a scan of visible access points. Follow up with a call
@@ -759,4 +761,4 @@ def set_analog_write(self, pin, analog_value):
759761
resp = self._send_command_get_response(_SET_ANALOG_WRITE_CMD,
760762
((pin,), (value,)))
761763
if resp[0][0] != 1:
762-
raise RuntimeError("Failed to write to pin")
764+
raise RuntimeError("Failed to write to pin")

examples/server/esp32spi_wsgiserver.py

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
4040
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) # pylint: disable=line-too-long
4141

42+
print("MAC addr:", [hex(i) for i in esp.MAC_address])
43+
4244
"""Use below for Most Boards"""
4345
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
4446
"""Uncomment below for ItsyBitsy M4"""
@@ -212,4 +214,4 @@ def led_color(environ): # pylint: disable=unused-argument
212214
except (ValueError, RuntimeError) as e:
213215
print("Failed to update server, restarting ESP32\n", e)
214216
wifi.reset()
215-
continue
217+
continue

0 commit comments

Comments
 (0)