问题
Is there any way i can get WLAN information f.e. SSID, Signal strength etc in java or C++?
I know about the wlanscan function in C++. Can anyone give me any example on how to implement it?
There is also a jwlanscan api for java but its not working for me.
OS: Windows 7
Any help would be appreciated. Thanks!
EDIT:
{
System.loadLibrary("wireless");
}
List list = getNetworkAdapterInfo();
if (list == null)
System.out.println("None Network Adapter.");
else
for (Iterator ite = list.iterator(); ite.hasNext(); )
{
NetworkAdapterInfo nic = (NetworkAdapterInfo)ite.next();
System.out.println(nic.toString());
List listap = getWirelessApInfo(nic.getName());
if (listap == null) {
System.out.println("None Access Point.");
}
else {
System.out.println("Access Point:");
for (Iterator ite1 = listap.iterator(); ite1.hasNext(); )
{
WirelessApInfo ap = (WirelessApInfo)ite1.next();
System.out.println(ap.toString());
}
}
System.out.println("");
}
So far i have this code (jwlanscan api). It does not return any access point.
回答1:
After some searching, i got the answer myself. :)
WLAN API for getting signal strenth
This C++ code displays all the required wlan information.
回答2:
following post details how to create WLAN object and access the info you need
How to find a list of wireless networks (SSID's) in Java, C#, and/or C?
WlanClient client = new WlanClient();
foreach ( WlanClient.WlanInterface wlanIface in client.Interfaces )
{
// Lists all available networks
Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList( 0 );
foreach ( Wlan.WlanAvailableNetwork network in networks )
{
Console.WriteLine( "Found network with SSID {0}.", GetStringForSSID(network.dot11Ssid));
}
}
static string GetStringForSSID(Wlan.Dot11Ssid ssid)
{
return Encoding.ASCII.GetString( ssid.SSID, 0, (int) ssid.SSIDLength );
}
UPDATE:
OK, my bad,
I guess there is no native java api's for wlan connections. only way to do it is to go through OS native api and get the info.
来源:https://stackoverflow.com/questions/9699618/wlan-ssid-in-java-c