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,141
  • VBWep1.1.zip
    7.7 KB · Views: 1,528
Last edited:

NJDude

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.

The networks found is nothing but the size of the ListView where I add the results (Line #149 in the Main module), I don't understand why you get zero.
 

Mahares

Expert
Licensed User
Longtime User
I made the below minor change, it started displaying the correct number of networks. Don't ask me why I made that change? I was not about to mess with NJDude or VB1992.
B4X:
'            For I = 0 To wfList.Size - 2
            For I = 0 To wfList.Size - 1  '8/2/12 Mahares change
 

synasir

Member
Licensed User
Longtime User
This library does not work for me. Changed the router to WEP and tried to connect using
mywifi.cWEP("CiscoXXXX","01234567890") but still did not work. Any ideas? Thanks.
 

synasir

Member
Licensed User
Longtime User
upload your code, and I can take a look at your project
(block out your ssid/wep password like you did in the uploaded project too)

Use the NJDUDE example also the same result. Even changed the phone to a Sony Experia from a Galaxy Y.


Connected to a previous router and tried to change to the Cisco WEP router using the app, did not connected. It disconnected my from my previous router and reconnected back to the previous router.

"Forget" the previous router and when running the app, "no wifi connection detected"
 

synasir

Member
Licensed User
Longtime User
Did you try the demo/example in the first post?
Because I tested that one myself.

All the SSID are listed but still cannot connect to the Cisco WEP router. Do you need to configure the router first?
 

synasir

Member
Licensed User
Longtime User
Still no go.


Changed router to TPLINK, does not work.
Changed router to Linksys, does not work.
Changed phone from Samsung to Sony, does not work.

Has anyone else got this working beside the author? :sign0163:

Getting very frustrated here!:BangHead:
 

vb1992

Well-Known Member
Licensed User
Longtime User
Could be coming down to a manifest permission problem...
What version of Android OS you running on the phones
I tested the apk, and works fine, thought I am not running ICS

check to make sure your demo project in the manifest file/editor has these permissions

B4X:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
    </uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
    </uses-permission>
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS">
    </uses-permission>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE">
    </uses-permission>
 
Last edited:

synasir

Member
Licensed User
Longtime User
Could be coming down to a manifest permission problem...
What version of Android OS you running on the phones
I tested the apk, and works fine, thought I am not running ICS

check to make sure your demo project in the manifest file/editor has these permissions

B4X:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
    </uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
    </uses-permission>
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS">
    </uses-permission>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE">
    </uses-permission>

The Samsung is running 2.3.6 while the Sony is running 2.1 (very old Sony)

It already has all this permission.

<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
 

jalle007

Active Member
Licensed User
Longtime User
I dont understand this whole idea about WiFi connecting and why is it so hard to do it

When i try to connect at my wirelles router which is set to WPA I got this :

Did not find a match for: [JalleNET ]
So we can't enable this SSID: [JalleNET ]

what dopes it mean? this library can't connect only to previously used wifi aftre it remembers it settings ?

Is it because of WPA ?
 

westingenieria

Active Member
Licensed User
Longtime User
Great library. Thank you for your work. Now i made a little modification (WPA+static IP) if someone has some interest i can upload the library...

I made the below minor change, it started displaying the correct number of networks. Don't ask me why I made that change? I was not about to mess with NJDude or VB1992.
B4X:
'            For I = 0 To wfList.Size - 2
            For I = 0 To wfList.Size - 1  '8/2/12 Mahares change

I have a problem with scanning networks... i have duplicate SSID in my list :sign0148:(also in the log). I cant find the problem... Ill appreciate if someone can help me.

PD. sorry for my english, i know it sucks!
 
Top