Skip to content

Expose handler for BSSID, and wi-fi scan handlers for BSSID & channel. #75

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

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion adafruit_esp32spi/adafruit_esp32spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
_GET_IPADDR_CMD = const(0x21)
_GET_MACADDR_CMD = const(0x22)
_GET_CURR_SSID_CMD = const(0x23)
_GET_CURR_BSSID_CMD = const(0x24)
_GET_CURR_RSSI_CMD = const(0x25)
_GET_CURR_ENCT_CMD = const(0x26)

Expand All @@ -83,6 +84,8 @@
_START_SCAN_NETWORKS = const(0x36)
_GET_FW_VERSION_CMD = const(0x37)
_GET_TIME = const(0x3B)
_GET_IDX_BSSID_CMD = const(0x3C)
_GET_IDX_CHAN_CMD = const(0x3D)
_PING_CMD = const(0x3E)

_SEND_DATA_TCP_CMD = const(0x44)
Expand Down Expand Up @@ -351,7 +354,7 @@ def start_scan_networks(self):

def get_scan_networks(self):
"""The results of the latest SSID scan. Returns a list of dictionaries with
'ssid', 'rssi' and 'encryption' entries, one for each AP found"""
'ssid', 'rssi', 'encryption', bssid, and channel entries, one for each AP found"""
self._send_command(_SCAN_NETWORKS)
names = self._wait_response_cmd(_SCAN_NETWORKS)
#print("SSID names:", names)
Expand All @@ -362,6 +365,10 @@ def get_scan_networks(self):
a_p['rssi'] = struct.unpack('<i', rssi)[0]
encr = self._send_command_get_response(_GET_IDX_ENCT_CMD, ((i,),))[0]
a_p['encryption'] = encr[0]
bssid = self._send_command_get_response(_GET_IDX_BSSID_CMD, ((i,),))[0]
a_p['bssid'] = bssid
chan = self._send_command_get_response(_GET_IDX_CHAN_CMD, ((i,),))[0]
a_p['channel'] = chan[0]
APs.append(a_p)
return APs

Expand Down Expand Up @@ -431,6 +438,12 @@ def ssid(self):
resp = self._send_command_get_response(_GET_CURR_SSID_CMD, [b'\xFF'])
return resp[0]

@property
def bssid(self):
"""The MAC-formatted service set ID of the access point we're connected to"""
resp = self._send_command_get_response(_GET_CURR_BSSID_CMD, [b'\xFF'])
return resp[0]

@property
def rssi(self):
"""The receiving signal strength indicator for the access point we're
Expand Down