How to manipulate MAC address (rotocolot address)? [closed]

1

I am making an application on INTEL XDK for smartphone and would like to capture the MAC Adrees value of the currently active Wifi Router, as well as the network name (SSID) and password, to make comparisons. Example: I have 3 routers with the same name and password, but with the values of MACs 'A', 'B' and 'C' respectively in my work and I want it when I connect to the Router with MAC Adrees = 'B' application enable some functions and inform me that I am connected on Router with SSID = 'work', Password = 'password' and MAC = 'B'.
How to manipulate the MAC Adrees (physical address) of the router?

    
asked by anonymous 28.09.2016 / 17:34

1 answer

0

Oh, there's this solution in Java:

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

public class App{

   public static void main(String[] args){

    InetAddress ip;
    try {

        ip = InetAddress.getLocalHost();
        System.out.println("Current IP address : " + ip.getHostAddress());

        NetworkInterface network = NetworkInterface.getByInetAddress(ip);

        byte[] mac = network.getHardwareAddress();

        System.out.print("Current MAC address : ");

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < mac.length; i++) {
            sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));        
        }
        System.out.println(sb.toString());

    } catch (UnknownHostException e) {

        e.printStackTrace();

    } catch (SocketException e){

        e.printStackTrace();

    }

   }

}

See if it helps.

Font

    
28.09.2016 / 18:29