Fix auth mode for AP, fixes #145

pull/163/head
Thorsten von Eicken 9 years ago
parent 23877f5ea7
commit 6ccca3ef9c
  1. 10
      README.adoc
  2. 6
      esp-link/cgiwifi.c
  3. 42
      html/wifi/wifiAp.html
  4. 12
      html/wifi/wifiAp.js

@ -171,6 +171,16 @@ to join its network to configure it. The short version is:
you reconnect your laptop/phone to your normal network and access esp-link via its hostname you reconnect your laptop/phone to your normal network and access esp-link via its hostname
or IP address or IP address
#### Notes on using AP (access point) mode
Esp-link does not support STA+AP mode, however it does support STA mode and AP mode. What happens
is that STA+AP mode is used at boot and when making STA changes to allow for recovery: the AP
mode stays on for a while so you can connect to it and fix the STA mode. Once STA has connected,
esp-link switches to STA-only mode. There is no setting to stay in STA+AP mode. So... if you want
to use AP ensure you set esp-link to AP-only mode. If you want STA+AP mode you're gonna have to
modify the source for yourself. (This stuff is painful to test and rather tricky, so don't expect
the way it works to change.)
### LED indicators ### LED indicators
Assuming appropriate hardware attached to GPIO pins, the green "conn" LED will show the wifi Assuming appropriate hardware attached to GPIO pins, the green "conn" LED will show the wifi

