[RTT] Update CTS to auto-select test AP

Update CTS to select a test AP:
- Scan for APs
- Select the APs supporting IEEE 802.11mc
- Pick the AP with the highest RSSI

Bug: 74518964
Test: atest WifiRttTest (and pick the CTS test)
Change-Id: I6467c75eedcc8260703d2a99214154c9e888cce9
This commit is contained in:
Etan Cohen
2018-05-16 11:16:02 -07:00
parent b58779a4e1
commit 01d63b603e
2 changed files with 12 additions and 20 deletions

View File

@@ -43,10 +43,6 @@ import java.util.concurrent.TimeUnit;
public class TestBase extends AndroidTestCase {
protected static final String TAG = "WifiRttCtsTests";
// The SSID of the test AP which supports IEEE 802.11mc
// TODO b/74518964: finalize correct method to refer to an AP in the test lab
static final String SSID_OF_TEST_AP = "standalone_rtt";
// wait for Wi-Fi RTT to become available
private static final int WAIT_FOR_RTT_CHANGE_SECS = 10;
@@ -211,33 +207,30 @@ public class TestBase extends AndroidTestCase {
}
/**
* Start a scan and return the test AP with the specified SSID and which supports IEEE 802.11mc.
* If the AP is not found re-attempts the scan maxScanRetries times (i.e. total number of
* scans can be maxScanRetries + 1).
* Start a scan and return a test AP which supports IEEE 802.11mc and which has the highest
* RSSI. Will perform N (parameterized) scans and get the best AP across both scans.
*
* Returns null if test AP is not found in the specified number of scans.
*
* @param ssid The SSID of the test AP
* @param maxScanRetries Maximum number of scans retries (in addition to first scan).
* @param numScanRetries Maximum number of scans retries (in addition to first scan).
*/
protected ScanResult scanForTestAp(String ssid, int maxScanRetries)
protected ScanResult scanForTestAp(int numScanRetries)
throws InterruptedException {
int scanCount = 0;
while (scanCount <= maxScanRetries) {
ScanResult bestTestAp = null;
while (scanCount <= numScanRetries) {
for (ScanResult scanResult : scanAps()) {
if (!scanResult.is80211mcResponder()) {
continue;
}
if (!ssid.equals(scanResult.SSID)) {
continue;
if (bestTestAp == null || scanResult.level > bestTestAp.level) {
bestTestAp = scanResult;
}
return scanResult;
}
scanCount++;
}
return null;
return bestTestAp;
}
}

View File

@@ -34,8 +34,8 @@ import java.util.List;
* Wi-Fi RTT CTS test: range to all available Access Points which support IEEE 802.11mc.
*/
public class WifiRttTest extends TestBase {
// Max number of scan retries to do while searching for APs supporting IEEE 802.11mc
private static final int MAX_NUM_SCAN_RETRIES_SEARCHING_FOR_IEEE80211MC_AP = 2;
// Number of scans to do while searching for APs supporting IEEE 802.11mc
private static final int NUM_SCANS_SEARCHING_FOR_IEEE80211MC_AP = 2;
// Number of RTT measurements per AP
private static final int NUM_OF_RTT_ITERATIONS = 10;
@@ -63,8 +63,7 @@ public class WifiRttTest extends TestBase {
}
// Scan for IEEE 802.11mc supporting APs
ScanResult testAp = scanForTestAp(SSID_OF_TEST_AP,
MAX_NUM_SCAN_RETRIES_SEARCHING_FOR_IEEE80211MC_AP);
ScanResult testAp = scanForTestAp(NUM_SCANS_SEARCHING_FOR_IEEE80211MC_AP);
assertTrue("Cannot find test AP", testAp != null);
// Perform RTT operations