question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add timeout option for connectToProtectedSSID

See original GitHub issue

Feature description

Add configurable timeout option. When the phone couldn’t connect to access point in the specified time, cancel the attempt and reject the promise with error timeoutOccurred.

On iOS this timeout behaviour has to be added completely. On Android this is already an option in the native dependency used (https://github.com/ThanosFisherman/WifiUtils) but we don’t allow setting it yet.

New method signature

If we don’t want to break the lib for users that upgrade, we could add a new method: connectToProtectedSSID(SSID, password, options: Object): Promise Options:

  • isWep: boolean: Used on iOS, …
  • timeout: int: Maximum time the phone can try to get connected. After this, the connection attempt is cancelled and the promise is rejected. Default is 45 seconds.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

3reactions
fiznoolcommented, Oct 18, 2021

Firstly apologies for wading in, I have just discovered this library, and it’s exactly what I need.

My own personal view is that using the named parameters approach to function signatures makes adding new features (such as this) trivial in the future. In this case, a short-term breaking change to a sig such as the following would benefit the library in the longer term:

export function connectToProtectedSSID(options: {
        ssid: string;
        password: string | null;
        isWEP: boolean;
        timeout? number;
    }): Promise<void>;

With this in place, more options can be easily added to this at a later date, providing they are optional.

Of course, there is the downside of inconvenience for existing users, but in most cases a simple refactor should suffice, especially if this is released as a major version bump with clear migration instructions.

Thanks for maintaining this library, whatever decision is taken here, it would be great to have a timeout option.

0reactions
kidasovcommented, Oct 4, 2021

any update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-wifi-reborn - npm
A react-native implementation for viewing and connecting to Wifi networks on Android and iOS devices.. Latest version: 4.7.0, ...
Read more >
react native - most likely the callback was already invoked
I got this error when trying to use react-native-wifi-reborn to connect with with. Invariant Violation: No callback found with cbID 2567 and ...
Read more >
useTimeout, a setTimeout hook for React - Josh W Comeau
export default function useTimeout(callback, delay) { ... Then, 5 seconds later, it'll re-render with hasTimeElapsed set to true.
Read more >
Using setTimeout in React components (including hooks)
Setting the number to null will disable the timeout, and it also automatically cancels it when the component unmounts. The code of the...
Read more >
lib/types/index.d.ts - jsDelivr
timeoutOccurred = 'timeoutOccurred', } /** * Connects to a WiFi network. ... export function connectToProtectedSSID( SSID: string, password: string | null, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found