Add open WifiConfiguration

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Add open WifiConfiguration

Postby MichaMicha » Sun Dec 28, 2008 3:47 pm

Hi,
I'm trying to add an open WifiConfiguration, but everytime I try to add one via my code the configuration either is WAP or WEP, I just want to create an open configuration.
Does someone knows how to do this?

This is a part of my code.


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. WifiConfiguration THOMSON = new WifiConfiguration();
  3.  
  4. // THOMSON.BSSID = sr.BSSID;
  5.  
  6. THOMSON.SSID = "\"TestConfig\"";
  7.  
  8. THOMSON.priority = 67;
  9.  
  10. // sr.
  11.  
  12. THOMSON.status = 1;
  13.  
  14.  
  15.  
  16. BitSet allowedAuthAlgorithms = new BitSet();
  17.  
  18. // allowedAuthAlgorithms.set(0, 3, true);
  19.  
  20.  
  21.  
  22. THOMSON.allowedAuthAlgorithms = allowedAuthAlgorithms;
  23.  
  24.  
  25.  
  26. BitSet allowedGroupCiphers = new BitSet();
  27.  
  28. allowedGroupCiphers.set(0, 3, true);
  29.  
  30. THOMSON.allowedGroupCiphers = allowedGroupCiphers;
  31.  
  32.  
  33.  
  34. BitSet allowedKeyManagement = new BitSet();
  35.  
  36. allowedKeyManagement.set(0, true);
  37.  
  38. THOMSON.allowedKeyManagement = allowedKeyManagement;
  39.  
  40.  
  41.  
  42. BitSet allowedPairwiseCiphers = new BitSet();
  43.  
  44. allowedPairwiseCiphers.set(1, 2, true);
  45.  
  46. THOMSON.allowedPairwiseCiphers = allowedPairwiseCiphers;
  47.  
  48.  
  49.  
  50. BitSet allowedProtocols = new BitSet();
  51.  
  52. allowedProtocols.set(0, 1, true);
  53.  
  54. THOMSON.allowedProtocols = allowedProtocols;
  55.  
  56.  
  57.  
  58. THOMSON.preSharedKey = null;
  59.  
  60.  
  61.  
  62. int THOMSONnetid = mainWifi.addNetwork(THOMSON);
  63.  
  64. boolean THOMSONresult = mainWifi.enableNetwork(THOMSONnetid, true);
  65.  
  66. mainText.setText("Adding Manual:" + THOMSONnetid + " result: "
  67.  
  68.                 + THOMSONresult + "\n\nSaving:"
  69.  
  70.                 + mainWifi.saveConfiguration());
  71.  
  72.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
MichaMicha
Freshman
Freshman
 
Posts: 3
Joined: Sun Dec 28, 2008 3:44 pm

Top

facing same problem

Postby lakki123 » Mon Apr 27, 2009 10:58 am

Hi,
I am also trying to add a local unsecured network but without any success.
The network id returned is always -1. Tired to look into logcat without any success.
Were you successful in adding a network configuration? Or anyone has been able to add a network configuration?
Can some one please provide me some hints?

Thanks,
Lakshmesha
lakki123
Freshman
Freshman
 
Posts: 2
Joined: Tue Mar 17, 2009 4:19 pm

Postby tina75 » Wed Aug 19, 2009 6:06 pm

i found this and it works:

http://mapbea.blogspot.com/2009/05/andr ... nager.html

or short:

WifiConfiguration wfc = new WifiConfiguration();
wfc.BSSID = bssid;
wfc.priority = 1;
wfc.allowedKeyManagement.set(KeyMgmt.NONE);
wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wfc.status=WifiConfiguration.Status.ENABLED;

int idt = mainWifi.addNetwork(wfc);
....
tina75
Junior Developer
Junior Developer
 
Posts: 17
Joined: Tue Aug 18, 2009 3:58 pm

Postby lakki123 » Fri Aug 21, 2009 4:03 pm

tina75 wrote:i found this and it works:

http://mapbea.blogspot.com/2009/05/andr ... nager.html

or short:

WifiConfiguration wfc = new WifiConfiguration();
wfc.BSSID = bssid;
wfc.priority = 1;
wfc.allowedKeyManagement.set(KeyMgmt.NONE);
wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wfc.status=WifiConfiguration.Status.ENABLED;

int idt = mainWifi.addNetwork(wfc);
....


Thanks a lot. But for me the actual error was, I had forgot to add the "quoted string" to BSSID. :oops:
lakki123
Freshman
Freshman
 
Posts: 2
Joined: Tue Mar 17, 2009 4:19 pm

Postby derolph » Tue Feb 02, 2010 7:45 pm

lakki123 wrote:
tina75 wrote:i found this and it works:

http://mapbea.blogspot.com/2009/05/andr ... nager.html

or short:

WifiConfiguration wfc = new WifiConfiguration();
wfc.BSSID = bssid;
wfc.priority = 1;
wfc.allowedKeyManagement.set(KeyMgmt.NONE);
wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wfc.status=WifiConfiguration.Status.ENABLED;

int idt = mainWifi.addNetwork(wfc);
....


Thanks a lot. But for me the actual error was, I had forgot to add the "quoted string" to BSSID. :oops:


I dropped that snippet of code into my application and I connected right up! Thank you very much for posting it. I saw something curious though... When I type in a bssid that is currently out of range, the device does not try to connect to the bssid, I only see the standard probe requests. I was hoping that I would see an association request when I added the network to the wifi manager. I would like to control when the association is attempted.
derolph
Freshman
Freshman
 
Posts: 2
Joined: Tue Feb 02, 2010 7:14 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests