Skip to content

Commit fbbe977

Browse files
authored
Merge pull request #66 from mytechnotalent/ESP32-MAC-order-library-fix
Fixed MAC reverse byte order issue within the ESP32SPI library as it …
2 parents f523b23 + 00b6b95 commit fbbe977

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

100644100755
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@ def MAC_address(self): # pylint: disable=invalid-name
354354
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b'\xFF'])
355355
return resp[0]
356356

357+
@property
358+
def MAC_address_actual(self): # pylint: disable=invalid-name
359+
"""A bytearray containing the actual MAC address of the ESP32"""
360+
if self._debug:
361+
print("MAC address")
362+
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b'\xFF'])
363+
new_resp = bytearray(resp[0])
364+
new_resp = reversed(new_resp)
365+
return new_resp
366+
357367
def start_scan_networks(self):
358368
"""Begin a scan of visible access points. Follow up with a call
359369
to 'get_scan_networks' for response"""

examples/server/esp32spi_wsgiserver.py

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
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+
print("MAC addr actual:", [hex(i) for i in esp.MAC_address_actual])
44+
4245
"""Use below for Most Boards"""
4346
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
4447
"""Uncomment below for ItsyBitsy M4"""
@@ -213,3 +216,4 @@ def led_color(environ): # pylint: disable=unused-argument
213216
print("Failed to update server, restarting ESP32\n", e)
214217
wifi.reset()
215218
continue
219+

0 commit comments

Comments
 (0)