forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Athena getNetworks method (commaai#21597)
* add iwlist scan * return using athena * add lte * add last one too * unused * add release files * more compact * typo * remove debug code * different file * array * rebase mistake
- Loading branch information
Showing
7 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,3 +391,6 @@ def get_modem_version(self): | |
|
||
def initialize_hardware(self): | ||
pass | ||
|
||
def get_networks(self): | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,3 +94,6 @@ def get_modem_version(self): | |
|
||
def initialize_hardware(self): | ||
pass | ||
|
||
def get_networks(self): | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import subprocess | ||
|
||
|
||
def scan(interface="wlan0"): | ||
result = [] | ||
try: | ||
r = subprocess.check_output(["iwlist", interface, "scan"], encoding='utf8') | ||
|
||
mac = None | ||
for line in r.split('\n'): | ||
if "Address" in line: | ||
# Based on the adapter eithere a percentage or dBm is returned | ||
# Add previous network in case no dBm signal level was seen | ||
if mac is not None: | ||
result.append({"mac": mac}) | ||
mac = None | ||
|
||
mac = line.split(' ')[-1] | ||
elif "dBm" in line: | ||
try: | ||
level = line.split('Signal level=')[1] | ||
rss = int(level.split(' ')[0]) | ||
result.append({"mac": mac, "rss": rss}) | ||
mac = None | ||
except ValueError: | ||
continue | ||
|
||
# Add last network if no dBm was found | ||
if mac is not None: | ||
result.append({"mac": mac}) | ||
|
||
return result | ||
|
||
except Exception: | ||
return None |