Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Add new method to connect to a SSIDPrefix protected only once, Android: Try to address issue #303 #377

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

notjulian
Copy link

@notjulian notjulian commented Apr 3, 2024

  • iOS: Add new method to connect to a SSIDPrefix protected only once.
  • Android: Add timeout for removeWifiNetwork and disconnect
  • Android: Try to address issue Android 13 issue #303.

For issue #303, I've tested it on a Pixel 7 running Android 14, as well as on other brands.
The fix is taken from WiFiFlutter concurrent-connections
Thanks to: @Martichou, @darhaywa and @daadu

Code example (for a hotspot without Internet), first connect, then forceWifiUsage true, before disconnect forceWiFiUsage to false

//To connect
await WifiManager.connectToProtectedWifiSSID({
                  ssid: WifiNetToUse,
                  password: pwdWifi,
                  isWEP: false,
                  isHidden: false,
                  timeout: 15,
                })
                  .then(async () => {
                    if (!isIOS)
                      await WifiManager.forceWifiUsageWithOptions(true, {
                        noInternet: true,
                      })
                  })
                  .catch(e => {
                    console.log(e.message, e.code)
                    error = e.code
                  })

//To disconnect
 await WifiManager.forceWifiUsageWithOptions(false, {
            noInternet: false,
})
await WifiManager.isRemoveWifiNetwork(currentSSID)

@JuanSeBestia
Copy link
Owner

I guess it has some conflicts for this MR
#355

@notjulian
Copy link
Author

I guess it has some conflicts for this MR #355

sorry where?
thanks

@smartmedev
Copy link

Hi @notjulian why did you add timeout for removeWifiNetwork and disconnect on Android?
What is the purpose?
I've found that you userd DisconnectCallbackHolder.getInstance() on the disconnect() and removeWifiNetwork() timeout blocks and Android Studio tell us that this call requires API Level 29 when the library target is 21.
Screenshot 2024-05-31 alle 14 25 10

Can you please add a check like this if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { } and use the old behavior elsewhere?

@notjulian
Copy link
Author

Hi @notjulian why did you add timeout for removeWifiNetwork and disconnect on Android? What is the purpose? I've found that you userd DisconnectCallbackHolder.getInstance() on the disconnect() and removeWifiNetwork() timeout blocks and Android Studio tell us that this call requires API Level 29 when the library target is 21. Screenshot 2024-05-31 alle 14 25 10

Can you please add a check like this if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { } and use the old behavior elsewhere?

Hi,
is to avoid timeout on disconnect, I've updated the code

@smartmedev
Copy link

Hi @notjulian, sorry but what do you mean with "avoid timeout on disconnect"?

In @JuanSeBestia library code on disconnect/removeWifiNetwork is there any timeout... you've added it on your pr, but I can't understand what is the purpose of adding a timeout on disconnect/removeWifiNetwork. Thank you

@notjulian
Copy link
Author

Hi @notjulian, sorry but what do you mean with "avoid timeout on disconnect"?

In @JuanSeBestia library code on disconnect/removeWifiNetwork is there any timeout... you've added it on your pr, but I can't understand what is the purpose of adding a timeout on disconnect/removeWifiNetwork. Thank you

If the disconnect take more time to complete, it will cancel and return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants