B4A Library VBWep 1.0 Library (WEP)

VBWep 1.1 Library (WEP)

Releasing VBWep 1.1
Allows you to connect to a WIFI via WEP with SSID,PASSWORD

  • VBConnect
    Permissions:
    • android.permission.CHANGE_NETWORK_STATE
    • android.permission.WAKE_LOCK
    • android.permission.INTERNET
    • android.permission.UPDATE_DEVICE_STATS
    • android.permission.CHANGE_WIFI_STATE
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.ACCESS_WIFI_STATE
    Properties:
    • BSSID As String
      Return a wifi BSSID as STRING
    • IPADDRESS As String
      Return a wifi IP ADDRESS as INT
      *(not sure if this works)
    • SupplicantState As SupplicantState
      Return a STATUS STATE
      *
      *ASSOCIATED - Association completed.
      *ASSOCIATING - Trying to associate with an access point.
      *COMPLETED - All authentication completed.
      *DISCONNECTED - client is not associated, *likely to start looking for an access point*
      *DORMANT - An Android-added state that is reported when a client issues an explicit DISCONNECT command.
      *FOUR_WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress.
      *GROUP_HANDSHAKE - WPA Group Key Handshake in progress.
      *INACTIVE - Inactive state.
      *INVALID - A pseudo-state that should normally never be seen. SCANNING - Scanning for a network.
      *UNINITIALIZED - No connection.
    • mac As String
      Return a wifi mac address as STRING
    Methods:
    • GetWifiList As List
      Return a List of the names of available WIFI Spots.
    • RemoveAllSavedNetworks
      Removes all saved networks on device
      *Good when you want to reset wifi configurations
      *WARNING: Will remove all passwords of saved wifi locations
    • cWEP (wepSSID As String, wepPASS As String)
      Connect to the given WEP network ssid with the password.
      *No quotes or backslashes needed.
      wepSSID:*
      wepPASS:*
    • intToIp (i As Int) As String
    • readWepConfig
      readWepConfig()
      *displays info to the b4a debug log window
    • weconnected As String
      If connected:
      *Returns a String *YES *
      *If not connected:
      *Returns a String *NO

cWep(ssid,password)
connects device to the wifi WEP/SSID

weconnected()
returns if you are connected to wifi

GetWifiList()
returns a list of available wifi's
returns the % of strength
returns the type of network
example: Igloo ::: [WPA-PSK-TKIP][WPA2-PSK-TKIP+CCMP] ::: 16

Msgbox(MyWiFi.mac,"mac address")
Msgbox(MyWiFi.IPADDRESS,"IP")
Msgbox(MyWiFi.BSSID,"BSSID")
Msgbox(MyWiFi.SupplicantState,"SUPSTATE")

* Return a STATUS STATE
*
* ASSOCIATED - Association completed.
* ASSOCIATING - Trying to associate with an access point.
* COMPLETED - All authentication completed.
* DISCONNECTED - client is not associated, likely to start looking for an access point
* DORMANT - An Android-added state that is reported when a client issues an explicit DISCONNECT command.
* FOUR_WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress.
* GROUP_HANDSHAKE - WPA Group Key Handshake in progress.
* INACTIVE - Inactive state.
* INVALID - A pseudo-state that should normally never be seen. SCANNING - Scanning for a network.
* UNINITIALIZED - No connection.

RemoveAllSavedNetworks()
clears out all Saved Networks in your wifi list
this will remove all saved configurations
don't use if you have and need wifi passwords stored on device



Attached is an example program, please test and give feedback.

Credits: Tomas for helping me start this a few months ago

Thanks in Advance
Vb1992

Library Revision History:

old...... Library is version 1.0 - July 17th, 2012
New...... Library is version 1.1 - July 19th, 2012

