v0.6.250
This commit is contained in:
@@ -103,7 +103,7 @@ void initControls() {
|
||||
}
|
||||
|
||||
void loopControls() {
|
||||
if(display.mode==LOST) return;
|
||||
if(display.mode==LOST || display.mode==UPDATING) return;
|
||||
#if ENC_BTNL!=255
|
||||
encoderLoop();
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
<div class="logo"></div>
|
||||
<div id="navbar"%APMODE%>
|
||||
<div class="playerbytton navbutton" id="playlistbutton" onclick="showEditor()"></div>
|
||||
<div class="playerbytton navbutton" id="settingsbutton" onclick="showSettings()"></div>
|
||||
<div class="playerbytton navbutton" id="settingsbutton" onclick="event.stopPropagation(); showSettings()"></div>
|
||||
<div id="settingspopup" class="hidden">
|
||||
<div class="button" id="settingsbuttonwifi" onclick="showSettingsWifi()">Wi-Fi</div>
|
||||
<div class="button" id="settingsbuttonupload" onclick="showSettingsUoload()">Update</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="playerwrap">
|
||||
<div class="player">
|
||||
|
||||
Binary file not shown.
Binary file not shown.
38
yoRadio/data/www/update.html
Normal file
38
yoRadio/data/www/update.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=0.25">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||
<link rel="apple-touch-icon" type="image/png" href="elogo.png">
|
||||
<link rel="icon" type="image/png" href="elogo.png">
|
||||
<link rel="stylesheet" title="base" href="style.css" type="text/css">
|
||||
<title>ёRadio-update</title>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div class="logo"></div>
|
||||
<div class="playerwrap">
|
||||
<div class="player" id="uploaderwrap">
|
||||
<div id="uploadstatus">Please choose firmware or SPIFFS *.bin file</div>
|
||||
<form id="updateform" method="POST" action="/update" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<label for="uploadtype1"><input type="radio" id="uploadtype1" name="updatetarget" value="fw" checked /><span class="checkmark"></span> firmware</label>
|
||||
<label for="contactChoice2"><input type="radio" id="uploadtype2" name="updatetarget" value="spiffs" /><span class="checkmark"></span> SPIFFS</label>
|
||||
</div>
|
||||
<div class="row rowinput">
|
||||
<input id="binfile" type="file" accept=".bin,.hex" name="update" />
|
||||
<input type="button" class="button" value="Update" onclick="doUpdate(this)">
|
||||
</div>
|
||||
</form>
|
||||
<progress id="updateprogress" max="100" value="70" hidden></progress>
|
||||
<a href="/" class="button" id="update_cancel_button">Cancel</a>
|
||||
</div><!--player-->
|
||||
</div><!--playerwrap-->
|
||||
<div id="copy">powered by <a target="_blank" href="https://github.com/e2002/yoradio/">ёRadio</a> | v%VERSION%</div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -328,6 +328,9 @@ void Display::swichMode(displayMode_e newmode) {
|
||||
if (newmode == LOST) {
|
||||
dsp.frameTitle("* LOST *");
|
||||
}
|
||||
if (newmode == UPDATING) {
|
||||
dsp.frameTitle("* UPDATING *");
|
||||
}
|
||||
if (newmode == NUMBERS) {
|
||||
//dsp.frameTitle("STATION");
|
||||
meta.reset();
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "src/displays/displayCustom.h"
|
||||
#endif
|
||||
|
||||
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST };
|
||||
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING };
|
||||
|
||||
enum displayRequestType_e { NEWMODE, CLOCK, NEWTITLE, RETURNTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, DRAWVOL };
|
||||
struct requestParams_t
|
||||
|
||||
@@ -88,7 +88,8 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
return;
|
||||
}
|
||||
if (strcmp(buf, "start") == 0 || strcmp(buf, "play") == 0) {
|
||||
player.play(config.store.lastStation);
|
||||
//player.play(config.store.lastStation);
|
||||
player.request.station = config.store.lastStation;
|
||||
return;
|
||||
}
|
||||
if (strcmp(buf, "boot") == 0 || strcmp(buf, "reboot") == 0) {
|
||||
@@ -114,7 +115,9 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
if (sscanf(buf, "play %d", &sb) == 1 ) {
|
||||
if (sb < 1) sb = 1;
|
||||
if (sb >= config.store.countStation) sb = config.store.countStation;
|
||||
player.play(sb);
|
||||
//player.play(sb);
|
||||
player.request.station = sb;
|
||||
player.request.doSave = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "options.h"
|
||||
#include "network.h"
|
||||
#include "mqtt.h"
|
||||
#include <Update.h>
|
||||
|
||||
#ifndef MIN_MALLOC
|
||||
#define MIN_MALLOC 24112
|
||||
@@ -24,7 +25,14 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
|
||||
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
|
||||
void handleHTTPPost(AsyncWebServerRequest * request);
|
||||
|
||||
byte ssidCount;
|
||||
byte ssidCount;
|
||||
bool shouldReboot = false;
|
||||
|
||||
char* updateError(){
|
||||
static char ret[140] = {0};
|
||||
sprintf(ret, "Update failed with error (%d)<br /> %s", (int)Update.getError(), Update.errorString());
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool NetServer::begin() {
|
||||
importRequest = false;
|
||||
@@ -62,6 +70,40 @@ bool NetServer::begin() {
|
||||
webserver.on("/upload", HTTP_POST, [](AsyncWebServerRequest * request) {
|
||||
//request->send(200);
|
||||
}, handleUpload);
|
||||
webserver.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
request->send(SPIFFS, "/www/update.html", String(), false, processor);
|
||||
});
|
||||
webserver.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||
shouldReboot = !Update.hasError();
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", shouldReboot?"OK": updateError());
|
||||
response->addHeader("Connection", "close");
|
||||
request->send(response);
|
||||
},[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
|
||||
if(!index){
|
||||
int target = (request->getParam("updatetarget", true)->value() == "spiffs") ? U_SPIFFS : U_FLASH;
|
||||
Serial.printf("Update Start: %s\n", filename.c_str());
|
||||
player.mode = STOPPED;
|
||||
display.putRequest({NEWMODE, UPDATING});
|
||||
if(!Update.begin(UPDATE_SIZE_UNKNOWN, target)){
|
||||
Update.printError(Serial);
|
||||
request->send(200, "text/html", updateError());
|
||||
}
|
||||
}
|
||||
if(!Update.hasError()){
|
||||
if(Update.write(data, len) != len){
|
||||
Update.printError(Serial);
|
||||
request->send(200, "text/html", updateError());
|
||||
}
|
||||
}
|
||||
if(final){
|
||||
if(Update.end(true)){
|
||||
Serial.printf("Update Success: %uB\n", index+len);
|
||||
} else {
|
||||
Update.printError(Serial);
|
||||
request->send(200, "text/html", updateError());
|
||||
}
|
||||
}
|
||||
});
|
||||
webserver.begin();
|
||||
websocket.onEvent(onWsEvent);
|
||||
webserver.addHandler(&websocket);
|
||||
@@ -77,6 +119,11 @@ bool NetServer::begin() {
|
||||
}
|
||||
|
||||
void NetServer::loop() {
|
||||
if(shouldReboot){
|
||||
Serial.println("Rebooting...");
|
||||
delay(100);
|
||||
ESP.restart();
|
||||
}
|
||||
websocket.cleanupClients();
|
||||
if (playlistrequest > 0) {
|
||||
requestOnChange(PLAYLIST, playlistrequest);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef options_h
|
||||
#define options_h
|
||||
|
||||
#define VERSION "0.6.220"
|
||||
#define VERSION "0.6.250"
|
||||
|
||||
/*******************************************************
|
||||
DO NOT EDIT THIS FILE.
|
||||
|
||||
@@ -59,7 +59,7 @@ void Player::loop() {
|
||||
if (isRunning()) {
|
||||
//digitalWrite(LED_BUILTIN, LOW);
|
||||
setOutputPins(false);
|
||||
config.setTitle(display.mode==LOST?"":"[stopped]");
|
||||
config.setTitle((display.mode==LOST || display.mode==UPDATING)?"":"[stopped]");
|
||||
netserver.requestOnChange(TITLE, 0);
|
||||
//stopSong();
|
||||
setDefaults();
|
||||
|
||||
Reference in New Issue
Block a user