This commit is contained in:
e2002
2022-04-20 13:00:13 +03:00
parent 1895043ba4
commit e8ed958f4d
14 changed files with 119 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
- [Hardware setup](#hardware-setup)
- [Quick start](#quick-start)
- [Update](#update)
- [Update over web-interface](#update-over-web-interface)
- [Controls](Controls.md)
- [MQTT](#mqtt)
- [Home Assistant](#home-assistant)
@@ -209,6 +210,16 @@ download _http://\<yoradioip\>/data/playlist.csv_ and _http://\<yoradioip\>/data
4. Go to page _http://\<yoradioip\>/_ in the browser and press Ctrl+F5 to update the scripts.
5. Well done!
## Update over web-interface
1. Backup your settings: \
download _http://\<yoradioip\>/data/playlist.csv_ and _http://\<yoradioip\>/data/wifi.csv_ and place them in the yoRadio/data/data/ folder
2. Get firmware binary: Sketch → Export compiled binary
3. Get SPIFFS binary: disconnect ESP32 from your computer, click on **ESP32 Data Sketch Upload**. \
You will get an error and file path
<img src="images/getspiffs.jpg" width="830" height="208">
4. Go to page _http://\<yoradioip\>/update_ and upload yoRadio.ino.esp32.bin and yoRadio.spiffs.bin in turn, checking the appropriate upload options.
5. Well done!
---
## MQTT
1. Copy file exsamples/mqttoptions.h to yoRadio/ directory
@@ -278,6 +289,11 @@ Work is in progress...
---
## Version history
#### v0.6.250
- added update via web-interface \
**Attention! Full firmware with chip re-partitioning is required!** see [board setup example](#quick-start)
- fixed choppy when switching stations via Home Assistant
#### v0.6.220
- new option PLAYER_FORCE_MONO (with i2S DAC only)
- change default scroll speed in DSP_NOKIA5110

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 49 KiB

BIN
images/getspiffs.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

View File

@@ -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

View File

@@ -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.

View 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>

View File

@@ -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();

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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.

View 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();