VBWep.zip is the project (also see in this thread NJDUDE's advanced example project)
VBWep1.1.zip is the library
 

Attachments

  • VBWep.zip
    5.8 KB · Views: 1,243
  • VBWep1.1.zip
    7.7 KB · Views: 1,633
Last edited:

mc73

Well-Known Member
Licensed User
Longtime User
Great! Libs like this, are really useful in occasions as one I'm facing lately, thank you!
 

NJDude

Expert
Licensed User
Longtime User
Nice lib.

The attached project has a slightly improved demo for this library.

You can Click and LongClick on the listview items.



Updated to sample version 1.2 on: Aug 02, 2012

NOTE: Modified sample using library version 1.5 BETA
 

Attachments

  • VBWEP_Sample_1.1.zip
    9.1 KB · Views: 652
  • VBWEP_Sample_1.2.zip
    9.1 KB · Views: 862
Last edited:

Mahares

Expert
Licensed User
Longtime User
@VB1992: Very nice library.
1. What makes this feature different or stand out over the built in WiFi feature on my smartphone?
2. Under what scenario would you use it?
3. How can it be used in conjunction with B4A-Bridge WiFi mode?
@NJDude: Very nice improvements to the demo.
 

vb1992

Well-Known Member
Licensed User
Longtime User
@vb1992: Very nice library.

Thanks

1. What makes this feature different or stand out over the built in WiFi feature
on my smartphone?

This gives you the ability to write your own app and let the user select the WIFI access point (WEP) and connect to that SSID by typing in a password, without the user ever having to leave your app and go into settings/wifi.

Great for initial "setup" type apps.


2. Under what scenario would you use it?

Example: So if you created a kiosk type app and you needed it to always connect to one certain wifi SSID/PASSWORD you could put that into the code and it would connect to it.

If you change that wifi router password monthly, then you could have your app check a database for the new password at the end of the month, and when you change your router password on the first of the month it could log in with that new password.

I am sure for tech support in companies this could be really good.


3. How can it be used in conjunction with B4A-Bridge WiFi mode?

Not sure if this would be relevant here, maybe someone else has thoughts on it.
 

NJDude

Expert
Licensed User
Longtime User
I've modified the sample on my previous post, it now detects if there's WiFi connection or not and displays a MsgBox and the list of available WiFi networks is sorted by signal strength, from strongest to weakest.
 

Mahares

Expert
Licensed User
Longtime User
@NJ: You and VB1992 seem to be complementing each other. I will be your guinea pig. I have installed your new updated sample. It seems to work fine. Here is what the screen shows:
Networks found:0 Connected: Yes.
In the previous sample, I thought it displayed Default when I tested it from the same site.
Anyway, you keep changing the code on us as often as you are changing 'location'. Just kidding.
Thank you again.
 

Mahares

Expert
Licensed User
Longtime User
@VB1992: The latest example revised by NJDude shows 0 networks , but says: Connected.
I reloaded your original code and it shows: Default, connected like it is supposed to do. Perhaps NJDude needs to look at his latest revision again.
Thanks VB1992.
 

vb1992

Well-Known Member
Licensed User
Longtime User
Just updated the Library to version 1.1
which now returns the follow information:


Mac Address
Ip Address
BSSID
Supplication State



* Return a STATUS STATE
*
* ASSOCIATED - Association completed.
* ASSOCIATING - Trying to associate with an access point.
* COMPLETED - All authentication completed.
* DISCONNECTED - client is not associated, likely to start looking for an access point
* DORMANT - An Android-added state that is reported when a client issues an explicit DISCONNECT command.
* FOUR_WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress.
* GROUP_HANDSHAKE - WPA Group Key Handshake in progress.
* INACTIVE - Inactive state.
* INVALID - A pseudo-state that should normally never be seen. SCANNING - Scanning for a network.
* UNINITIALIZED - No connection.
 

vb1992

Well-Known Member
Licensed User
Longtime User
This is a beta library test for NJDUDE
(anyone can test it also, but the examples in the first post won't work properly if you don't change the code to reflect)

B4X:
myresult.SSID + " ::: " + myresult.capabilities  + " ::: " + mylevel + " ::: " + myresult.BSSID
 

Attachments

  • VBWep1.5.zip
    11.2 KB · Views: 747
Last edited:

NJDude

Expert
Licensed User
Longtime User
Did you upload the correct lib? I do not see the members you mentioned (SSID and Capabilities) or am I doing something wrong?.

Also, the version still shows 1.0 (I think in Eclipse you have to do something like @version ...) maybe a lib maker can tell you exactly what to do.
 
Last edited:

vb1992

Well-Known Member
Licensed User
Longtime User
thanks, looking it up

will try this tomorrow

rightclick on the project, select "Team -> set Property"

Property name: Enter "svn:keywords"

Enter a text property: Enter "LastChangedDate Author Id Revision HeadURL"

Check the option "Set property recursively"

Click "OK"
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
NJ: Since I promised I will be your Guinea pig, the sample VBWEP 1.1 did not compile for me. Please note that the built in WiFI on the device displays all networks OK.
Error on Line 125
B4X:
wfSignal.BSSID = WiFiData(3)
ArrayoutofboundsException, length=3
 

NJDude

Expert
Licensed User
Longtime User
I'm assuming you didn't update the VBWep lib to 1.5 BETA, the new sample (1.2) uses that lib and it works. The new lib is in post #13.

Here's the APK, give it a shot.
 

Attachments

  • WEPLibSample.apk
    107 KB · Views: 482

Mahares

Expert
Licensed User
Longtime User
NJ: After installing the latest lib it compiled and worked. However, it still displays 'networks Found=0', but it is connected. I will ignore that if it is not important.
I even installed your apk file and it showed the same: Network found=0.
I hope things are well in Proces_Global.
 
Top