| 298 | } |
| 299 | |
| 300 | void WifiSelectionActivity::loop() { |
| 301 | // Check scan progress |
| 302 | if (state == WifiSelectionState::SCANNING) { |
| 303 | processWifiScanResults(); |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | // Check connection progress |
| 308 | if (state == WifiSelectionState::CONNECTING || state == WifiSelectionState::AUTO_CONNECTING) { |
| 309 | checkConnectionStatus(); |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | if (state == WifiSelectionState::PASSWORD_ENTRY) { |
| 314 | // Reach here once password entry finished in subactivity |
| 315 | attemptConnection(); |
| 316 | return; |
| 317 | } |
| 318 | |
| 319 | // Handle save prompt state |
| 320 | if (state == WifiSelectionState::SAVE_PROMPT) { |
| 321 | if (mappedInput.wasPressed(MappedInputManager::Button::Up) || |
| 322 | mappedInput.wasPressed(MappedInputManager::Button::Left)) { |
| 323 | if (savePromptSelection > 0) { |
| 324 | savePromptSelection--; |
| 325 | requestUpdate(); |
| 326 | } |
| 327 | } else if (mappedInput.wasPressed(MappedInputManager::Button::Down) || |
| 328 | mappedInput.wasPressed(MappedInputManager::Button::Right)) { |
| 329 | if (savePromptSelection < 1) { |
| 330 | savePromptSelection++; |
| 331 | requestUpdate(); |
| 332 | } |
| 333 | } else if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) { |
| 334 | if (savePromptSelection == 0) { |
| 335 | // User chose "Yes" - save the password |
| 336 | RenderLock lock(*this); |
| 337 | WIFI_STORE.addCredential(selectedSSID, enteredPassword); |
| 338 | } |
| 339 | // Complete - parent will start web server |
| 340 | onComplete(true); |
| 341 | } else if (mappedInput.wasPressed(MappedInputManager::Button::Back)) { |
| 342 | // Skip saving, complete anyway |
| 343 | onComplete(true); |
| 344 | } |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | // Handle forget prompt state (connection failed with saved credentials) |
| 349 | if (state == WifiSelectionState::FORGET_PROMPT) { |
| 350 | if (mappedInput.wasPressed(MappedInputManager::Button::Up) || |
| 351 | mappedInput.wasPressed(MappedInputManager::Button::Left)) { |
| 352 | if (forgetPromptSelection > 0) { |
| 353 | forgetPromptSelection--; |
| 354 | requestUpdate(); |
| 355 | } |
| 356 | } else if (mappedInput.wasPressed(MappedInputManager::Button::Down) || |
| 357 | mappedInput.wasPressed(MappedInputManager::Button::Right)) { |
nothing calls this directly
no test coverage detected