Skip to content
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

Wifi bug fix #54

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions src/html/wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,6 @@ <h1>Configure WiFi</h1>


<script>
function validateForm(form) {
var isValid = true;
allInputs = form.getElementsByTagName("input");
for (const input of allInputs) {
if (input.value == "") {
isValid = false;
input.classList.add("invalid");
}
else {
input.classList.remove("invalid");
}
}

return isValid;
}

// Submit the form data to the action URI
function putForm(targetForm, saveToEeprom) {
Expand Down Expand Up @@ -232,16 +217,11 @@ <h1>Configure WiFi</h1>

const form = document.getElementById("wifi-config")

// First validate the input
const isValid = validateForm(form);

if (isValid) {
putForm(form, true);
putForm(form, true);

// Send reboot request
const uri = "/rest/system_control?s5=true";
fetch(uri);
}
// Send reboot request
const uri = "/rest/system_control?s5=true";
fetch(uri);
})

function populateWifiConfig() {
Expand Down
12 changes: 9 additions & 3 deletions src/wireless.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,20 @@ void wireless_task(void *p) {
// Show the current joining SSID
sprintf(first_line_buffer, ">%s", wireless_config.eeprom_wireless_metadata.ssid);

// If the authentication method is open then the password is NULL
const char * wifi_password = NULL;
if (wireless_config.eeprom_wireless_metadata.auth != AUTH_OPEN) {
wifi_password = wireless_config.eeprom_wireless_metadata.pw;
}

// Retry within timeframe
TickType_t stop_tick = xTaskGetTickCount() + pdMS_TO_TICKS(wireless_config.eeprom_wireless_metadata.timeout_ms);
while (xTaskGetTickCount() < stop_tick) {
int resp;
resp = cyw43_arch_wifi_connect_timeout_ms(wireless_config.eeprom_wireless_metadata.ssid,
wireless_config.eeprom_wireless_metadata.pw,
get_cyw43_auth(wireless_config.eeprom_wireless_metadata.auth),
wireless_config.eeprom_wireless_metadata.timeout_ms);
wifi_password,
get_cyw43_auth(wireless_config.eeprom_wireless_metadata.auth),
wireless_config.eeprom_wireless_metadata.timeout_ms);
if (resp == PICO_OK) {
wireless_config.current_wireless_state = WIRELESS_STATE_STA_MODE_LISTEN;
break;
Expand Down