Merge branch 'WiFi-Manager' of https://github.com/sle118/squeezelite-esp32.git into Over_The_Air_Update

This commit is contained in:
Sebastien
2019-09-21 22:10:11 -04:00
10 changed files with 225 additions and 188 deletions

View File

@@ -2,5 +2,6 @@ idf_component_register(SRCS "dns_server.c" "http_server.c" "json.c" "wifi_manage
INCLUDE_DIRS .
REQUIRES esp_common
PRIV_REQUIRES newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant cmd_system
EMBED_FILES style.css jquery.gz code.js index.html
)
EMBED_FILES style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz
)

Binary file not shown.

Binary file not shown.

View File

@@ -6,6 +6,6 @@
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the SDK documents if you need to do this.
#
COMPONENT_EMBED_FILES := style.css jquery.gz code.js index.html
COMPONENT_EMBED_FILES := style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz
CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_DEBUG
COMPONENT_ADD_INCLUDEDIRS := .

View File

@@ -52,8 +52,14 @@ static TaskHandle_t task_http_server = NULL;
*/
extern const uint8_t style_css_start[] asm("_binary_style_css_start");
extern const uint8_t style_css_end[] asm("_binary_style_css_end");
extern const uint8_t jquery_gz_start[] asm("_binary_jquery_gz_start");
extern const uint8_t jquery_gz_end[] asm("_binary_jquery_gz_end");
extern const uint8_t jquery_gz_start[] asm("_binary_jquery_min_js_gz_start");
extern const uint8_t jquery_gz_end[] asm("_binary_jquery_min_js_gz_end");
extern const uint8_t popper_gz_start[] asm("_binary_popper_min_js_gz_start");
extern const uint8_t popper_gz_end[] asm("_binary_popper_min_js_gz_end");
extern const uint8_t bootstrap_js_gz_start[] asm("_binary_bootstrap_min_js_gz_start");
extern const uint8_t bootstrap_js_gz_end[] asm("_binary_bootstrap_min_js_gz_end");
extern const uint8_t bootstrap_css_gz_start[] asm("_binary_bootstrap_min_css_gz_start");
extern const uint8_t bootstrap_css_gz_end[] asm("_binary_bootstrap_min_css_gz_end");
extern const uint8_t code_js_start[] asm("_binary_code_js_start");
extern const uint8_t code_js_end[] asm("_binary_code_js_end");
extern const uint8_t index_html_start[] asm("_binary_index_html_start");
@@ -64,7 +70,10 @@ extern const uint8_t index_html_end[] asm("_binary_index_html_end");
const static char http_html_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/html\n\n";
const static char http_css_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/css\nCache-Control: public, max-age=31536000\n\n";
const static char http_js_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\n\n";
const static char http_jquery_gz_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\nAccept-Ranges: bytes\nContent-Length: 29995\nContent-Encoding: gzip\n\n";
const static char http_jquery_gz_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\nAccept-Ranges: bytes\nContent-Length: 30604\nContent-Encoding: gzip\n\n";
const static char http_popper_gz_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\nAccept-Ranges: bytes\nContent-Length: 7487\nContent-Encoding: gzip\n\n";
const static char http_bootstrap_js_gz_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\nAccept-Ranges: bytes\nContent-Length: 15412\nContent-Encoding: gzip\n\n";
const static char http_bootstrap_css_gz_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/css\nAccept-Ranges: bytes\nContent-Length: 25925\nContent-Encoding: gzip\n\n";
const static char http_400_hdr[] = "HTTP/1.1 400 Bad Request\nContent-Length: 0\n\n";
const static char http_404_hdr[] = "HTTP/1.1 404 Not Found\nContent-Length: 0\n\n";
const static char http_503_hdr[] = "HTTP/1.1 503 Service Unavailable\nContent-Length: 0\n\n";
@@ -173,13 +182,25 @@ void http_server_netconn_serve(struct netconn *conn) {
netconn_write(conn, http_js_hdr, sizeof(http_js_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, code_js_start, code_js_end - code_js_start, NETCONN_NOCOPY);
}
else if(strstr(line, "GET /style.css ")) {
netconn_write(conn, http_css_hdr, sizeof(http_css_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, style_css_start, style_css_end - style_css_start, NETCONN_NOCOPY);
}
else if(strstr(line, "GET /jquery.js ")) {
netconn_write(conn, http_jquery_gz_hdr, sizeof(http_jquery_gz_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, jquery_gz_start, jquery_gz_end - jquery_gz_start, NETCONN_NOCOPY);
}
else if(strstr(line, "GET /style.css ")) {
netconn_write(conn, http_css_hdr, sizeof(http_css_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, style_css_start, style_css_end - style_css_start, NETCONN_NOCOPY);
else if(strstr(line, "GET /popper.js ")) {
netconn_write(conn, http_popper_gz_hdr, sizeof(http_popper_gz_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, popper_gz_start, popper_gz_end - popper_gz_start, NETCONN_NOCOPY);
}
else if(strstr(line, "GET /bootstrap.js ")) {
netconn_write(conn, http_bootstrap_js_gz_hdr, sizeof(http_bootstrap_js_gz_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, bootstrap_js_gz_start, bootstrap_js_gz_end - bootstrap_js_gz_start, NETCONN_NOCOPY);
}
else if(strstr(line, "GET /bootstrap.css ")) {
netconn_write(conn, http_bootstrap_css_gz_hdr, sizeof(http_bootstrap_css_gz_hdr) - 1, NETCONN_NOCOPY);
netconn_write(conn, bootstrap_css_gz_start, bootstrap_css_gz_end - bootstrap_css_gz_start, NETCONN_NOCOPY);
}
//dynamic stuff

View File

@@ -1,68 +1,192 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="/style.css">
<script src="/jquery.js"></script>
<script src="/code.js"></script>
<title>esp32-wifi-manager</title>
</head>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="/bootstrap.css">
<link rel="stylesheet" href="/style.css">
<script src="/jquery.js"></script>
<script src="/bootstrap.js"></script>
<script src="/popper.js"></script>
<script src="/code.js"></script>
<body>
<div id="app">
<div id="app-wrap">
<div id="command_line">
<header>
<h1>Startup command</h1>
</header>
<h2>
<div id="autoexec" class="toggle">
<label>Run squeezelite automatically at boot
<input id="autoexec-cb" type="checkbox" checked="checked" onclick='handleClick(this);'/><span class="slider"></span>
</label>
</div>
</h2>
<!-- TODO delete -->
<link rel="stylesheet" href="/test/bootstrap.min.css">
<script src="/test/jquery.min.js"></script>
<script src="/test/bootstrap.min.js"></script>
<script src="/test/popper.min.js"></script>
<div id="autoexec-command">
<div id="audioout" class="toggle-buttons">
<h2>Audio output</h2>
<input type="radio" id="i2s" name="audio" checked='checked' />
<label for="i2s">I2S</label>
<input type="radio" id="spdif" name="audio" />
<label for="spdif">SPDIF</label>
<input type="radio" id="bt" name="audio" />
<label for="bt">Bluetooth</label>
</div>
<div id="btsinkdiv">
<input id="btsink" type="text" value="BT sink name" />
</div>
<div>
<h2>Player name</h2>
<input id="player" type="text" value="squeezelite" />
</div>
<div>
<h2>Optional setting (e.g. for LMS IP address)</h2>
<input id="optional" type="text" value="" placeholder="-s 192.168.0.1" />
</div>
<title>esp32-wifi-manager</title>
</head>
<div class="buttons">
<input id="generate-command" type="button" value="Generate" />
</div>
<body>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tab-wifi">WiFi</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-startup">Startup</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-audio">Audio + LMS</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-system">System</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-credits">Credits</a>
</li>
</ul>
<h2>Squeezelite command to run</h2>
<section id="command-list">
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active show" id="tab-wifi">
<div id="wifi">
<div id="wifi-status">
<h2>Connected to:</h2>
<section id="connected-to">
<div class="ape"><div class="w0"><div class="pw"><span></span></div></div></div>
</section>
</div>
<h2>Manual connect</h2>
<section id="manual_add">
<div class="ape">ADD (HIDDEN) SSID</div>
</section>
<h2>or choose a network...</h2>
<section id="wifi-list">
</section>
</div>
<div id="connect_manual">
<header>
<h1>Enter Details</h1>
</header>
<h2>Manual Connection</h2>
<section>
<input id="manual_ssid" type="text" placeholder="SSID" value="">
<input id="manual_pwd" type="password" placeholder="Password" value="">
</section>
<div class="buttons">
<input id="manual_join" type="button" value="Join" data-connect="manual" />
<input id="manual_cancel" type="button" value="Cancel"/>
</div>
</div>
<div id="connect">
<header>
<h1>Enter Password</h1>
</header>
<h2>Password for <span id="ssid-pwd"></span></h2>
<section>
<input id="pwd" type="password" placeholder="Password" value="">
</section>
<div class="buttons">
<input id="join" type="button" value="Join" />
<input id="cancel" type="button" value="Cancel"/>
</div>
</div>
<div id="connect-wait">
<header>
<h1>Please wait...</h1>
</header>
<h2>Connecting to <span id="ssid-wait"></span></h2>
<section>
<div id="loading">
<div class="spinner"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>
<p class="tctr">You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.</p>
</div>
<div id="connect-success">
<h3 class="gr">Success!</h3>
</div>
<div id="connect-fail">
<h3 class="rd">Connection failed</h3>
<p class="tctr">Please double-check wifi password if any and make sure the access point has good signal.</p>
</div>
</section>
<div class="buttons">
<input id="ok-connect" type="button" value="OK" class="ctr" />
</div>
</div>
<div id="connect-details">
<div id="connect-details-wrap">
<header>
<h1></h1>
</header>
<h2></h2>
<section>
<div class="buttons">
<input id="disconnect" type="button" value="Disconnect" class="ctr"/>
</div>
</section>
<h2>IP Address</h2>
<section>
<div class="ape brdb">IP Address:<div id="ip" class="fr"></div></div>
<div class="ape brdb">Subnet Mask:<div id="netmask" class="fr"></div></div>
<div class="ape">Default Gateway:<div id="gw" class="fr"></div></div>
</section>
<div class="buttons">
<input id="ok-details" type="button" value="OK" class="ctr" />
</div>
</div>
<div id="diag-disconnect" class="diag-box">
<div class="diag-box-win">
<p>Are you sure you would like to disconnect from this wifi?</p>
<div class="buttons">
<input id="no-disconnect" type="button" value="No" />
<input id="yes-disconnect" type="button" value="Yes" />
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="tab-startup">
<h2>Run squeezelite automatically at boot</h2>
<div id="autoexec" class="toggle">
<label>
<input id="autoexec-cb" type="checkbox" checked="checked" onclick='handleClick(this);'/><span class="slider"></span>
</label>
</div>
</div>
<div class="tab-pane fade" id="tab-audio">
<div id="autoexec-command">
<div id="audioout" class="toggle-buttons">
<h2>Audio output</h2>
<input type="radio" id="i2s" name="audio" checked='checked' />
<label for="i2s">I2S</label>
<input type="radio" id="spdif" name="audio" />
<label for="spdif">SPDIF</label>
<input type="radio" id="bt" name="audio" />
<label for="bt">Bluetooth</label>
</div>
<div id="btsinkdiv">
<input id="btsink" type="text" value="BT sink name" />
</div>
<div>
<h2>Player name</h2>
<input id="player" type="text" value="squeezelite" />
</div>
<div>
<h2>Optional setting (e.g. for LMS IP address)</h2>
<input id="optional" type="text" value="" placeholder="-s 192.168.0.1" />
</div>
<div class="buttons">
<input id="update-command" type="button" value="Save" />
<input id="generate-command" type="button" value="Generate" />
</div>
<h2>Squeezelite command to run</h2>
<section id="command-list">
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
</section>
</div>
</div>
<div class="tab-pane fade" id="tab-system">
<div id="recoverydiv">
<header><h1>System management</h1></header>
<h2>Check for firmware upgrade</h2>
<div class="buttons">
<input type="button" id="fwcheck" value="Check" onclick='handleClick(this);' />
@@ -86,127 +210,22 @@
<input type="button" id="reboot" value="Reboot" onclick='handleClick(this);' />
</div>
</div>
</div>
<div id="wifi">
<header>
<h1>Wi-Fi</h1>
</header>
<div id="wifi-status">
<h2>Connected to:</h2>
<section id="connected-to">
<div class="ape"><div class="w0"><div class="pw"><span></span></div></div></div>
</section>
</div>
<h2>Manual connect</h2>
<section id="manual_add">
<div class="ape">ADD (HIDDEN) SSID<div>
</section>
<h2>or choose a network...</h2>
<section id="wifi-list">
</section>
<div id="pwrdby"><em>Powered by </em><a id="acredits" href="#"><strong>esp32-wifi-manager</strong></a>.</div>
</div>
<div id="connect_manual">
<header>
<h1>Enter Details</h1>
</header>
<h2>Manual Connection</h2>
<section>
<input id="manual_ssid" type="text" placeholder="SSID" value="">
<input id="manual_pwd" type="password" placeholder="Password" value="">
</section>
<div class="buttons">
<input id="manual_join" type="button" value="Join" data-connect="manual" />
<input id="manual_cancel" type="button" value="Cancel"/>
</div>
</div>
<div id="connect">
<header>
<h1>Enter Password</h1>
</header>
<h2>Password for <span id="ssid-pwd"></span></h2>
<section>
<input id="pwd" type="password" placeholder="Password" value="">
</section>
<div class="buttons">
<input id="join" type="button" value="Join" />
<input id="cancel" type="button" value="Cancel"/>
</div>
</div>
<div id="connect-wait">
<header>
<h1>Please wait...</h1>
</header>
<h2>Connecting to <span id="ssid-wait"></span></h2>
<section>
<div id="loading">
<div class="spinner"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>
<p class="tctr">You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.</p>
</div>
<div id="connect-success">
<h3 class="gr">Success!</h3>
</div>
<div id="connect-fail">
<h3 class="rd">Connection failed</h3>
<p class="tctr">Please double-check wifi password if any and make sure the access point has good signal.</p>
</div>
</section>
<div class="buttons">
<input id="ok-connect" type="button" value="OK" class="ctr" />
</div>
</div>
<div id="connect-details">
<div id="connect-details-wrap">
<header>
<h1></h1>
</header>
<h2></h2>
<section>
<div class="buttons">
<input id="disconnect" type="button" value="Disconnect" class="ctr"/>
</div>
</section>
<h2>IP Address</h2>
<section>
<div class="ape brdb">IP Address:<div id="ip" class="fr"></div></div>
<div class="ape brdb">Subnet Mask:<div id="netmask" class="fr"></div></div>
<div class="ape">Default Gateway:<div id="gw" class="fr"></div></div>
</section>
<div class="buttons">
<input id="ok-details" type="button" value="OK" class="ctr" />
</div>
</div>
<div id="diag-disconnect" class="diag-box">
<div class="diag-box-win">
<p>Are you sure you would like to disconnect from this wifi?</p>
<div class="buttons">
<input id="no-disconnect" type="button" value="No" />
<input id="yes-disconnect" type="button" value="Yes" />
</div>
</div>
</div>
</div>
</div>
</div>
<div id="credits">
<header>
<h1>About this app...</h1>
</header>
<h2></h2>
<section>
<p><strong>esp32-wifi-manager</strong>, &copy; 2017-2019, Tony Pottier<br />Licender under the MIT License.</p>
<p>
This app would not be possible without the following libraries:
</p>
<ul>
<li>SpinKit, &copy; 2015, Tobias Ahlin. Licensed under the MIT License.</li>
<li>jQuery, The jQuery Foundation. Licensed under the MIT License.</li>
<li>cJSON, &copy; 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
</ul>
</section>
<div class="buttons">
<input id="ok-credits" type="button" value="OK" class="ctr" />
</div>
</div>
</body>
<html>
<div class="tab-pane fade" id="tab-credits">
<section>
<p><strong>esp32-wifi-manager</strong>, &copy; 2017-2019, Tony Pottier<br />Licender under the MIT License.</p>
<p>
This app would not be possible without the following libraries:
</p>
<ul>
<li>SpinKit, &copy; 2015, Tobias Ahlin. Licensed under the MIT License.</li>
<li>jQuery, The jQuery Foundation. Licensed under the MIT License.</li>
<li>cJSON, &copy; 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
</ul>
</section>
</div>
</div>
</body>
</html>

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.