Example usage:
Get all Wi-Fi spots and connect:
import logging
from wifi_manager import WiFi
logging.basicConfig(level=logging.INFO)
wifi_spots = WiFi.scan_wifi_spots() # Get all Wi-Fi spots
for spot in wifi_spots:
if spot.public:
spot.connect() # Connect to public Wi-Fi
break
if spot.name == "my_router":
spot.connect("12345678") # Connect to private Wi-Fi
breakCustom connect to Wi-Fi:
import logging
from wifi_manager import WiFiSpot, Profile
logging.basicConfig(level=logging.INFO)
# Custom connect
profile = Profile('SSID1', 'Iphone (Ivan)', 'WPA3-Personal', False, 'password')
profile.create()
try:
profile.connect() # Try to connect to Wi-Fi
except ConnectionError: # If profile is invalid
profile.delete() # Be sure to delete the profile
else:
if WiFiSpot.check_connect(): # Check if password is correct
if not WiFiSpot.check_internet(): # Check internet
profile.delete()
else:
profile.delete()