Get nearby BSSID and signal strength in Java

1.9k Views Asked by At

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

There are 1 best solutions below

0
On

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.");
        }

}