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

Automatically connect to grisp.io #14

Merged
merged 6 commits into from
Jan 26, 2024
Merged

Automatically connect to grisp.io #14

merged 6 commits into from
Jan 26, 2024

Conversation

ziopio
Copy link
Member

@ziopio ziopio commented Jan 25, 2024

The gen_statem is there to mainly automate what was previously done manually.
State machine is quite simple, is just a sequence that can loop in case it disconnects.

idle -> waiting_ip -> connecting -> connected -> waiting_ip ....

The option {connect, true / false} controlls whether the gen_statem should connect or not.

The gen_statem is always started under the top app supervisor.
The user can either leave the default {connect, true}and have this process attempt to connect as soon as it is started.
If {connect, false} is set in the sys.config, then it can always be started with grisp_io_connection:connect()

I noticed that on Wifi WPA supplicant can be slow and the IP can take even 5+ seconds to be set after the app is booted. So if we serve logs to the user, is nice to wait for the IP instead of keep crashing on errors.

Copy link
Member

@peerst peerst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the comments in the code please

src/grisp_io_connection.erl Outdated Show resolved Hide resolved
src/grisp_io_connection.erl Outdated Show resolved Hide resolved
src/grisp_io_connection.erl Show resolved Hide resolved
src/grisp_io_connection.erl Show resolved Hide resolved
src/grisp_seawater_client.erl Outdated Show resolved Hide resolved
Copy link
Member

@peerst peerst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ziopio
Copy link
Member Author

ziopio commented Jan 26, 2024

I am going to adjust a couple of things to solve the merge conflict with the WS refactoring then I'll squash.

@ziopio ziopio merged commit 8c98fbd into main Jan 26, 2024
1 check passed
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.

2 participants