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

  • Jhwifi.1.2.zip
    4.2 KB · Views: 1,984
Last edited:

margret

Well-Known Member
Licensed User
Longtime User
The help in the IDE says:

Wifi_Use_Static_IP As Int

It does not say what turns this on and what's off:

Is Wifi_Use_Static_IP = 1 turned on and 0 is off?

UPDATED: After using and testing. Passing a 1 is on and passing a 0 turns it off.

This is a great library!!!

Thank You So Much!

Margret:)
 
Last edited:

rfresh

Well-Known Member
Licensed User
Longtime User
Hmmm...I don't have the right syntax here???

B4X:
jhw.Wifi_Sleep_Policy = WIFI_SLEEP_POLICY_NEVER

or ???

B4X:
mInt = jhw.get("Wifi_Sleep_Policy")
 
Last edited:

KTMRacr

New Member
Licensed User
Longtime User
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!
 

joehil

Member
Licensed User
Longtime User
@rfresh:

Here is a code sample:

B4X:
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
 

harri_el_sucio

New Member
Licensed User
Longtime User
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
 

Rusty

Well-Known Member
Licensed User
Longtime User
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
 

joehil

Member
Licensed User
Longtime User
@Rusty:

I will implement your request during the next few days.

With kindest regards

joehil
 

abner69

Member
Licensed User
Longtime User
@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:
 

Rusty

Well-Known Member
Licensed User
Longtime User
Joe,
Did you ever implement the SSID list?
Regards,
Rusty
 

joehil

Member
Licensed User
Longtime User
@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:

margret

Well-Known Member
Licensed User
Longtime User
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.
 

cmastran

Member
Licensed User
Longtime User
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
 

frapel

Active Member
Licensed User
Longtime User
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
 

fabpalma

Member
Licensed User
Longtime User
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
 

rfsingh81

Member
Licensed User
Longtime User
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
 
Top