@ -551,6 +551,7 @@ int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
if (checkString(buff) && len>7 && len<=64) { if (checkString(buff) && len>7 && len<=64) {
// String preprocessing done in client side, wifiap.js line 31 // String preprocessing done in client side, wifiap.js line 31
os_memcpy(apconf.password, buff, len); os_memcpy(apconf.password, buff, len);
os_printf("Setting AP password len=%d\n", len);
} else if (len != 0) { } else if (len != 0) {
jsonHeader(connData, 400); jsonHeader(connData, 400);
httpdSend(connData, "PASSWORD not valid or out of range", -1); httpdSend(connData, "PASSWORD not valid or out of range", -1);
@ -562,19 +563,22 @@ int ICACHE_FLASH_ATTR cgiApSettingsChange(HttpdConnData *connData) {
len=httpdFindArg(connData->getArgs, "ap_authmode", buff, sizeof(buff)); len=httpdFindArg(connData->getArgs, "ap_authmode", buff, sizeof(buff));
if (len > 0) { if (len > 0) {
int value = atoi(buff); int value = atoi(buff);
if(value >= 0 && value <= 4){ if (value > 0 && value <= 4) {
apconf.authmode = value; apconf.authmode = value;
} else { } else {
// If out of range set by default // If out of range set by default
os_printf("Forcing AP authmode to WPA_WPA2_PSK\n");
apconf.authmode = 4; apconf.authmode = 4;
} }
} else { } else {
// Valid password but wrong auth mode, default 4 // Valid password but wrong auth mode, default 4
os_printf("Forcing AP authmode to WPA_WPA2_PSK\n");
apconf.authmode = 4; apconf.authmode = 4;
} }
} else { } else {
apconf.authmode = 0; apconf.authmode = 0;
} }
os_printf("Setting AP authmode=%d\n", apconf.authmode);
// Set max connection number // Set max connection number
len=httpdFindArg(connData->getArgs, "ap_maxconn", buff, sizeof(buff)); len=httpdFindArg(connData->getArgs, "ap_maxconn", buff, sizeof(buff));
if(len>0){ if(len>0){

@ -31,7 +31,6 @@
<div id="AP_Settings-spinner" class="spinner spinner-small"></div> <div id="AP_Settings-spinner" class="spinner spinner-small"></div>
<form action="#" id="AP_Settings-form" class="pure-form" hidden> <form action="#" id="AP_Settings-form" class="pure-form" hidden>
<!-- <input type="text" id="conn_check" name="ap_connex" value="0" hidden>-->
<legend>Soft-AP main settings, use with care!</legend> <legend>Soft-AP main settings, use with care!</legend>
<div class="pure-form-stacked"> <div class="pure-form-stacked">
@ -47,21 +46,17 @@
</div> </div>
<div class="pure-form-stacked"> <div class="pure-form-stacked">
<legend>Soft-AP Advanced Settings</legend> <label>Soft-AP Auth Mode</label>
</div> <select name="ap_authmode" href="#">
<option value="0">OPEN</option>
<div class="form-horizontal"> <option value="1">WEP</option>
<label for="AP_Settings-ron" style="margin-right:1em"> <option value="2">WPA_PSK</option>
<input type="radio" name="ap" value="on" id="AP_Settings-ron"/> <option value="3">WPA2_PSK</option>
Show </label> <option value="4">WPA_WPA2_PSK</option>
<label for="AP_Settings-roff" style="margin-right:1em"> </select>
<input type="radio" name="ap" value="off" id="AP_Settings-roff"/> <div class="popup">Default WPA_WPA2_PSK</div>
Hide </label>
</div> </div>
<div id="AP_Settings-off" class="pure-form-stacked"></div>
<div id="AP_Settings-on" class="pure-form-stacked">
<div class="pure-form-stacked"> <div class="pure-form-stacked">
<label>Soft-AP Max Connections</label> <label>Soft-AP Max Connections</label>
<input type="text" name="ap_maxconn" /> <input type="text" name="ap_maxconn" />
@ -74,25 +69,11 @@
<div class="popup">Between 100 - 60000 ms ( default 100ms )</div> <div class="popup">Between 100 - 60000 ms ( default 100ms )</div>
</div> </div>
<div class="pure-form-stacked">
<label>Soft-AP Auth Mode</label>
<select name="ap_authmode" href="#">
<option value="0">OPEN</option>
<option value="1">WEP</option>
<option value="2">WPA_PSK</option>
<option value="3">WPA2_PSK</option>
<option value="4">WPA_WPA2_PSK</option>
</select>
<div class="popup">Default WPA_WPA2_PSK</div>
</div>
<div class="form-horizontal"> <div class="form-horizontal">
<label><input type="checkbox" name="ap_hidden" />Soft-AP SSID hidden</label> <label><input type="checkbox" name="ap_hidden" />Soft-AP SSID hidden</label>
<div class="popup">Check this box to hide you Soft-AP SSID ( default Not Hidden )</div> <div class="popup">Check this box to hide you Soft-AP SSID ( default Not Hidden )</div>
</div> </div>
</div>
<button id="AP_Settings-button" type="submit" class="pure-button button-primary"> <button id="AP_Settings-button" type="submit" class="pure-button button-primary">
Change Soft-AP settings! Change Soft-AP settings!
</button> </button>
@ -114,10 +95,7 @@ onLoad(function() {
getWifiInfo(); getWifiInfo();
// Fetch actual settings // Fetch actual settings
fetchApSettings(); fetchApSettings();
// Hide advanced settings // Wire-up form
undoApAdvanced();
bnd($("#AP_Settings-ron"), "click", doApAdvanced);
bnd($("#AP_Settings-roff"), "click", undoApAdvanced);
bnd($("#AP_Settings-form"), "submit", changeApSettings); bnd($("#AP_Settings-form"), "submit", changeApSettings);
}); });
</script> </script>

@ -83,15 +83,3 @@ function fetchApSettings() {
window.setTimeout(fetchApSettings, 1000); window.setTimeout(fetchApSettings, 1000);
}); });
} }
function doApAdvanced() {
$('#AP_Settings-on').removeAttribute('hidden');
$("#AP_Settings-off").setAttribute("hidden", "");
$("#AP_Settings-roff").removeAttribute("checked");
}
function undoApAdvanced(){
$("#AP_Settings-on").setAttribute("hidden", "");
$("#AP_Settings-off").removeAttribute("hidden");
$("#AP_Settings-roff").setAttribute("checked", "");
}

Loading…
Cancel
Save