Get nearby BSSID and signal strength in Java

无人久伴 提交于 2019-12-23 04:48:16

问题


I need to get nearby BSSID's with their signal strength using Java. Something like the output of netsh wlan show networks mode=BSSID.

Is it possible?


回答1:


Try implementing a method like this: (of course the command held in the cmd string is for window operating systems only).

The "wlanResults.append("...");" is simply writing the results to a jTextArea in a gui (it's a part of a program i'm working on).

public void getWLANbssidInfo(){
     String cmd = "netsh wlan show network mode=bssid";

        try {

            Process p3;
             p3 = Runtime.getRuntime().exec("cmd /c " + cmd);
             p3.waitFor();
             BufferedReader reader = new BufferedReader(new InputStreamReader(p3.getInputStream()));
             String line = reader.readLine();
             while(line!=null){
                 wlanResults.append(line + "\n");
                 System.out.println(line);
                 line = reader.readLine();
             }
        } catch (IOException ex) {

            wlanResults.append("Comand error\n" + ex);
            System.out.println("There was an IO exception.");

        } catch (InterruptedException ex) {
            wlanResults.append("Command was interrupted: " + ex);
            System.out.println("The command was interrupted.");
        }

}


来源:https://stackoverflow.com/questions/21240305/get-nearby-bssid-and-signal-strength-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!