Skip to content
Snippets Groups Projects

Add w1f1 app & replace wifi in settings menu

Merged ave requested to merge ave/flow3r-firmware:add-wifi-app into main
5 unresolved threads
1 file
+ 20
5
Compare changes
  • Side-by-side
  • Inline
@@ -42,7 +42,10 @@ class WifiApp(Application):
def on_enter(self, vm: Optional[ViewManager]) -> None:
super().on_enter(vm)
self._connection_timer = 10
self._scan_timer = 0
self._iface = network.WLAN(network.STA_IF)
self._current_ssid = None
self._current_psk = None
self.input._ignore_pressed()
# TODO: big error display
@@ -166,19 +169,19 @@ class WifiApp(Application):
if ssid in self._wifi_config["networks"]:
psk = self._wifi_config["networks"][ssid]["psk"]
self._current_ssid = ssid
self._current_psk = psk
try:
self._is_connecting = ssid
self._iface.connect(
ssid,
psk,
)
self.update_settings_json(ssid, psk)
if ssid not in self._wifi_config["networks"]:
self.add_to_config_json(ssid, psk)
self._status_text = "connecting"
except OSError as e:
self._status_text = str(e)
self._is_connecting = False
self._status_text = "connecting"
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
@@ -192,11 +195,18 @@ class WifiApp(Application):
):
self._wlan_offset += 1
if not self._nearby_wlans and self._iface.active():
if not self._nearby_wlans and self._iface.active() and self._scan_timer <= 0:
self._status_text = "scanning"
self.scan_wifi()
self._wlan_offset = 0
self._status_text = "ready"
self._scan_timer = 1
if not self._nearby_wlans:
self._iface.disconnect()
if not self._nearby_wlans:
self._scan_timer -= delta_ms / 1000
if ins.captouch.petals[0].pressed:
if not self._petal_pressed.get(0, False):
@@ -246,6 +256,11 @@ class WifiApp(Application):
if self._iface.isconnected():
self._connection_timer = 10
self._is_connecting = False
if self._current_ssid:
self.update_settings_json(self._current_ssid, self._current_psk)
if self._current_ssid not in self._wifi_config["networks"]:
self.add_to_config_json(self._current_ssid, self._current_psk)
elif self._connection_timer <= 0:
self._iface.disconnect()
self._status_text = "conn timed out"
Loading