Android Wifi Roaming Through Ap With Same Ssid
I saw that Android system has a bad behavior with Wifi roaming. We have a Wifi centralized network with many AP with a signle SSID. The Adroid Phones wont roams seamlessly. An Andr
Solution 1:
You cannot do this as you describe. A client cannot determine the state of the TCP connection on it's own. Your network must also move the communication channel from one AP to another. This can be done with the right network controllers.
Also, you should look at IEEE 802.11k - https://en.wikipedia.org/wiki/IEEE_802.11k-2008
Solution 2:
Add below permissions;
<uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE" /><uses-permissionandroid:name="android.permission.CHANGE_WIFI_STATE" />
Register for below intent;
privateWifiBroadcastReceiverwifiBroadcastReceiver=newWifiBroadcastReceiver();
Then in routine;
registerReceiver(wifiBroadcastReceiver, newIntentFilter("android.net.wifi.SCAN_RESULTS"));
Use the below class to change the reassociation;
publicclassWifiBroadcastReceiverextendsBroadcastReceiver {
privateWiFiManagermanager=null;//set the value in constructorprivateWifiConfigurationconnectedConfiguration=null;//set the value in constructorprivateint connectedNetId;
privatevoidupdateConnectedConfiguration(String ssid) {
configs = manager.getConfiguredNetworks();
intnid=0;
for (WifiConfiguration cnf : configs) {
if (cnf.SSID.substring(1, cnf.SSID.length() - 1).equals(ssid)) {
connectedConfiguration = cnf;
connectedNetId = nid;
}
nid++;
}
}
publicvoidonReceive(Context c, Intent intent) {
List<ScanResult> results = manager.getScanResults();
WifiInfoinfo= manager.getConnectionInfo();
ScanResultstronger=null;
for (ScanResult scanResult : results) {
try {
if (scanResult.SSID.equals(info.getSSID())) {
if (stronger == null) {
if (WifiManager.compareSignalLevel(info.getRssi() + 5, scanResult.level) < 0) {
stronger = scanResult;
}
} elseif (WifiManager.compareSignalLevel(stronger.level, scanResult.level) < 0) {
stronger = scanResult;
}
}
} catch (Exception e) {
}
}
if (stronger != null && !stronger.BSSID.equals(info.getBSSID())) {
updateConnectedConfiguration(info.getSSID());
if (connectedConfiguration != null) {
connectedConfiguration.BSSID = stronger.BSSID;
manager.updateNetwork(connectedConfiguration);
manager.saveConfiguration();
manager.enableNetwork(connectedNetId, true);
manager.reassociate();
info = manager.getConnectionInfo();
//showNotification("\nConnecting " + stronger.SSID, stronger.BSSID + " " + stronger.level + "dBm");
}
}
}
}
Post a Comment for "Android Wifi Roaming Through Ap With Same Ssid"