Skip to content

Commit

Permalink
Merge pull request #54 from eamars/fix_wifi_no_pw_bug
Browse files Browse the repository at this point in the history
Wifi bug fix
  • Loading branch information
eamars authored Oct 17, 2024
2 parents a255903 + b0efc00 commit 0d79cfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
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

0 comments on commit 0d79cfa

Please sign in to comment.