我需要了解连接到我的wifi网络的所有无线设备的详细信息。我正在获取IP,MAC地址,以及设备的供应商。
如何获取设备类型? (即笔记本电脑,手机,AC,冰箱)和主机名?
InetAddress inetAddress = null;
for (int i = 0; i < 256; i++) {
try {
inetAddress = InetAddress.getByName("192.168.1." + i);
if (inetAddress.isReachable(30)) {
ConnectedDevice device = new ConnectedDevice();
device.setDeviceIPAddress(subnet + i);
device.setDeviceMACAddress(Utils.getMacAddressFromArpCache(inetAddress.getHostName()));
Log.d("Device", inetAddress.getHostName() + ", " + inetAddress.getHostAddress() + ", " + inetAddress.getCanonicalHostName() + ", " + device.getDeviceMACAddress());
}
} catch (Exception e) {
e.printStackTrace();
}
}
getHostName(),getHostAddress(),getCanonicalHostName()inetAddress的所有3种方法仅返回ip地址。如何在网络上获取已连接设备的主机名?我还应该做些什么才能获得设备的所有可能细节?请指导我。