Skip to content

Commit 3fd6a12

Browse files
Fixed MAC reverse byte order by adding new function to the ESP32SPI library calling the actual MAC address and providing a usage of the function in the webserver code within WSGISERVER.
1 parent ec97d6b commit 3fd6a12

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ def firmware_version(self):
333333

334334
@property
335335
def MAC_address(self): # pylint: disable=invalid-name
336+
"""A bytearray containing the MAC address of the ESP32"""
337+
if self._debug:
338+
print("MAC address")
339+
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b'\xFF'])
340+
return resp[0]
341+
342+
@property
343+
def MAC_address_actual(self): # pylint: disable=invalid-name
336344
"""A bytearray containing the MAC address of the ESP32"""
337345
if self._debug:
338346
print("MAC address")
@@ -761,5 +769,4 @@ def set_analog_write(self, pin, analog_value):
761769
resp = self._send_command_get_response(_SET_ANALOG_WRITE_CMD,
762770
((pin,), (value,)))
763771
if resp[0][0] != 1:
764-
raise RuntimeError("Failed to write to pin")
765-
772+
raise RuntimeError("Failed to write to pin")

examples/server/esp32spi_wsgiserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) # pylint: disable=line-too-long
4141

4242
print("MAC addr:", [hex(i) for i in esp.MAC_address])
43+
print("MAC addr actual:", [hex(i) for i in esp.MAC_address_actual])
4344

4445
"""Use below for Most Boards"""
4546
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
@@ -214,5 +215,4 @@ def led_color(environ): # pylint: disable=unused-argument
214215
except (ValueError, RuntimeError) as e:
215216
print("Failed to update server, restarting ESP32\n", e)
216217
wifi.reset()
217-
continue
218-
218+
continue

0 commit comments

Comments
 (0)