Skip to content

Commit 83fe4b3

Browse files
authored
Merge pull request #75 from anecdata/bssid_channel
Expose handler for BSSID, and wi-fi scan handlers for BSSID & channel.
2 parents 424c489 + b6e5743 commit 83fe4b3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
_GET_IPADDR_CMD = const(0x21)
6363
_GET_MACADDR_CMD = const(0x22)
6464
_GET_CURR_SSID_CMD = const(0x23)
65+
_GET_CURR_BSSID_CMD = const(0x24)
6566
_GET_CURR_RSSI_CMD = const(0x25)
6667
_GET_CURR_ENCT_CMD = const(0x26)
6768

@@ -83,6 +84,8 @@
8384
_START_SCAN_NETWORKS = const(0x36)
8485
_GET_FW_VERSION_CMD = const(0x37)
8586
_GET_TIME = const(0x3B)
87+
_GET_IDX_BSSID_CMD = const(0x3C)
88+
_GET_IDX_CHAN_CMD = const(0x3D)
8689
_PING_CMD = const(0x3E)
8790

8891
_SEND_DATA_TCP_CMD = const(0x44)
@@ -351,7 +354,7 @@ def start_scan_networks(self):
351354

352355
def get_scan_networks(self):
353356
"""The results of the latest SSID scan. Returns a list of dictionaries with
354-
'ssid', 'rssi' and 'encryption' entries, one for each AP found"""
357+
'ssid', 'rssi', 'encryption', bssid, and channel entries, one for each AP found"""
355358
self._send_command(_SCAN_NETWORKS)
356359
names = self._wait_response_cmd(_SCAN_NETWORKS)
357360
#print("SSID names:", names)
@@ -362,6 +365,10 @@ def get_scan_networks(self):
362365
a_p['rssi'] = struct.unpack('<i', rssi)[0]
363366
encr = self._send_command_get_response(_GET_IDX_ENCT_CMD, ((i,),))[0]
364367
a_p['encryption'] = encr[0]
368+
bssid = self._send_command_get_response(_GET_IDX_BSSID_CMD, ((i,),))[0]
369+
a_p['bssid'] = bssid
370+
chan = self._send_command_get_response(_GET_IDX_CHAN_CMD, ((i,),))[0]
371+
a_p['channel'] = chan[0]
365372
APs.append(a_p)
366373
return APs
367374

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

441+
@property
442+
def bssid(self):
443+
"""The MAC-formatted service set ID of the access point we're connected to"""
444+
resp = self._send_command_get_response(_GET_CURR_BSSID_CMD, [b'\xFF'])
445+
return resp[0]
446+
434447
@property
435448
def rssi(self):
436449
"""The receiving signal strength indicator for the access point we're

0 commit comments

Comments
 (0)