-
Notifications
You must be signed in to change notification settings - Fork 0
Feature menu wifi ssid #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds WiFi SSID selection functionality to the ESP8266 firmware menu system. It introduces a new menu flow that allows users to scan for available WiFi networks, select an SSID, enter credentials, and view connection results.
Key changes:
- WiFi network scanning and management with RSSI-based sorting
- New menu states for SSID selection and connection result display
- Enhanced LCD character set with connection and warning symbols
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Firmware_ESP8266/lcd.h | Adds WiFi SSID selection menu, new LCD special characters, and menu navigation logic |
| Firmware_ESP8266/basic_defines.h | Defines new menu enumeration values for WiFi configuration flow |
| Firmware_ESP8266/Firmware_ESP8266.ino | Integrates WiFi handler into main loop |
| Firmware_ESP8266/ESP8266_Utils.h | Implements WiFi network scanning, tracking, and connection management |
| Firmware_ESP8266/EEPROM_Utils.h | Fixes EEPROM scheduled write timing logic |
| // each time we enter this menu. | ||
| ESP8266Utils_startWifiScanIfNeeded(); | ||
| ESP8266Utils_checkScanResults(); | ||
| static int previousCurrentIndex = 1; // Start at 1 so in the first iteration we can |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Magic number 1 is used without clear explanation. Consider defining a constant like 'INITIAL_NETWORK_INDEX' or starting at 0 with proper initialization logic.
| static int previousCurrentIndex = 1; // Start at 1 so in the first iteration we can | |
| static int previousCurrentIndex = INITIAL_NETWORK_INDEX; // Start at INITIAL_NETWORK_INDEX so in the first iteration we can |
| String mySSID = adjustedSSID; | ||
| int adjustedSSIDindex = ESP8266Utils_getIndexBySsid(adjustedSSID); | ||
| if (adjustedSSIDindex < 0) { | ||
| mySSID = "No hay redes"; |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded Spanish text should be replaced with a constant or configurable string for better maintainability and internationalization support.
| mySSID = "No hay redes"; | |
| mySSID = LCD_NO_NETWORKS_TEXT; |
| porcentaje = 100; // Limit to 100% | ||
| } | ||
| if (ESP8266Utils_isWifiConnected()) { | ||
| *lcdBuffer += String("WIFI: CONECTADO "); |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded Spanish text should be replaced with constants for better maintainability and internationalization support.
Firmware_ESP8266/ESP8266_Utils.h
Outdated
| seenInThisScan(true) {} | ||
| }; | ||
|
|
||
| std::vector<WifiNetworkInfo> wifiNetworks; |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variable should be declared as 'static' to limit its scope to this compilation unit, or consider using a namespace or class to encapsulate this state.
| std::vector<WifiNetworkInfo> wifiNetworks; | |
| static std::vector<WifiNetworkInfo> wifiNetworks; |
Firmware_ESP8266/ESP8266_Utils.h
Outdated
| it->notSeenCount = 0; | ||
| } | ||
|
|
||
| if (it->notSeenCount >= 5) { |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number 5 should be defined as a constant like 'MAX_UNSEEN_SCANS' for better maintainability.
| if (it->notSeenCount >= 5) { | |
| if (it->notSeenCount >= MAX_UNSEEN_SCANS) { |
Firmware_ESP8266/ESP8266_Utils.h
Outdated
| } | ||
|
|
||
| // Filtro para evitar agregar redes volátiles de 1 sola muestra | ||
| if (rssi < -80) { |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number -80 should be defined as a constant like 'MIN_RSSI_THRESHOLD' for better maintainability.
| if (rssi < -80) { | |
| if (rssi < MIN_RSSI_THRESHOLD) { |
Firmware_ESP8266/ESP8266_Utils.h
Outdated
| std::sort(wifiNetworks.begin(), wifiNetworks.end(), compareByRssiDesc); | ||
|
|
||
| if (wifiNetworks.size() > 10) { | ||
| wifiNetworks.resize(10); |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number 10 should be defined as a constant like 'MAX_TRACKED_NETWORKS' for better maintainability.
| wifiNetworks.resize(10); | |
| if (wifiNetworks.size() > MAX_TRACKED_NETWORKS) { | |
| wifiNetworks.resize(MAX_TRACKED_NETWORKS); |
| return (elapsed * 100) / WIFI_CONNECTION_TIMEOUT_MS; | ||
| } | ||
|
|
||
| void Wifi_handler() {} |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty function implementation that is called from the main loop serves no purpose and should either be implemented or removed to avoid confusion.
| void Wifi_handler() {} |
No description provided.