Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MAC reverse byte order issue within the ESP32SPI library as it … #66

Open
wants to merge 5 commits into
base: master
from
@@ -339,6 +339,16 @@ def MAC_address(self): # pylint: disable=invalid-name
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b'\xFF'])
return resp[0]

@property
def MAC_address_actual(self): # pylint: disable=invalid-name
"""A bytearray containing the actual MAC address of the ESP32"""
if self._debug:
print("MAC address")
resp = self._send_command_get_response(_GET_MACADDR_CMD, [b'\xFF'])
new_resp = bytearray(resp[0])
This conversation was marked as resolved by ladyada

This comment has been minimized.

Copy link
@ladyada

ladyada Aug 21, 2019

Member

check it! you can turn these three lines into one line of code by nesting the commands. please try it!

This comment has been minimized.

Copy link
@mytechnotalent

mytechnotalent Aug 21, 2019

Author

@ladyada not sure what you are asking as the other functions follow the same format in line 337, 338. Lines 337, 338, 339 are part of the original code so not sure where the efficiency is here.

This comment has been minimized.

Copy link
@ladyada

ladyada Aug 21, 2019

Member

its not required, but sometimes people like to shorten it. how are you verifying the MAC address - with a router or...?

This comment has been minimized.

Copy link
@mytechnotalent

mytechnotalent Aug 21, 2019

Author

@ladyada understood but the rest of the functions follow that convention so wanted to stay consistent for style as that would really freak me out seeing every other function in one coding style and this one in another format UBER OCD HERE! My home router I only allow devices to which I specially add their MAC. When I reversed the byte order I was successfully able to connect. To confirm I also fired up my Kali box and did a netdiscover and clearly verified the reverse order sequence and the nice Expressif Inc. Vendor tag. In addition new_resp was necessary as the resp is an immutable bytestring. I therefore needed to create a mutable bytestring (new_resp) in order to achieve the reverse bit order or little endian format.

This comment has been minimized.

Copy link
@ladyada

ladyada Aug 21, 2019

Member

oki!

new_resp = reversed(new_resp)
return new_resp

def start_scan_networks(self):
"""Begin a scan of visible access points. Follow up with a call
to 'get_scan_networks' for response"""
@@ -39,6 +39,9 @@
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) # pylint: disable=line-too-long

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

"""Use below for Most Boards"""
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
"""Uncomment below for ItsyBitsy M4"""
@@ -213,3 +216,4 @@ def led_color(environ): # pylint: disable=unused-argument
print("Failed to update server, restarting ESP32\n", e)
wifi.reset()
continue

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.