B4A Library Wifi Manager Library

For one of my projects I created a little library to have access to 3 wifi manager functions:

Inquire the state of wifi (switched on or off), switch wifi on or off and start a wifi scan.

Here is a sample how you can use it:

Dim jhw As JhWifi

' Initialize wifi
jhw.Initialize()

' Is wifi enabled, if not enable it
If jhw.Enabled = False Then
jhw.Enabled = True
End If
' Start wifi scan
jhw.startscan()
' Disable wifi
jhw.Enabled = False

Please use it for whatever you need it.

With kindest regards
Joerg
 

Attachments

Last edited:
Hmmm...I don't have the right syntax here???

Code: Copy
jhw.Wifi_Sleep_Policy = WIFI_SLEEP_POLICY_NEVER

or ???

Code: Copy
mInt = jhw.get("Wifi_Sleep_Policy")
 
Last edited:
Awesome...

Wanted to make sure my users have WiFi turned off when using my app so they aren't draining the battery. Does what I need with a whopping three lines of code.

Awesome.

Thanks!
 
@rfresh:

Here is a code sample:

Code: Copy
jhw.Initialize()
jhw.Wifi_Sleep_Policy = jhw.WIFI_SLEEP_POLICY_NEVER
jhw.Wifi_Sleep_Policy = jhw.WIFI_SLEEP_POLICY_DEFAULT
jhw.Wifi_Sleep_Policy = jhw.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED

With kindest regards
joehil
 
Assign Static IP address

Hello joehil:
Your library can assign a static ip directions to the device? I write this program :


wifi.Initialize
wifi.Wifi_Use_Static_IP=1
wifi.Wifi_Static_IP="192.168.1.22"
Server.Initialize(50000, "Servidor")
ToastMessageShow(wifi.Wifi_Static_IP, True)
ToastMessageShow ("MyIp = " & Server.GetMyIP,True)

and the result of the first toast is 192.168.1.22
and the result of the second toast is 192.168.1.36, it takes the ip access point

can you help please? , I want to assign a static IP address to the device, if possible .
Thanks
 
Joe,
Nice work!
Is there a way to get a list of SSIDs when you do a scan? I know you get an index to the "strongest", but I'd like to get a list of SSIDs regardless of strength. (And as a sideline, it would be good to know the security i.e. WPA/WPA2 etc.)
Thanks,
Rusty
 
@Rusty:

I will implement your request during the next few days.

With kindest regards

joehil
 
@joehil,

Thanks for a great lib! I was wondering if your could add the ability to check and see if there is an Active connection?

.connected = returns true or false


attn: Pablo

:sign0098:
 
Joe,
Did you ever implement the SSID list?
Regards,
Rusty
 
@Rusty:

Sorry, I have not implemented it, because vb1992 posted this link:

http://www.b4x.com/forum/addit...tml#post113173

as a reply to your request and said, that this library does it.

Have you tried that? If it does not work for you, I will implement it in my library.

With kindest regards

joehil
 
Last edited:
I have been using your library for some time now and it is GREAT! Thank you for this!

I have now run into one issue I hope to resolve. I have a tablet running ICS and I can not set a static IP on this tablet. I use the same small app I have been using on a half dozen other devices that work fine. However, none of them are running ICS. Is this a known issue in ICS? Any thoughts or info would be great.
 
Problem with jhwifi when network not found

Hello,

When I am searching an SSID which is not present using n=jhw.findConfiguredNetwork("MyNetwork") I am getting n=7.

What is n supposed to be when the network is not found ?
why 7, why not a negative number ?

Thank You
Carlos
 
JhWifi.IsInitialized missing method

Hi,
thank you for this very useful library.

I would suggest you a little add: I'm trying to test if wifi is enabled in a part of code where I can't know if the JhWifi object was already initialized and I get a NullPointerException.

If you will add a IsInitialized method (like those in many B4A objects) to your lib I could avoid that exception :sign0060:

Thanx in advance
best regards
 
Hi Joehil,

I'm searching a way to get an event when the Connection Manager get a new "open network available" (there is a specific setting into the network window) without doing a continue network scanning...

Do you have idea if this is possible ?

Fab
 
Hello joehil:
Your library can assign a static ip directions to the device? I write this program :


wifi.Initialize
wifi.Wifi_Use_Static_IP=1
wifi.Wifi_Static_IP="192.168.1.22"
Server.Initialize(50000, "Servidor")
ToastMessageShow(wifi.Wifi_Static_IP, True)
ToastMessageShow ("MyIp = " & Server.GetMyIP,True)

and the result of the first toast is 192.168.1.22
and the result of the second toast is 192.168.1.36, it takes the ip access point

can you help please? , I want to assign a static IP address to the device, if possible .
Thanks

Is this problem resolved in this library yet? I want to use this library and was reading the posts with problems, this one seems not replied to. Thanks
 
Back
Top