Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
|
|
|
<title>WiFi Login</title>
|
|
|
|
<style type=text/css>
|
|
|
|
* {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
html,
|
|
|
|
body {
|
|
|
|
height: 100%;
|
|
|
|
font-family: sans-serif;
|
|
|
|
text-align: center;
|
|
|
|
background: #444d44;
|
|
|
|
}
|
|
|
|
|
|
|
|
#content {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 320px;
|
|
|
|
height: 480px;
|
|
|
|
margin: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
input,
|
|
|
|
button,
|
|
|
|
select {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldset {
|
|
|
|
border: 0;
|
|
|
|
box-shadow: 0 0 15px 1px rgba(0, 0, 0, .4);
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 20px 30px;
|
|
|
|
background: #fff;
|
|
|
|
min-height: 320px;
|
|
|
|
margin: -1px;
|
|
|
|
}
|
|
|
|
|
|
|
|
input {
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
color: #222;
|
|
|
|
font: 16px monospace;
|
|
|
|
padding: 15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
select {
|
|
|
|
font: 16px monospace;
|
|
|
|
background-color: transparent;
|
|
|
|
padding: 15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
|
|
|
color: #fff;
|
|
|
|
border: 0;
|
|
|
|
border-radius: 3px;
|
|
|
|
cursor: pointer;
|
|
|
|
display: block;
|
|
|
|
font: 16px sans-serif;
|
|
|
|
text-decoration: none;
|
|
|
|
padding: 10px 5px;
|
|
|
|
background: #31b457;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
button:focus,
|
|
|
|
button:hover {
|
|
|
|
box-shadow: 0 0 0 2px #fff, 0 0 0 3px #31b457;
|
|
|
|
}
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
font-size: 16px;
|
|
|
|
color: #666;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
h4 {
|
|
|
|
color: #ccc;
|
|
|
|
padding: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.utility {
|
|
|
|
float: right;
|
|
|
|
clear: both;
|
|
|
|
max-width: 75%;
|
|
|
|
font-size: 13px;
|
|
|
|
color: #222;
|
|
|
|
margin: 10px 0;
|
|
|
|
padding: 5px 10px;
|
|
|
|
background: #ccc;
|
|
|
|
}
|
|
|
|
|
|
|
|
.utility:focus,
|
|
|
|
.utility:hover {
|
|
|
|
box-shadow: 0 0 0 2px #fff, 0 0 0 3px #ccc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#dropdown,
|
|
|
|
#f2,
|
|
|
|
#f3,
|
|
|
|
#bk2 {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
#dropdown {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
overflow: auto;
|
|
|
|
height: 51px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#aplist {
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
font-family: monospace;
|
|
|
|
padding: 10px 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#arrow {
|
|
|
|
color: #888;
|
|
|
|
position: absolute;
|
|
|
|
right: 8px;
|
|
|
|
top: 15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#i {
|
2016-12-01 22:12:47 +01:00
|
|
|
text-align: center;
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div id=content>
|
|
|
|
<fieldset>
|
|
|
|
<div id=deviceId></div>
|
|
|
|
<div id=f1>
|
|
|
|
<h3>Connect device to your Wi-Fi</h3>
|
2019-07-08 21:48:16 +02:00
|
|
|
<form action="/setwifi" method="POST">
|
|
|
|
<button id=networks type=button class=utility></button>
|
|
|
|
<div id=dropdown>
|
|
|
|
<span id=arrow>▼</span>
|
|
|
|
<select id=aplist name=aplist></select>
|
|
|
|
</div>
|
|
|
|
<input id=ssid name=wifi_ssid type=text autocorrect=off autocapitalize=none placeholder='Wi-Fi Name' />
|
2020-09-18 23:47:52 +02:00
|
|
|
<input id=wifi_password name=wifi_password type=password autocorrect=off autocapitalize=none autocomplete=off placeholder=Password />
|
2019-07-08 21:48:16 +02:00
|
|
|
<!-- You can add inputs here and have them pop up in your lua code through the file eus_params.lua -->
|
|
|
|
<input type="submit" value="Save"/>
|
|
|
|
</form>
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
</div>
|
|
|
|
<div id=f2>
|
|
|
|
<h1>Success!</h1>
|
|
|
|
<div id=i>
|
2016-12-01 22:12:47 +01:00
|
|
|
<h3>Your device has successfully connected to the Wi-Fi network.<br /><br/>You may now close this web page.</h3>
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id=f3>
|
|
|
|
<h2>Trying...</h2>
|
|
|
|
<button id=bk2 type=button class='utility'>Go Back to Wi-Fi Setup</button>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<h4 id='st'>Updating Status...</h4>
|
|
|
|
</div>
|
|
|
|
<script>
|
2016-12-01 22:12:47 +01:00
|
|
|
var $ = function (selector) { return document.querySelector(selector); };
|
|
|
|
var ab = $('#networks'), ap = $('#aplist');
|
|
|
|
var stopAll = false, ra, rs, submitted = false;
|
|
|
|
|
2019-07-08 21:48:16 +02:00
|
|
|
$.urlParam = function (name) {
|
|
|
|
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
|
|
|
if (results == null) { return null;}
|
|
|
|
else { return decodeURI(results[1]) || 0;}
|
|
|
|
}
|
2016-12-01 22:12:47 +01:00
|
|
|
function show(f, y) {
|
|
|
|
if (y == null) y = f;
|
|
|
|
$(f).style.display = y == f ? 'block' : 'none';
|
|
|
|
}
|
|
|
|
function hide(f) {
|
|
|
|
$(f).style.display = 'none';
|
|
|
|
}
|
|
|
|
function to(cb, x) {
|
|
|
|
return setTimeout(cb, 1000 * x);
|
|
|
|
}
|
|
|
|
function refr() {
|
|
|
|
if (!stopAll)
|
|
|
|
fetch('/status.json?n=' + Math.random(), 'GET', newSt, 2);
|
|
|
|
}
|
|
|
|
function cur(f) {
|
|
|
|
show('#f1', f);
|
|
|
|
show('#f2', f);
|
|
|
|
show('#f3', f);
|
|
|
|
}
|
|
|
|
function newSt(s, d) {
|
|
|
|
clearTimeout(rs);
|
|
|
|
rs = to(refr, 3);
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
if (s != 200) {
|
|
|
|
$('#st').innerText = 'Awaiting Status (' + s + ')';
|
|
|
|
} else {
|
|
|
|
if (typeof d === 'string') {
|
|
|
|
d = JSON.parse(d);
|
|
|
|
}
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
$('#deviceId').innerText = "Device: " + d.deviceid;
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
var c = d.pairing;
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
var st = [
|
|
|
|
'Idle',
|
|
|
|
'Connecting...',
|
|
|
|
'Failed - wrong password',
|
|
|
|
'Failed - network not found',
|
|
|
|
'Failed',
|
|
|
|
'Wi-Fi successfully connected!'
|
|
|
|
][d.status];
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
if (st == null)
|
|
|
|
st = "";
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
if (!submitted && d.status > 1 && d.status < 5)
|
|
|
|
st = "Need a valid Network and Password";
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
$('#st').innerText = st;
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
|
2016-12-01 22:12:47 +01:00
|
|
|
if (d.status === 5) {
|
|
|
|
cur('#f2');
|
|
|
|
stopAll = true;
|
|
|
|
clearTimeout(ra);
|
|
|
|
} else if (d.status > 1) {
|
|
|
|
cur('#f1');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function fetch(url, method, callback, time_out) {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.onloadend = function () {
|
|
|
|
callback(xhr.status, xhr.responseText);
|
|
|
|
}
|
|
|
|
xhr.ontimeout = function () {
|
|
|
|
callback(-1, null);
|
|
|
|
}
|
|
|
|
xhr.open(method, url, true);
|
|
|
|
xhr.setRequestHeader('Accept', 'application/json');
|
|
|
|
xhr.timeout = (time_out || 10) * 1000;
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
function gotAp(s, json) {
|
2020-09-18 23:47:52 +02:00
|
|
|
var list;
|
|
|
|
if (s === 200 && json != null) {
|
|
|
|
if (typeof json === 'string' && json.length > 0) {
|
|
|
|
list = JSON.parse(json);
|
|
|
|
} else if (typeof json === 'object') {
|
|
|
|
list = json;
|
|
|
|
}
|
2016-12-01 22:12:47 +01:00
|
|
|
|
2020-09-18 23:47:52 +02:00
|
|
|
list.sort(function (a, b) {
|
|
|
|
return b.rssi - a.rssi;
|
|
|
|
});
|
|
|
|
var ops = '<option>Select a Network...</option>';
|
|
|
|
var seen = {};
|
|
|
|
for (var i = 0; i < list.length; ++i) {
|
|
|
|
var ssid = list[i].ssid;
|
|
|
|
if (!seen[ssid]) {
|
|
|
|
seen[ssid] = 1;
|
|
|
|
ops += '<option data-auth=' + list[i].auth + '>' +
|
|
|
|
ssid.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<") + '</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ap.innerHTML = ops;
|
|
|
|
ab.disabled = false;
|
|
|
|
togAp(null, true);
|
|
|
|
ab.onclick = togAp;
|
|
|
|
} else {
|
|
|
|
ab.innerText = 'No networks found (' + s + ')';
|
|
|
|
ra = to(refrAp, 5);
|
|
|
|
}
|
2016-12-01 22:12:47 +01:00
|
|
|
}
|
|
|
|
function togAp(ev, force) {
|
|
|
|
if (!force || ap.style.display == 'block') {
|
2020-09-18 23:47:52 +02:00
|
|
|
hide('#dropdown');
|
|
|
|
show('#ssid');
|
|
|
|
ab.innerText = 'Scan for Networks';
|
|
|
|
ab.onclick = refrAp;
|
2016-12-01 22:12:47 +01:00
|
|
|
} else {
|
2020-09-18 23:47:52 +02:00
|
|
|
show('#dropdown');
|
|
|
|
hide('#ssid');
|
|
|
|
ab.innerText = 'Manual Entry';
|
2016-12-01 22:12:47 +01:00
|
|
|
}
|
2020-09-18 23:47:52 +02:00
|
|
|
let pw = $('#wifi_password');
|
|
|
|
pw.placeholder = "Password";
|
|
|
|
pw.disabled = false;
|
|
|
|
pw.required = true;
|
2016-12-01 22:12:47 +01:00
|
|
|
}
|
|
|
|
function refrAp() {
|
|
|
|
ab.innerText = 'Searching for networks...';
|
|
|
|
ab.disabled = true;
|
|
|
|
ap.innerHTML = '<option disabled>Scanning...</option>';
|
|
|
|
if (!stopAll)
|
|
|
|
fetch('/aplist?n=' + Math.random(), 'GET', gotAp, 10);
|
|
|
|
}
|
|
|
|
window.onload = function() {
|
2019-07-08 21:48:16 +02:00
|
|
|
let trying = $.urlParam('trying');
|
|
|
|
ab.innerText = 'Scan for Networks';
|
|
|
|
ab.onclick = refrAp;
|
|
|
|
$('#aplist').onchange = function () {
|
2020-09-18 23:47:52 +02:00
|
|
|
$('#ssid').value = $('#aplist').value;
|
|
|
|
let pw = $('#wifi_password');
|
|
|
|
if ($('#aplist').selectedOptions[0].dataset.auth > 0) {
|
|
|
|
pw.placeholder = "Password";
|
|
|
|
pw.disabled = false;
|
|
|
|
pw.required = true;
|
|
|
|
} else {
|
|
|
|
pw.placeholder = "Open -- no password";
|
|
|
|
pw.disabled = true;
|
|
|
|
pw.required = false;
|
|
|
|
}
|
2019-07-08 21:48:16 +02:00
|
|
|
};
|
|
|
|
$('#bk2').onclick = function () {
|
|
|
|
cur('#f1')
|
|
|
|
}
|
|
|
|
rs = to(refr, 0.5);
|
|
|
|
if( trying ) cur("#f3");
|
2020-09-18 23:47:52 +02:00
|
|
|
refrAp();
|
2016-12-01 22:12:47 +01:00
|
|
|
}
|
Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
2016-11-08 21:58:33 +01:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
2019-07-08 21:48:16 +02:00
|
|
|
</html>
|