Skip to content

Commit 82fc260

Browse files
committed
Fixing OTA updates
1 parent 4bd18b4 commit 82fc260

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

extras/dashboard.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ <h3 class="modal-title" id="modalTitle">Confirm Action</h3>
15471547
reconnectTimeout = null;
15481548
}
15491549
updateStatus(false);
1550-
const wsUrl = 'ws://' + window.location.hostname + '/ws';
1550+
const wsUrl = 'ws://' + "192.168.178.101"+ '/ws';
15511551
ws = new WebSocket(wsUrl);
15521552

15531553
ws.onopen = () => {
@@ -1719,6 +1719,7 @@ <h3 class="modal-title" id="modalTitle">Confirm Action</h3>
17191719
}
17201720

17211721
function sendAction(cardId, action, data = {}) {
1722+
console.log(`[Dashboard] Sending action: ${action} for card: ${cardId}`, data);
17221723
if (ws && ws.readyState === WebSocket.OPEN) {
17231724
ws.send(JSON.stringify({ type: 'action', cardId, action, data }));
17241725
}
@@ -2442,7 +2443,6 @@ <h3 class="modal-title" id="modalTitle">Confirm Action</h3>
24422443
const chunk = data.slice(offset, offset + chunkSize);
24432444
const b64 = btoa(String.fromCharCode.apply(null, chunk));
24442445
sendAction(id, 'ota_chunk', { data: b64 });
2445-
24462446
offset += chunkSize;
24472447
const pct = Math.min(100, Math.round((offset / data.length) * 100));
24482448
document.getElementById(`progress-fill-${id}`).style.width = pct + '%';
@@ -2615,6 +2615,8 @@ <h3 class="modal-title" id="modalTitle">Confirm Action</h3>
26152615
zone.style.display = 'none';
26162616
progress.style.display = 'block';
26172617

2618+
console.log('Starting OTA upload: ' + file.name + ' (' + file.size + ' bytes)');
2619+
26182620
// Send OTA start
26192621
if (ws && ws.readyState === WebSocket.OPEN) {
26202622
ws.send(JSON.stringify({ type: 'ota_start', name: file.name, size: file.size }));
@@ -2628,6 +2630,7 @@ <h3 class="modal-title" id="modalTitle">Confirm Action</h3>
26282630
const data = new Uint8Array(reader.result);
26292631

26302632
function sendChunk() {
2633+
console.log('Sending chunk: ' + offset + ' - ' + Math.min(offset + chunkSize, data.length) + ' / ' + data.length);
26312634
if (offset >= data.length) {
26322635
if (ws && ws.readyState === WebSocket.OPEN) {
26332636
ws.send(JSON.stringify({ type: 'ota_end' }));
@@ -2639,7 +2642,7 @@ <h3 class="modal-title" id="modalTitle">Confirm Action</h3>
26392642

26402643
const chunk = data.slice(offset, offset + chunkSize);
26412644
const b64 = btoa(String.fromCharCode.apply(null, chunk));
2642-
2645+
console.log('Sending chunk: ' + b64.length + ' bytes');
26432646
if (ws && ws.readyState === WebSocket.OPEN) {
26442647
ws.send(JSON.stringify({ type: 'ota_chunk', data: b64 }));
26452648
}

src/ESPDashboardPlus.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ class ESPDashboardPlus {
874874
String _lastUpdate;
875875

876876
void handleWebSocketMessage(AsyncWebSocketClient* client, const String& message) {
877-
StaticJsonDocument<1024> doc;
877+
StaticJsonDocument<2048> doc;
878878
DeserializationError error = deserializeJson(doc, message);
879879

880880
if (error) {
@@ -902,7 +902,8 @@ class ESPDashboardPlus {
902902
_otaInProgress = true;
903903

904904
if (!Update.begin(_otaSize)) {
905-
Serial.println("[Dashboard] OTA begin failed");
905+
Serial.print("[Dashboard] OTA begin failed: ");
906+
Update.printError(Serial);
906907
_otaInProgress = false;
907908
}
908909
} else if (action == "ota_chunk" && _otaInProgress) {

0 commit comments

Comments
 (0)