扫描wifi结果中重复的SSID

ran*_*s26 3 ssid wifi android-wifi

我正在尝试制作一个可以创建可用wifi接入点列表的应用。这是我使用的部分代码:

x = new BroadcastReceiver()
        {
            @Override
            public void onReceive(Context c, Intent intent) 
            {
                results = wifi.getScanResults();
                size = results.size();
                if (results != null) {
                    for (int i=0; i<size; i++){
                        ScanResult scanresult = wifi.getScanResults().get(i);
                        String ssid = scanresult.SSID;
                        int rssi = scanresult.level;
                        String rssiString = String.valueOf(rssi);
                        textStatus.append(ssid + "," + rssiString);
                        textStatus.append("\n");
                    }
                    unregisterReceiver(x); //stops the continuous scan
                    textState.setText("Scanning complete!");
                } else {
                    unregisterReceiver(x); 
                    textState.setText("Nothing is found. Please make sure you are under any wifi coverage");
                }
            }
        };
Run Code Online (Sandbox Code Playgroud)

textStatus和textState都是TextView。我可以使它工作,但有时结果在一次扫描中显示重复的SSID,但信号电平不同。可能会有3-4个相同的SSID,但信号电平不同。

SSID真的不同吗?它们有什么不同?谁能解释?

DuK*_*0mE 6

Are you having several router modems for the same network? For example: A company has a big wireless network with multiple router modems installed in several places so every room has Wifi. If you do that scan you will get a lot of results with the same SSIDs but with different acces points, and thus different signal level.

编辑:根据沃尔特(Walt)的评论,即使您的调制解调器是双频的,尽管只有一个接入点,您也可以有多个结果。

  • 如果您的应用仅在扫描可用的wifi网络,则可以将所有接入点视为同一网络。您可以执行类似HashMap &lt;String,int&gt;的操作。对于每次扫描,您都可以将SSID插入此哈希图的键字段中,并将其信号级别插入此哈希图的value字段中。如果SSID已经在HashMap中,则比较信号电平并将其替换为更好的值。因此,通过此哈希图,您可以获得只有一个SSID和所有多个接入点中最佳信号电平的结果 (2认同)