Skip to content

Repository files navigation

Smart Wi-Fi Manager

Smart Wi-Fi Manager keeps a Linux computer connected to the best saved Wi-Fi network. It uses NetworkManager (nmcli) and includes an optional web dashboard.

It is designed for Raspberry Pi, Ubuntu, drones, robots, and other Linux computers that may move between known networks.

Install

You need Linux with NetworkManager, Python 3, curl, and systemd.

git clone https://github.com/alireza787b/smart-wifi-manager.git
cd smart-wifi-manager
sudo ./install.sh

The installer adds the short swm command and starts the Wi-Fi manager. The dashboard is installed at http://127.0.0.1:9080, where only this computer can reach it.

See all commands or get help for one command:

swm help
swm help wifi
swm help wifi add
swm help dashboard

Add your first Wi-Fi network

sudo swm wifi add "YOUR_WIFI_NAME"

Type the Wi-Fi password when asked. The password is hidden while you type.

Check the saved networks:

sudo swm wifi list

Add a network without a password:

sudo swm wifi add "OPEN_WIFI_NAME" --open

Manage Wi-Fi from the terminal

Use either the profile ID or Wi-Fi name in these commands:

# Change a password (the new password is requested safely)
sudo swm wifi password "YOUR_WIFI_NAME"

# Change the Wi-Fi name or priority
sudo swm wifi edit "YOUR_WIFI_NAME" --ssid "NEW_NAME"
sudo swm wifi edit "YOUR_WIFI_NAME" --priority 120

# Temporarily stop or resume using a network
sudo swm wifi disable "YOUR_WIFI_NAME"
sudo swm wifi enable "YOUR_WIFI_NAME"

# Remove a saved network
sudo swm wifi remove "YOUR_WIFI_NAME"

Higher priority numbers are preferred. The default priority is 100.

For scripts, read a password from standard input so it does not appear in the process list:

printf '%s' "$WIFI_PASSWORD" | sudo swm wifi add "YOUR_WIFI_NAME" --password-stdin

Edit the raw config

Open the real JSON config in your terminal editor:

sudo swm config edit

The command checks the JSON before saving it. Other useful commands are:

sudo swm config check
sudo swm config show

config show hides passwords. The config file is /etc/smart-wifi-manager/config.json.

Dashboard access

Check its current state:

sudo swm dashboard status

Allow access from your LAN or VPN:

sudo swm dashboard expose

dashboard expose listens on port 9080. The first time it is exposed, it creates a browser username and password and prints the password once. Save it.

Undo exposure and return to local-only access:

sudo swm dashboard hide

Reset the browser password:

sudo swm dashboard password --user admin

The password is hidden while you type. Stop the dashboard completely with:

sudo swm dashboard off

The Wi-Fi manager keeps running when the dashboard is hidden or stopped. unexpose is an alias for hide, and reset-password is an alias for password.

The dashboard is not meant to be placed directly on the public internet. Use a trusted LAN or VPN and a firewall.

API tokens

API tokens are for scripts or fleet tools. You do not need one to use the dashboard in a browser.

sudo swm dashboard token create   # create and print once
sudo swm dashboard token status   # check whether one exists
sudo swm dashboard token rotate   # replace and print once
sudo swm dashboard token remove   # delete it

Save a created token immediately; the manager will not display it again. Only one API token is active at a time; rotate replaces the old token.

Example API request:

read -rsp "API token: " SWM_API_TOKEN; echo
curl -H "Authorization: Bearer $SWM_API_TOKEN" \
  http://DEVICE_IP:9080/api/v1/profiles/summary
unset SWM_API_TOKEN

Useful service commands

sudo systemctl status smart-wifi-manager
sudo journalctl -u smart-wifi-manager -n 50
cat /run/smart-wifi-manager/status.json

Manager modes:

  • manage: scan and connect automatically.
  • observe: scan and report without switching.
  • disabled: pause Wi-Fi management.

Change the mode in the dashboard under Advanced settings, or edit the raw config.

More documentation

Fleet bundle operations are documented in the CLI reference. They remain available under swm profile but are not needed for normal single-computer use.

Development

python3 -m pytest tests -q
bash -n install.sh configure_smart_wifi_manager.sh smart-wifi-manager.sh
(cd dashboard && go test ./...)

Apache-2.0 license. See LICENSE.

About

Field-ready Wi-Fi profile manager for Linux drones and robots with scan, priority, fleet sync, and safe NetworkManager control.

Topics

Resources

Contributing

Security policy

Stars

13 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages