v.0.10.0 redesign prj structure, multi dev containers
This commit is contained in:
3
pico-client/web/__init__.py
Normal file
3
pico-client/web/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .wlan import Wlan
|
||||
|
||||
__all__=["Wlan"]
|
||||
22
pico-client/web/wlan.py
Normal file
22
pico-client/web/wlan.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import time
|
||||
import network # type: ignore
|
||||
|
||||
API_KEY = "3545ce42d0ba436e8dc164532250410"
|
||||
ACTUAL_WEATHER_URL = "http://api.weatherapi.com/v1/current.json?key={API_KEY}&q={city}&aqi=yes&lang={lang}"
|
||||
|
||||
|
||||
class Wlan:
|
||||
def __init__(self):
|
||||
print("Wlan::__init__")
|
||||
self.wlan = network.WLAN(network.STA_IF)
|
||||
|
||||
def connect(self, ssid: str, password: str):
|
||||
self.wlan.active(True)
|
||||
self.wlan.connect(ssid, password)
|
||||
|
||||
while not self.wlan.isconnected:
|
||||
print("connecting, please wait ...")
|
||||
time.sleep(1)
|
||||
|
||||
time.sleep(0.25)
|
||||
print("connected! IP=", self.wlan.ifconfig()[0])
|
||||
Reference in New Issue
Block a user