Skip to content

Commit

Permalink
Update tools, add support for channel/frequency to WiFiBackendHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
mar-v-in committed Sep 14, 2015
1 parent 8b2a8eb commit 98062ac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
6 changes: 3 additions & 3 deletions unifiednlp-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ buildscript {
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

version = '1.3.3'
version = '1.4.0'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
}
Expand Down
4 changes: 0 additions & 4 deletions unifiednlp-api/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
GROUP=org.microg
POM_ARTIFACT_ID=unifiednlp-api
VERSION_NAME=1.3.3

POM_NAME=µg UnifiedNlp API
POM_DESCRIPTION=API interfaces and helpers to create backends for UnifiedNlp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private synchronized boolean loadWiFis() {
List<ScanResult> scanResults = wifiManager.getScanResults();
for (ScanResult scanResult : scanResults) {
if (ignoreNomap && scanResult.SSID.toLowerCase(Locale.US).endsWith("_nomap")) continue;
wiFis.add(new WiFi(scanResult.BSSID, scanResult.level));
wiFis.add(new WiFi(scanResult.BSSID, scanResult.level, frequencyToChannel(scanResult.frequency), scanResult.frequency));
}
if (state == State.DISABLING)
state = State.DISABLED;
Expand All @@ -145,6 +145,17 @@ private synchronized boolean loadWiFis() {
}
}

@SuppressWarnings("MagicNumber")
private static int frequencyToChannel(int freq) {
if (freq >= 2412 && freq <= 2484) {
return (freq - 2412) / 5 + 1;
} else if (freq >= 5170 && freq <= 5825) {
return (freq - 5170) / 5 + 34;
} else {
return -1;
}
}

/**
* @return the latest scan result.
*/
Expand Down Expand Up @@ -172,6 +183,8 @@ public interface Listener {
public static class WiFi {
private final String bssid;
private final int rssi;
private final int channel;
private final int frequency;

public String getBssid() {
return bssid;
Expand All @@ -181,9 +194,23 @@ public int getRssi() {
return rssi;
}

public int getChannel() {
return channel;
}

public int getFrequency() {
return frequency;
}

public WiFi(String bssid, int rssi) {
this(bssid, rssi, -1, -1);
}

public WiFi(String bssid, int rssi, Integer channel, Integer frequency) {
this.bssid = wellFormedMac(bssid);
this.rssi = rssi;
this.channel = channel;
this.frequency = frequency;
}
}

Expand Down

0 comments on commit 98062ac

Please sign in to comment.