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

Monitor wifi connectivity #940

Open
wants to merge 7 commits into
base: main-dev
Choose a base branch
from

Conversation

jjjasont
Copy link

@jjjasont jjjasont commented Mar 9, 2025

Add a new process for Wifi connectivity check.

If SSID and WIFI_MAX_FAILS are defined, Wi-Fi monitoring is enabled.

Teslausb will check wifi connectivity on a 60-seconds internal.
Teslausb will reboot if SSID is in range, but not connected after WIFI_MAX_FAILS

jjjasont added 2 commits March 9, 2025 20:09
new process to monitor wifi connectivity
wifi connectivity monitor teslausb_setup_variables.conf parameters
@jjjasont
Copy link
Author

jjjasont commented Mar 9, 2025

Background for this pull request:

I setup Home wifi SSID and enabled AP access point in TeslaUSB.

I noticed that TeslaUSB does not automatically connects to home wifi when I return home. But it will successfully connect to home wifi after a reboot.

So I setup a monitor script to reboot TeslaUSB if after X consecutive failed checks

Do a ping test connectivity.
Default to ping 8.8.8.8 if ping_host not defined in config
Update with ping host config
# TeslaUSB will check wifi connectivity on a 60-seconds internal.
# TeslaUSB will reboot if SSID is in range, but ping failed after WIFI_MAX_FAILS
#export MAX_FAILS = 3
#export PING_HOST="192.168.1.1" # Host to ping for connectivity; defaults to 8.8.8.8 if unset
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like this should either ping the archive server, or the default gateway.
I think I prefer the latter, because then it would do the right thing (which is nothing) both if the inernet is down or if the archive server is down.

Copy link
Author

Choose a reason for hiding this comment

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

Do you think this is just a change in the comment?
The current version, the user can specify a host that response to ping. It can be router/gateway/archive server or external ip address.

Copy link
Owner

Choose a reason for hiding this comment

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

Do you think this is just a change in the comment?

I was thinking that the code that actually does the pinging should default to the gateway if PING_HOST is unspecified, i.e. something like : ${PING_HOST:=$(route | grep '^default' | awk '{print $2}')} and then the user can just leave it unspecified in the config file. That would then also work if the user specified multiple networks to connect to (e.g. home, work, hotspot, etc.)

Rename MAX_FAILS back to WIFI_MAX_FAILS.
Support both Networking Manager & WPA Supplicant.
Update the monitoring logic so that monitoring will only happen if SSID, WIFI_MAX_FAILS and PING_HOST are defined.
Rename MAX_FAILS back to WIFI_MAX_FAILS.
Update descriptions on how wifi monitoring works.
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