diff --git a/Firmware/simulator/smoke-test.js b/Firmware/simulator/smoke-test.js index b4631e1..8a14d85 100644 --- a/Firmware/simulator/smoke-test.js +++ b/Firmware/simulator/smoke-test.js @@ -74,17 +74,27 @@ async function expectSoon(pg, what, sel, re, ms = 5000) { } catch (e) { /* reported by expect() below */ } await expect(pg, what, sel, re); } -// the pages' own question box (ask / askText in the pages) answered with OK as soon as it opens, as a person would; `text` is typed -// into its field first (the module's password, when it asks for one). Stays on after the page reloads itself (a restart) +// the pages' own question box (ask / askText / askShow in the pages) answered with OK as soon as it opens, as a person would; +// `text` is typed into its field first (the module's password, when it asks for one). What each box said is kept for asked() +// below. Stays on after the page reloads itself (a restart); holdAsk(pg, true) leaves the boxes to the check for a while async function answerAsk(pg, text) { - const js = "(()=>{if(window.__askAuto)return;window.__askAuto=1;" + - "const go=()=>{const a=document.getElementById('ask');if(!a||a.hidden)return;const i=document.getElementById('askIn');" + + const js = "(()=>{if(window.__askAuto)return;window.__askAuto=1;window.__asked=[];" + + "const go=()=>{const a=document.getElementById('ask');if(!a||a.hidden||window.__askHold)return;" + + "window.__asked.push(document.getElementById('askBox').innerText);const i=document.getElementById('askIn');" + "if(i&&!i.hidden)i.value=" + JSON.stringify(text || "") + ";document.getElementById('askYes').click();};" + "const start=()=>{const a=document.getElementById('ask');if(!a)return;new MutationObserver(go).observe(a,{attributes:true,attributeFilter:['hidden']});go();};" + "document.readyState==='loading'?document.addEventListener('DOMContentLoaded',start):start();})()"; await pg.addInitScript(js); await pg.evaluate(js); } +// what the boxes answered by answerAsk said since the last call (title, rows, verdict, text and buttons, one string each) +async function asked(pg) { return pg.evaluate(() => { const a = window.__asked || []; window.__asked = []; return a; }); } +async function holdAsk(pg, on) { await pg.evaluate(v => { window.__askHold = v; }, on); } +// the last box answered says `re` +async function askedSays(pg, what, re) { + const a = await asked(pg); + if (!a.length || !re.test(a[a.length - 1])) fail.push(what + ": the box should say " + re + ", it said " + JSON.stringify(a.length ? a[a.length - 1] : "nothing")); +} // a page of the site inside an AgOpenWeb web card: the server's /Boards/_card, an iframe with the card's sandbox at the smallest // card size, 480 x 320. There the browser's confirm() and prompt() return false / null without showing anything, which the check // first makes sure of (otherwise the frame is not testing what a card does). Gives the page and its frame (null: not loaded) @@ -103,10 +113,11 @@ async function card(browser, port, src, what) { return [pg, fr]; } // the question box open in the card: its text, whether it asks to type something, inside the 480 x 320, the OK button 44 px high -async function askShown(fr, what, re, withInput) { +async function askShown(fr, what, re, withInput, title) { await fr.waitForTimeout(200); if (!(await fr.locator("#ask").isVisible())) { fail.push(what + ": the question box did not open"); return; } await expect(fr, what, "#askText", re); + if (title) await expect(fr, what, "#askTitle", title); if ((await fr.locator("#askIn").isVisible()) !== withInput) fail.push(what + ": the question " + (withInput ? "has no field to type in" : "should not ask to type anything")); const b = await fr.locator(".askBox").boundingBox(), y = await fr.locator("#askYes").boundingBox(); if (!b || b.x < 0 || b.y < 0 || b.x + b.width > 480 || b.y + b.height > 320) fail.push(what + ": the question box does not fit the card (" + JSON.stringify(b) + ")"); @@ -121,7 +132,7 @@ async function teensy(browser, port, q, name) { const what = "Teensy page " + (q || "(defaults)"); const pg = await page(browser, "http://127.0.0.1:" + port + "/Boards/teensy/" + q, what); await pg.waitForTimeout(2500); - await expect(pg, what, "#ghVer", /^[\d.]+(, built [^—]+)? — the one installed$/); + await expect(pg, what, "#ghVer", /^[\d.]+(, built .+)? installed$/); await expect(pg, what, "#hdr", /_AiO_WEB · 192\.168\.5\.126/); await expect(pg, what, "#simBar", /SIMULATOR/); if (!(await pg.locator("#dot.on").count())) fail.push(what + ": the page is not connected to the pretend module"); @@ -290,9 +301,10 @@ async function teensy(browser, port, q, name) { await pg.click('nav button[data-t="firmware"]'); await pg.waitForTimeout(300); await expect(pg, what, "#prevFw", /^none kept yet/); if (!(await pg.locator("#revert").isDisabled())) fail.push(what + ": Go back is offered with no previous firmware kept"); - await pg.setInputFiles("#hexFile", hex); await pg.waitForTimeout(1500); - await expect(pg, what, "#hexInfo", /_AiO_WEB, built/); - await pg.click("#install"); + await asked(pg); + await pg.setInputFiles("#hexFile", hex); // Install from a file…: the box says what is inside, OK installs it + await pg.waitForTimeout(1500); + await askedSays(pg, what + " (Install from a file…)", /^Install this file\?\n[\s\S]*Inside\s+v[\d.]+_AiO_WEB, built [\s\S]*Runs now\s+v[\d.]+_AiO_WEB, built [\s\S]*Autosteer must be off and the tractor stopped/); await pg.waitForFunction(() => /Updated\. Running/.test(document.getElementById("fwMsg").textContent), null, {timeout: 60000}).catch(() => {}); await expect(pg, what, "#fwMsg", /Updated\. Running/); await pg.waitForFunction(() => /_AiO_WEB, built/.test(document.getElementById("prevFw").textContent), null, {timeout: 10000}).catch(() => {}); // the next status poll fills it @@ -300,6 +312,7 @@ async function teensy(browser, port, q, name) { await shot(pg, "parked-updated"); await pg.click("#revert"); await pg.waitForFunction(() => /Going back/.test(document.getElementById("fwMsg").textContent), null, {timeout: 5000}).catch(() => {}); + await askedSays(pg, what + " (Go back)", /^Go back to the previous firmware\?\nPrevious\s+v[\d.]+_AiO_WEB, built /); await pg.waitForFunction(() => /Updated\. Running/.test(document.getElementById("fwMsg").textContent), null, {timeout: 60000}).catch(() => {}); await expect(pg, what, "#fwMsg", /Updated\. Running/); await expect(pg, what, "#prevFw", /^none kept yet/); // used up by going back @@ -311,7 +324,7 @@ async function teensy(browser, port, q, name) { const what = "Teensy page, newer build on GitHub"; const pg = await page(browser, "http://127.0.0.1:" + port + "/Boards/teensy/", what, j => { j.teensy.built = LATER; }); await pg.waitForTimeout(2500); - await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 — newer than the installed one$/); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 newer$/); if (await pg.locator("#ghInstall").isDisabled()) fail.push(what + ": Install from GitHub is not offered"); if (await pg.locator("#ghNote").isHidden()) fail.push(what + ": no note about the new firmware"); await pg.close(); @@ -326,7 +339,7 @@ async function teensy(browser, port, q, name) { for (let i = 0; i < 40 && (await pg.locator("#aSecs span").count()) !== 19; i++) await pg.waitForTimeout(250); if ((await pg.locator("#aSecs span").count()) !== 19) fail.push(what + ": Program → module should show the seed drill's 19 sections"); await expect(pg, what, "#mFw", /AiO/); - await expect(pg, what, "#ghVer", /^[\d.]+(, built [^—]+)? — the one installed$/); + await expect(pg, what, "#ghVer", /^[\d.]+(, built .+)? installed$/); await shot(pg, "xiao-status"); for (const t of ["log", "wifi", "prog"]) { await pg.click('nav button[data-t="' + t + '"]'); await pg.waitForTimeout(800); @@ -337,22 +350,22 @@ async function teensy(browser, port, q, name) { await pg.close(); } // the XIAO page with the module parked: the firmware's own .hex installed on the module over the link, then the - // previous firmware put back (the XIAO password typed in the Update or restart card) + // previous firmware put back (the XIAO password typed in the box that confirms each one, then remembered while the page is open) if (hex) { const what = "XIAO page, module firmware over the link"; const pg = await page(browser, "http://127.0.0.1:" + port + "/Boards/xiao/?park=1", what); - await answerAsk(pg); + await answerAsk(pg, "agopengps"); await pg.waitForTimeout(2500); await pg.click('nav button[data-t="prog"]'); await pg.waitForTimeout(800); await expect(pg, what, "#tFw", /_AiO_WEB/); - await expectSoon(pg, what, "#tGh", /the one the module runs$/); + await expectSoon(pg, what, "#tGh", / installed$/); await expect(pg, what, "#tPrev", /^none kept yet/); if (!(await pg.locator("#tRevert").isDisabled())) fail.push(what + ": Go back is offered with no previous firmware kept"); if (!(await pg.locator("#tGhInstall").isDisabled())) fail.push(what + ": Install from GitHub is offered with the same build"); - await pg.fill("#pwP", "agopengps"); - await pg.setInputFiles("#tHexFile", hex); await pg.waitForTimeout(1500); - await expect(pg, what, "#tHexInfo", /_AiO_WEB, built/); - await pg.click("#tInstall"); + await asked(pg); + await pg.setInputFiles("#tHexFile", hex); // Install from a file… in the module card: the box says what is inside + await pg.waitForTimeout(1500); + await askedSays(pg, what + " (Install from a file…)", /^Install this file on the module\?\n[\s\S]*Inside\s+v[\d.]+_AiO_WEB, built [\s\S]*XIAO network password/); await pg.waitForFunction(() => /^Done\./.test(document.getElementById("tMsg").textContent), null, {timeout: 60000}).catch(() => {}); await expect(pg, what, "#tMsg", /^Done\. The module runs/); await expect(pg, what, "#tPrev", /_AiO_WEB, built/); @@ -360,6 +373,7 @@ async function teensy(browser, port, q, name) { await shot(pg, "xiao-module-updated"); await pg.click("#tRevert"); await pg.waitForFunction(() => /going back/.test(document.getElementById("tMsg").textContent), null, {timeout: 5000}).catch(() => {}); + await askedSays(pg, what + " (Go back)", /^Go back to the previous firmware\?\nPrevious\s+v[\d.]+_AiO_WEB, built /); await pg.waitForFunction(() => /^Done\./.test(document.getElementById("tMsg").textContent), null, {timeout: 60000}).catch(() => {}); await expect(pg, what, "#tMsg", /^Done\. The module runs/); await expect(pg, what, "#tPrev", /^none kept yet/); @@ -371,19 +385,21 @@ async function teensy(browser, port, q, name) { const pg = await page(browser, "http://127.0.0.1:" + port + "/Boards/xiao/?chip=s3", what, j => { if (j.xiao.S3) j.xiao.S3.built = LATER; }); await pg.waitForTimeout(2500); await expect(pg, what, "#hdr", /_XIAO_ESP32S3/); - await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 — newer than the installed one$/); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 newer$/); if (await pg.locator("#ghInstall").isDisabled()) fail.push(what + ": Install from GitHub is not offered"); await pg.close(); } - // Enter in the XIAO page's password boxes: it does what the card's button does (here every action asks first, and the check - // says no); an empty box does nothing, and a held Enter does not also answer the question it opened + // Enter on the XIAO page: in the Module network password it does what the card's button does (here the action asks first, and + // the check says no); in the box that confirms an installation an empty password does nothing, and a held Enter on Install + // from GitHub opens the box but never also answers it, even with the password already in it. Files for the first install over + // USB-C are refused in the box with the reason; a program without the XIAO firmware's name in it waits for "Install it anyway" { const what = "XIAO page, Enter in the password boxes"; const pg = await page(browser, "http://127.0.0.1:" + port + "/Boards/xiao/", what, j => { if (j.xiao.C3) j.xiao.C3.built = LATER; }); - const askOpen = async (re, how) => { + const askOpen = async (re, how, sel) => { await pg.waitForTimeout(300); if (!(await pg.locator("#ask").isVisible())) { fail.push(what + ": " + how + " did not ask anything"); return; } - await expect(pg, what, "#askText", re); + await expect(pg, what, sel || "#askText", re); await pg.keyboard.press("Escape"); await pg.waitForTimeout(200); if (await pg.locator("#ask").isVisible()) fail.push(what + ": Escape does not close the question"); }; @@ -394,19 +410,41 @@ async function teensy(browser, port, q, name) { await pg.fill("#pwN", "agopengps"); await pg.locator("#pwN").press("Enter"); await askOpen(/^Change the module's subnet to 192\.168\.7 and restart it\?/, "Enter in the Module network password"); await pg.click('nav button[data-t="prog"]'); await pg.waitForTimeout(300); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 newer$/); if (await pg.locator("#ghInstall").isDisabled()) fail.push(what + ": Install from GitHub is not offered"); - await pg.click("#ghInstall"); await pg.waitForTimeout(200); - await expect(pg, what, "#fwMsg", /^Type the XIAO network password\.$/); - await pg.locator("#pwP").press("Enter"); await pg.waitForTimeout(300); - if (await pg.locator("#ask").isVisible()) fail.push(what + ": Enter in the empty password box asked something"); - await pg.fill("#pwP", "agopengps"); await pg.locator("#pwP").press("Enter"); // the password typed after Install from GitHub asked for it - await askOpen(/^Install [\d.]+, built 31 Dec 2099 23:59 from GitHub \(v[\d.]+_XIAO_ESP32C3\.bin\) on the XIAO\?$/, "Enter after Install from GitHub asked for the password"); - const bin = Buffer.alloc(4096); bin[0] = 0xE9; bin[12] = 5; // an ESP32-C3 program's header (chip id 5) - await pg.setInputFiles("#binFile", {name: "v4.5_XIAO_ESP32C3.bin", mimeType: "application/octet-stream", buffer: bin}); await pg.waitForTimeout(300); - await pg.focus("#pwP"); + await pg.click("#ghInstall"); await pg.waitForTimeout(300); + await expect(pg, what, "#askTitle", /^Install from GitHub on the XIAO\?$/); + await expect(pg, what, "#askVerdict", /^✓ Newer than the one installed\.$/); + await expect(pg, what, "#askPwL", /^XIAO network password$/); + await pg.locator("#askIn").press("Enter"); await pg.waitForTimeout(300); + if (!(await pg.locator("#ask").isVisible())) fail.push(what + ": Enter in the empty password field answered the box"); + await askOpen(/^Install from GitHub on the XIAO\?$/, "Install from GitHub", "#askTitle"); + // the password typed in the WiFi tab is offered in the box; Install from GitHub with a held Enter: the box, not its answer + await pg.click('nav button[data-t="wifi"]'); await pg.fill("#pwW", "agopengps"); + await pg.click('nav button[data-t="prog"]'); await pg.waitForTimeout(300); + await pg.focus("#ghInstall"); await pg.keyboard.down("Enter"); await pg.keyboard.down("Enter"); await pg.keyboard.down("Enter"); await pg.keyboard.up("Enter"); // held: repeats - await askOpen(/^Install v4\.5_XIAO_ESP32C3\.bin on the XIAO\?$/, "a held Enter in the password box"); - if (await pg.locator("#prog").isVisible()) fail.push(what + ": the installation started"); + await pg.waitForTimeout(300); + if (await pg.locator("#ask").isVisible() && (await pg.inputValue("#askIn")) !== "agopengps") fail.push(what + ": the password typed in the WiFi tab is not offered in the box"); + await askOpen(/^Install from GitHub on the XIAO\?$/, "a held Enter on Install from GitHub", "#askTitle"); + const bin = Buffer.alloc(4096); bin[0] = 0xE9; bin[12] = 5; // an ESP32-C3 program's header (chip id 5), no name inside + for (const name of ["v4.5_XIAO_ESP32C3_USB.bin", "v4.5_XIAO_ESP32C3.merged.bin"]) { + await pg.setInputFiles("#binFile", {name, mimeType: "application/octet-stream", buffer: bin}); await pg.waitForTimeout(300); + await expect(pg, what + " (" + name + ")", "#askVerdict", /^✗ This is a file for the first install over USB-C\. Over WiFi choose v[\d.]+_XIAO_ESP32C3\.bin/); + if (await pg.locator("#askIn").isVisible()) fail.push(what + ": the box for a refused file asks for the password"); + await askOpen(/^This file cannot be installed$/, "a file for USB-C (" + name + ")", "#askTitle"); + } + await pg.setInputFiles("#binFile", {name: "v4.5_XIAO_ESP32C3.bin", mimeType: "application/octet-stream", buffer: bin}); await pg.waitForTimeout(300); + if (await pg.locator("#ask").isVisible()) { + await expect(pg, what, "#askVerdict", /^! Another program, not this XIAO firmware/); + if (!(await pg.locator("#askForce").isVisible()) || !(await pg.locator("#askYes").isDisabled())) fail.push(what + ": a program without the XIAO firmware's name should wait for Install it anyway"); + await pg.locator("#askIn").press("Enter"); await pg.waitForTimeout(300); + if (!(await pg.locator("#ask").isVisible())) fail.push(what + ": Enter answered the box before Install it anyway was ticked"); + await pg.check("#askForceIn"); + if (await pg.locator("#askYes").isDisabled()) fail.push(what + ": Install it anyway does not turn Install on"); + } + await askOpen(/^Install this file on the XIAO\?$/, "a chosen .bin", "#askTitle"); + if (await pg.locator("#prog").isVisible()) fail.push(what + ": an installation started"); await pg.close(); } // the seed drill module's page: the Relay24_ESP32 on the network cable sowing a pass with 19 of its 24 relays (relay 1 = @@ -464,23 +502,29 @@ async function teensy(browser, port, q, name) { await shot(pg, "seeder-network"); await pg.click('nav button[data-t="firmware"]'); await pg.waitForTimeout(700); if (!(await pg.locator("#t-firmware").isVisible())) fail.push(what + ": tab Firmware does not show"); - await expect(pg, what, "#ver", /^Seeder_ESP32 v[\d.]+$/); + await expect(pg, what, "#ver", /^Seeder_ESP32 v[\d.]+, built .+$/); await expect(pg, what, "#board", /^Relay24_ESP32$/); // the .bin on main, once there is one: the one the pretend module runs (or an older one, when the code changed and the // .bin did not yet); none yet: said so - await expect(pg, what, "#ghVer", /^(no seed drill program on GitHub|v[\d.]+, built [^—]+ — (the one installed|older than the installed one \(the new \.bin is not on GitHub yet\)))$/); + await expect(pg, what, "#ghVer", /^(no seed drill firmware on GitHub|v[\d.]+, built .+ (installed|older))$/); if (!(await pg.locator("#ghInstall").isDisabled())) fail.push(what + ": Install from GitHub is offered with nothing newer there"); if (await pg.locator('nav button[data-t="firmware"].new').count()) fail.push(what + ": the Firmware tab is marked new with nothing newer"); await shot(pg, "seeder-firmware"); - // wrong files: the .merged.bin, a program for the other board, the sprayer's program + // wrong files, refused in the box as soon as they are chosen, with the reason and no password asked: the .merged.bin, a program + // for the other board, the sprayer's program const sdBin = (fw, ver, built, board) => Buffer.concat([Buffer.from([0xE9]), Buffer.alloc(31), Buffer.from('{"fw":"' + fw + '","ver":"' + ver + '","built":"' + built + '"\0' + (board ? ',"board":"' + board + '"\0' : ""))]); - for (const [name, buf, re] of [["Seeder_ESP32.ino.merged.bin", Buffer.alloc(64, 0xFF), /^This is the wrong file: use Seeder_ESP32\.ino\.bin/], - ["Seeder_ESP32.ino.bin", sdBin("Seeder_ESP32", "0.2", LATER, "KC868-A32"), /^This program is for the KC868-A32 board, but this module is on the Relay24_ESP32 board/], - ["Sprayer_ESP32.ino.bin", sdBin("Sprayer_ESP32", "0.10", LATER, ""), /^This is the program Sprayer_ESP32, not this module's/]]) { - await pg.setInputFiles("#bin", {name: name, mimeType: "application/octet-stream", buffer: buf}); - await pg.click("#install"); await pg.waitForTimeout(500); - await expect(pg, what + " (" + name + ")", "#msgProg", re); + for (const [name, buf, re] of [["Seeder_ESP32.ino.merged.bin", Buffer.alloc(64, 0xFF), /^✗ This is the wrong file: use Seeder_ESP32\.ino\.bin/], + ["Seeder_ESP32.ino.bin", sdBin("Seeder_ESP32", "0.2", LATER, "KC868-A32"), /^✗ This program is for the KC868-A32 board, but this module is on the Relay24_ESP32 board/], + ["Sprayer_ESP32.ino.bin", sdBin("Sprayer_ESP32", "0.10", LATER, ""), /^✗ This is the program Sprayer_ESP32, not this module's/]]) { + await holdAsk(pg, true); + await pg.setInputFiles("#bin", {name: name, mimeType: "application/octet-stream", buffer: buf}); await pg.waitForTimeout(500); + await expect(pg, what + " (" + name + ")", "#askTitle", /^This file cannot be installed$/); + await expect(pg, what + " (" + name + ")", "#askVerdict", re); + if (await pg.locator("#askIn").isVisible()) fail.push(what + " (" + name + "): the box for a refused file asks for the password"); + await pg.click("#askNo"); await pg.waitForTimeout(200); + if (await pg.locator("#ask").isVisible()) fail.push(what + " (" + name + "): Close does not close the box"); + await holdAsk(pg, false); } if (/program update/.test(await pg.locator("#log").textContent())) fail.push(what + ": a wrong file was sent to the module"); try { @@ -513,7 +557,7 @@ async function teensy(browser, port, q, name) { await answerAsk(pg, "agopengps"); await pg.waitForTimeout(2500); if (!(await pg.locator("#t-firmware").isVisible())) fail.push(what + ": #firmware in the address does not open the Firmware tab"); - await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 — newer than the installed one$/); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 newer$/); if (!(await pg.locator('nav button[data-t="firmware"].new').count())) fail.push(what + ": the Firmware tab is not marked new"); if (await pg.locator("#ghInstall").isDisabled()) fail.push(what + ": Install from GitHub is not offered"); else { @@ -521,7 +565,8 @@ async function teensy(browser, port, q, name) { try { await pg.waitForFunction(() => /^Back:/.test(document.getElementById("msgProg").textContent), null, {timeout: 25000}); } catch (e) { fail.push(what + ": the module did not come back with the new program (" + (await pg.locator("#msgProg").textContent()) + ")"); } await expect(pg, what, "#msgProg", /^Back: it runs Seeder_ESP32 v[\d.]+, built 31 Dec 2099 23:59 for the Relay24_ESP32\.$/); - await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 — the one installed$/); + await askedSays(pg, what, /^Install from GitHub\?\nOn GitHub\s+Seeder_ESP32 v[\d.]+, built 31 Dec 2099 23:59\s+Runs now\s+Seeder_ESP32 v[\d.]+, built [\s\S]*✓ Newer than the one installed\.\s+Every section closes during the update\.\s+Password of the own Wi-Fi network/); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 installed$/); if (await pg.locator('nav button[data-t="firmware"].new').count()) fail.push(what + ": the Firmware tab is still marked new after the update"); } await shot(pg, "seeder-firmware-updated"); @@ -591,22 +636,28 @@ async function teensy(browser, port, q, name) { await shot(pg, "sprayer-module"); await pg.click('nav button[data-t="firmware"]'); await pg.waitForTimeout(700); if (!(await pg.locator("#t-firmware").isVisible())) fail.push(what + ": tab Firmware does not show"); - await expect(pg, what, "#ver", /^Sprayer_ESP32 v[\d.]+$/); + await expect(pg, what, "#ver", /^Sprayer_ESP32 v[\d.]+, built .+$/); await expect(pg, what, "#board", /^ESP32_Relay_X8$/); // the .bin on main: the one the pretend module runs (or an older one, when the code changed and the .bin did not yet) - await expect(pg, what, "#ghVer", /^v[\d.]+, built [^—]+ — (the one installed|older than the installed one \(the new \.bin is not on GitHub yet\))$/); + await expect(pg, what, "#ghVer", /^v[\d.]+, built .+ (installed|older)$/); if (!(await pg.locator("#ghInstall").isDisabled())) fail.push(what + ": Install from GitHub is offered with nothing newer there"); if (await pg.locator('nav button[data-t="firmware"].new').count()) fail.push(what + ": the Firmware tab is marked new with nothing newer"); await shot(pg, "sprayer-firmware"); - // wrong files: the .merged.bin, and a program for another board + // wrong files, refused in the box as soon as they are chosen, with the reason and no password asked: the .merged.bin, a program + // for another board, the seed drill's program const sprBin = (ver, built, board) => Buffer.concat([Buffer.from([0xE9]), Buffer.alloc(31), Buffer.from('{"fw":"Sprayer_ESP32","ver":"' + ver + '","built":"' + built + '"\0,"board":"' + board + '"\0')]); - for (const [name, buf, re] of [["Sprayer_ESP32.ino.merged.bin", Buffer.alloc(64, 0xFF), /^This is the wrong file: use Sprayer_ESP32\.ino\.bin/], - ["Sprayer_ESP32.ino.bin", sprBin("0.10.0", LATER, "ESP32 dev module"), /^This program is for the ESP32 dev module board, but this module is on the ESP32_Relay_X8 board/], - ["Seeder_ESP32.ino.bin", Buffer.concat([Buffer.from([0xE9]), Buffer.alloc(31), Buffer.from('{"fw":"Seeder_ESP32","ver":"0.2","built":"' + LATER + '"')]), /^This is the program Seeder_ESP32, not this module's/]]) { - await pg.setInputFiles("#bin", {name: name, mimeType: "application/octet-stream", buffer: buf}); - await pg.click("#install"); await pg.waitForTimeout(500); - await expect(pg, what + " (" + name + ")", "#msgProg", re); + for (const [name, buf, re] of [["Sprayer_ESP32.ino.merged.bin", Buffer.alloc(64, 0xFF), /^✗ This is the wrong file: use Sprayer_ESP32\.ino\.bin/], + ["Sprayer_ESP32.ino.bin", sprBin("0.10.0", LATER, "ESP32 dev module"), /^✗ This program is for the ESP32 dev module board, but this module is on the ESP32_Relay_X8 board/], + ["Seeder_ESP32.ino.bin", Buffer.concat([Buffer.from([0xE9]), Buffer.alloc(31), Buffer.from('{"fw":"Seeder_ESP32","ver":"0.2","built":"' + LATER + '"')]), /^✗ This is the program Seeder_ESP32, not this module's/]]) { + await holdAsk(pg, true); + await pg.setInputFiles("#bin", {name: name, mimeType: "application/octet-stream", buffer: buf}); await pg.waitForTimeout(500); + await expect(pg, what + " (" + name + ")", "#askTitle", /^This file cannot be installed$/); + await expect(pg, what + " (" + name + ")", "#askVerdict", re); + if (await pg.locator("#askIn").isVisible()) fail.push(what + " (" + name + "): the box for a refused file asks for the password"); + await pg.click("#askNo"); await pg.waitForTimeout(200); + if (await pg.locator("#ask").isVisible()) fail.push(what + " (" + name + "): Close does not close the box"); + await holdAsk(pg, false); } if (/program update/.test(await pg.locator("#log").textContent())) fail.push(what + ": a wrong file was sent to the module"); try { @@ -639,7 +690,7 @@ async function teensy(browser, port, q, name) { await answerAsk(pg, "agopengps"); await pg.waitForTimeout(2500); if (!(await pg.locator("#t-firmware").isVisible())) fail.push(what + ": #firmware in the address does not open the Firmware tab"); - await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 — newer than the installed one$/); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 newer$/); if (!(await pg.locator('nav button[data-t="firmware"].new').count())) fail.push(what + ": the Firmware tab is not marked new"); if (await pg.locator("#ghInstall").isDisabled()) fail.push(what + ": Install from GitHub is not offered"); else { @@ -647,14 +698,16 @@ async function teensy(browser, port, q, name) { try { await pg.waitForFunction(() => /^Back:/.test(document.getElementById("msgProg").textContent), null, {timeout: 25000}); } catch (e) { fail.push(what + ": the module did not come back with the new program (" + (await pg.locator("#msgProg").textContent()) + ")"); } await expect(pg, what, "#msgProg", /^Back: it runs Sprayer_ESP32 v[\d.]+, built 31 Dec 2099 23:59 for the ESP32_Relay_X8\.$/); - await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 — the one installed$/); + await askedSays(pg, what, /^Install from GitHub\?\nOn GitHub\s+Sprayer_ESP32 v[\d.]+, built 31 Dec 2099 23:59\s+Runs now\s+Sprayer_ESP32 v[\d.]+, built [\s\S]*✓ Newer than the one installed\.\s+The sections close during the update\.\s+Password of the own Wi-Fi network/); + await expect(pg, what, "#ghVer", /built 31 Dec 2099 23:59 installed$/); if (await pg.locator('nav button[data-t="firmware"].new').count()) fail.push(what + ": the Firmware tab is still marked new after the update"); } await shot(pg, "sprayer-firmware-updated"); await pg.close(); } - // the sprayer page inside a web card: Save and restart (Module tab) asks yes / no (Escape is a no), Restart (Firmware tab) asks - // the password in the box (Cancel does nothing, Enter after the password restarts the module) + // the sprayer page inside a web card: Save and restart (Module tab) asks yes / no (Escape is a no); Restart module (Firmware tab) + // and a chosen .bin ask in one box with the password (Cancel does nothing, Enter with no password typed does nothing, Enter after + // the password restarts the module); the box with the most in it still fits the smallest card { const what = "Sprayer page in a web card"; const [pg, fr] = await card(browser, port, "/Boards/sprayer/#module", what); @@ -670,20 +723,27 @@ async function teensy(browser, port, q, name) { await askShown(fr, what, /^Save and restart the module\? Its Wi-Fi goes off/, false); await fr.locator("#askYes").press("Escape"); await askClosed(fr, what, "Escape"); await fr.click('nav button[data-t="firmware"]'); await fr.waitForTimeout(300); - await fr.click("button[onclick*='/api/restart']"); - await askShown(fr, what, /^Password of the own Wi-Fi network$/, true); + const onMain = path.join(__dirname, "..", "..", "Sprayer", "Sprayer_ESP32", "Sprayer_ESP32.ino.bin"); + await fr.setInputFiles("#bin", onMain); + await askShown(fr, what, /^The sections close during the update\.$/, true, /^Install this file\?$/); + await expect(fr, what, "#askPwL", /^Password of the own Wi-Fi network$/); + await shot(pg, "sprayer-card-file"); + await fr.click("#askNo"); await askClosed(fr, what, "Cancel"); + await fr.click("#restart"); + await askShown(fr, what, /^Every section closes for a few seconds\.$/, true, /^Restart the module\?$/); await shot(pg, "sprayer-card-password"); await fr.click("#askNo"); await askClosed(fr, what, "Cancel"); await expect(fr, what, "#msgProg", /^$/); - await fr.click("button[onclick*='/api/restart']"); + await fr.click("#restart"); await fr.locator("#askIn").press("Enter"); await fr.waitForTimeout(200); - if (!(await fr.locator("#ask").isVisible())) { fail.push(what + ": Enter with no password typed answers the question"); await fr.click("button[onclick*='/api/restart']"); } + if (!(await fr.locator("#ask").isVisible())) { fail.push(what + ": Enter with no password typed answers the question"); await fr.click("#restart"); } await fr.fill("#askIn", "agopengps"); await fr.locator("#askIn").press("Enter"); await askClosed(fr, what, "Enter"); await expectSoon(fr, what, "#msgProg", /^done, restarting/); } await pg.close(); } - // the Teensy page inside a web card: Restart Teensy asks yes / no + // the Teensy page inside a web card: Restart Teensy asks yes / no; a chosen .hex without the update page inside is shown in the + // box with the warning, and Install waits for "Install it anyway" { const what = "Teensy page in a web card"; const [pg, fr] = await card(browser, port, "/Boards/teensy/?park=1", what); @@ -699,6 +759,23 @@ async function teensy(browser, port, q, name) { await askShown(fr, what, /^Restart the Teensy\?/, false); if (await fr.locator("#ask").isVisible()) { await fr.click("#askNo"); await askClosed(fr, what, "Cancel"); } await expect(fr, what, "#fwMsg", /^$/); + const hexOf = text => { // text as an Intel HEX file, 16 bytes a line + const b = Buffer.from(text, "latin1"), l = []; + for (let i = 0; i < b.length; i += 16) { + const r = [Math.min(16, b.length - i), (i >> 8) & 255, i & 255, 0, ...b.subarray(i, i + 16)]; + l.push(":" + [...r, (256 - r.reduce((x, y) => x + y, 0) % 256) % 256].map(x => x.toString(16).padStart(2, "0").toUpperCase()).join("")); + } + return l.join("\n") + "\n:00000001FF\n"; + }; + await fr.setInputFiles("#hexFile", {name: "v4.5_AiO_WEB.ino.hex", mimeType: "text/plain", buffer: Buffer.from(hexOf("fw_teensy41 [boot] v4.5_AiO_WEB, built Nov 13 2026 10:00:00 "))}); + await askShown(fr, what, /^Autosteer must be off and the tractor stopped\./, false, /^Install this file\?$/); + await expect(fr, what, "#askVerdict", /^! No update page inside: the next update will have to be by USB\.$/); + if (!(await fr.locator("#askYes").isDisabled())) fail.push(what + ": Install is on before Install it anyway is ticked"); + await fr.check("#askForceIn"); + if (await fr.locator("#askYes").isDisabled()) fail.push(what + ": Install it anyway does not turn Install on"); + await shot(pg, "teensy-card-file"); + await fr.click("#askNo"); await askClosed(fr, what, "Cancel"); + await expect(fr, what, "#fwMsg", /^$/); await fr.click("#reboot"); await fr.click("#askYes"); await askClosed(fr, what, "OK"); await expectSoon(fr, what, "#fwMsg", /^Restarting/); diff --git a/Firmware/v4.5_AiO_WEB/README.md b/Firmware/v4.5_AiO_WEB/README.md index 705cf72..1eaee95 100644 --- a/Firmware/v4.5_AiO_WEB/README.md +++ b/Firmware/v4.5_AiO_WEB/README.md @@ -31,7 +31,7 @@ One row per day, in short; the details are in the sections of this file (the lin | Date | What changed | |---|---| -| 13 Nov 2026 | A held Enter no longer answers the page's question too: Enter on a button such as *Restart Teensy* asks once and waits for the answer ([Web page](#web-page)). | +| 13 Nov 2026 | A held Enter no longer answers the page's question too ([Web page](#web-page)). Firmware tab: one card for the firmware, and one box that says what a `.hex` holds before it is installed ([update](#firmware-update-over-the-network)). | | 12 Nov 2026 | A WAS fault or a silent Keya is told on the program's screen again when its AutoSteer button goes on: on a bench with no WAS the button only went red, with no reason ([WAS check](#was-check)). | | 11 Nov 2026 | **Keya**: holding the wheel cuts autosteer, by the motor's own current against the program's Current Turn limit ([Keya kickout](#keya-kickout)). After an update, an old page a browser kept fetches the new one by itself ([Web page](#web-page)). | | 10 Nov 2026 | The UM982's temperature is read (`HWSTATUSA`); one a device does not give reads *not reported* ([Identification](#identification)). Tabs and light/dark button 44 px high, 8 px corners; network name `AiO-xxxx`, with a hyphen ([Web page](#web-page)). | @@ -67,7 +67,7 @@ One row per day, in short; the details are in the sections of this file (the lin **Already compiled:** `v4.5_AiO_WEB.ino.hex` (Teensyduino 1.58, the name the Arduino IDE gives). The IDE ignores it and the XIAO folders. -- From a firmware that already has this web page: web page → Firmware → choose the `.hex`. +- From a firmware that already has this web page: web page → Firmware → **Install from a file…** → the `.hex`. - From any other firmware: over USB, Teensy Loader → File → Open HEX File → press the button on the Teensy. ## Web page @@ -92,7 +92,7 @@ The page carries the date its own firmware was compiled, and compares it with th | **IMU** | The IMU found; with a TM171: gyro calibration, new install calibration, set-up check with "Fix TM171 setup", and the TM171 settings (requires the TX5 wire). | | **GPS** | The receiver (model, firmware), the receiver check, the u-blox or UM982 settings, and a UM982 console (a command and its replies for 5 s; `FRESET`, `UNLOG` and baud rate changes ask first). | | **Machine** | Only once a machine module (IP .123: the official Machine_UDP_v5, the sprayer module, the seed drill module, or anything that talks like them) has been heard on UDP 9999. Its IP, last packet, checksum errors, hello replies, and one square per section (up to 64) in the AgOpenWeb section colours: green open, red closed, orange asked on by the program (PGN 254, and PGN 229 above 16) but still closed on the module, cyan asked off but still open. The modules' side comes from their PGN 237 (the AiO v26 layout; our seed drill module adds sections 17-64), else the sprayer PGN 160 or the hello reply (1-16 only); with several machine modules on the network (each its own IP, up to 4), their sections are shown together and the IP row lists them. The official module reports its output levels, so with "Invert relay" on in the program its squares read reversed. The Sprayer card (pressure, flow, total litres, main switch) appears once PGN 160 arrives. Only to look at. | -| **Firmware** | Firmware name and build date, the processor's clock and temperature (and the highest since start-up), why the Teensy last started, the watchdog, new versions on GitHub, update from a file, restart. **Diagnostic report**: one `.json` file with everything the module can tell (status, messages, settings, the installation notes, GPS, UM982 console, build, free RAM, longest loop time, loops per second and the time each part of the loop takes, web errors); send it when something goes wrong. | +| **Firmware** | **Teensy firmware**: installed (name and build date), on GitHub, the previous one kept, **Install from GitHub**, **Install from a file…**, **Go back to the previous firmware** ([update](#firmware-update-over-the-network)). **This Teensy**: the board, the processor's clock and temperature (and the highest since start-up), why the Teensy last started, the watchdog, **Restart Teensy**. **Diagnostic report**: one `.json` file with everything the module can tell (status, messages, settings, the installation notes, GPS, UM982 console, build, free RAM, longest loop time, loops per second and the time each part of the loop takes, web errors); send it when something goes wrong. | While autosteer is on, the buttons that change the receiver or the TM171, and the firmware install, are greyed out; the TM171 calibrations and the firmware install also while the tractor is moving (not on a bench: simulator mode on, or no WAS). @@ -122,13 +122,14 @@ Saved in the Teensy's EEPROM (address 200, away from the AgOpenGPS steer setting ### Firmware update over the network -Web page → Firmware → choose the `.hex` → Install. +Web page → Firmware → **Install from a file…** → choose the `.hex` → **Install** in the box. -- Once chosen, the page reads the file in the browser and shows what is inside, next to its name: the version and the build date and time (the `[boot] … built …` line the firmware prints at start-up), "the firmware running now" when it is the same build as the module's, a warning when it is not a Teensy 4.1 firmware, not an AiO_WEB one, or has no update page inside. Nothing is sent until Install. +- The **Teensy firmware** card has the rows **Installed**, **On GitHub** (tagged *newer*, *installed* or *older*) and **Previous**, the two ways to install (**Install from GitHub**, **Install from a file…**), the progress bar and the messages, and **Go back to the previous firmware** at the bottom. +- Once chosen, the page reads the file in the browser and opens one box: the file, what is inside (the version and the build date and time, from the `[boot] … built …` line the firmware prints at start-up), what runs now, and whether it is newer, the same or older. Nothing is sent until **Install**. A file that is not a `.hex` or not a Teensy 4.1 firmware is refused in that box with the reason. **Install from GitHub** and **Go back** are confirmed in the same box. - Only with **autosteer off and the tractor stopped** (program's speed, and the receiver's with RTK, below 1 km/h). On the bench the speed is not checked: simulator mode on, or a wheel angle a tractor does not give (no WAS, or beyond ±50°). - The module receives the whole file into free flash and checks it (checksums, size, Teensy 4.1, this firmware family `AiO-WEB-OTA-1`), reading back every sector. Since 3 Nov 2026 the image carries only that name: a module still on a firmware from before 22 Oct 2026 (which looks for `AOG-UM982-TM171-WEB-OTA-1`) takes a build from 22 Oct to 2 Nov 2026 first, or this one over USB. **If anything fails, the running firmware stays** and the page says why. - Then the new firmware is copied over the old one (a few seconds) and the Teensy restarts. **Do not cut the power during that copy**: the Teensy would need reprogramming over USB (it is not damaged, and the 15 s button restore also works). -- "Other firmware" installs an image without the family marker; the next update is then over USB. +- A `.hex` without AiO_WEB build data or without the family marker (another firmware) is shown in the box with a warning, and **Install** waits for **Install it anyway** to be ticked; the next update is then over USB. ### Going back to the previous firmware @@ -137,14 +138,14 @@ Web page → Firmware → **Go back to the previous firmware** (also on the XIAO - At each update, before the new firmware is copied over the old one, the module copies the firmware it is running into free flash (from 2 MB to 4 MB, with its name, build date and a checksum). The Firmware tab shows it in the **Previous firmware** row; the Status JSON carries it as `prev`. - The button puts that copy back (a few seconds, then a restart), with the same conditions as an update: autosteer off, tractor stopped. The settings in the EEPROM are kept. No file, no computer and no internet are needed: it is for a new build that misbehaves in the field. - Going back uses the copy up: after it there is no previous firmware until the next update. The copy exists only after the first update made with a firmware of 2 Nov 2026 or later (the first install of that firmware is by USB or from the page, as any other); a copy whose checksum no longer matches is not offered. -- "Other firmware" images are copied too, so an update with that box ticked still has a way back to this firmware. +- Firmware installed with **Install it anyway** is copied too, so such an update still has a way back to this firmware. ### Update from the XIAO page For a module whose own page cannot be reached (its network cable or network, a fault in the page, the box closed) while the XIAO on the GPS2 port still answers on WiFi. -- XIAO page → Firmware → **Module (Teensy) firmware**: the firmware the module runs, the one on GitHub, the previous one kept; **Install from GitHub**, **Choose .hex** → **Install on the module**, and **Go back to the previous firmware**. The XIAO's network password (the one of the "Update or restart" card) is asked. -- The `.hex` goes to the XIAO as its own update does, and on to the Teensy over the serial link in pieces of 252 bytes, each confirmed by the Teensy before the next one is sent (about a minute for the 2 MB file). The Teensy checks the file exactly as one from its own page (checksums, Teensy 4.1, the family marker unless "Other firmware" is ticked), refuses it with autosteer on or the tractor moving, and keeps autosteer off while it receives. The web page and UDP keep being served meanwhile. **If anything fails, the running firmware stays** and the XIAO page says why; without an answer from the Teensy for 15 s both sides give up. +- XIAO page → Firmware → **Module (Teensy) firmware**: the firmware the module runs, the one on GitHub, the previous one kept; **Install from GitHub**, **Install from a file…** and **Go back to the previous firmware**, each confirmed in one box that says what the file holds and asks the XIAO's network password. +- The `.hex` goes to the XIAO as its own update does, and on to the Teensy over the serial link in pieces of 252 bytes, each confirmed by the Teensy before the next one is sent (about a minute for the 2 MB file). The Teensy checks the file exactly as one from its own page (checksums, Teensy 4.1, the family marker unless **Install it anyway** was ticked), refuses it with autosteer on or the tractor moving, and keeps autosteer off while it receives. The web page and UDP keep being served meanwhile. **If anything fails, the running firmware stays** and the XIAO page says why; without an answer from the Teensy for 15 s both sides give up. - The XIAO page then watches the module come back (its time on starts again, or another build runs) and says which firmware it runs. - It needs a Teensy firmware of 2 Nov 2026 or later (the first one with PGN 145) and the XIAO program compiled from the same date or later: an older Teensy does not answer, and the page says so. diff --git a/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/README.md b/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/README.md index c7bf956..4fd8383 100644 --- a/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/README.md +++ b/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/README.md @@ -23,7 +23,7 @@ Version 4.5, the same number as the Teensy firmware it goes with (v4.5_AiO_WEB). | Date | What changed | |---|---| -| 13 Nov 2026 | Loading the page no longer stops the XIAO on weak WiFi ("XIAO silent for 10 s"); the browser keeps the page. Enter in a password field does what its button does ([What it does](#what-it-does)). | +| 13 Nov 2026 | Loading the page no longer stops the XIAO on weak WiFi ("XIAO silent for 10 s"). Enter in a password field does what its button does. Firmware tab: one card per device, one box for each install ([What it does](#what-it-does)). | | 11 Nov 2026 | The page checks that it is the page of the program running: after an update an old page a browser kept (old buttons, new data) fetches the new one by itself ([What it does](#what-it-does)). | | 10 Nov 2026 | Tabs and the light/dark button 44 px high with 8 px corners; the WiFi tab's password to confirm in a card of its own, no longer a field across the page ([What it does](#what-it-does)). Messages give the size of an updated program, not 0 bytes. | | 9 Nov 2026 | The page's questions (save and restart, install, the module's firmware, subnet) in its own box: the browser's pop-ups show nothing inside an AgOpenWeb web card, so those buttons did nothing there ([What it does](#what-it-does)). | @@ -65,15 +65,16 @@ Version 4.5, the same number as the Teensy firmware it goes with (v4.5_AiO_WEB). | | The name on the network (`xiao` → `xiao.local`). | | | Saved in the XIAO; it restarts to apply them. | | | **Module network**: the module's (Teensy's) Ethernet IP and its subnet. For a module on a network that is not 192.168.5.x: type that network's first three numbers (and the XIAO password); the Teensy saves it and restarts with the new IP. This page is on WiFi, so it works whatever the module's IP is. | -| **Firmware** | Version, the newest version on GitHub with **Install from GitHub**, **program update over WiFi** (a `.bin` file, see below), restart. One password field for all. **Module (Teensy) firmware**: the module's firmware installed from this page over the link, and its previous firmware put back (see below). **Download the report**: the XIAO's state and settings (no passwords), the module status and both message lists in one `.json` file, to send when something goes wrong. | +| **Firmware** | One card per device, the same layout. **XIAO firmware**: installed, on GitHub (tagged *newer*, *installed* or *older*), **Install from GitHub**, **Install from a file…** (a `.bin`, see below), the progress, **Restart XIAO** at the bottom. **Module (Teensy) firmware**: the module's firmware installed from this page over the link, and its previous firmware put back (see below). Each install and the restart are confirmed in one box that says what the file holds against what runs now and asks the XIAO's network password. **Download the report**: the XIAO's state and settings (no passwords), the module status and both message lists in one `.json` file, to send when something goes wrong. | - Changes (WiFi, update, restart) **ask for the password of the XIAO's own network**, to confirm. - The question before each one (save and restart, install, the module's firmware, the subnet) opens in a box of the page itself, not a browser pop-up: inside an AgOpenWeb web card the browser's pop-ups show nothing, so those buttons did nothing there. - - **Enter** in a password field does what its button does, and the question still comes first. On the Firmware tab: the action that asked for the password (*Type the XIAO network password*), else **Install** with a `.bin` chosen, else **Install from GitHub**; never **Restart**. An empty field does nothing, and a held Enter does not also answer the question it opened. + - **Enter** in a password field does what its button does, and the question still comes first. On the Firmware tab the password is typed in the box that confirms the action, where Enter is its **Install** or **Restart**. An empty field does nothing, and a held Enter does not also answer the box it opened. + - The box's buttons stay in sight at its bottom when it is taller than the screen (an AgOpenWeb web card of 480 x 320): the rest scrolls. - The tabs and the light/dark button at the top are 44 px high, with the same 8 px corners as that box's buttons: a size a finger hits on the cab's screen. - On the WiFi tab the password and **Save and restart the XIAO** have a card of their own, *Confirm and save*, as wide as the other two. - The page carries the date its own program was compiled and compares it with the one the XIAO reports. When they differ (an old page the browser kept after an update), it fetches the page again at an address the browser has never seen (`/?b=`); if that page is still old, a notice says to reload it by hand. - - Typed once, it is filled in both tabs until the page is closed. + - Typed once, in the WiFi tab or in a Firmware box, it is offered again until the page is closed. - The page never shows or stores it. - Just viewing the page needs nothing more than being on the network. - It tells the Teensy its version and WiFi state: they show in the **XIAO** card of the Teensy page (normally http://192.168.5.126/; the module's IP is shown on the Status tab). Its events also go to the Teensy log as `[xiao] > ...`. From the WiFi tab it can set the module's subnet (PGN 144 to the Teensy). @@ -115,7 +116,7 @@ No other libraries are needed: everything is in the esp32 package. - The page looks for the newest version in the `Firmware` folder of **github.com/renatorgr/Boards**: when it opens, every 6 hours while it stays open, and with **Check now** (Firmware tab). - A newer one shows at the top of Status and in Firmware. **A new build of the same version counts as new**: the page compares when the `.bin` for this XIAO's chip (C3 or S3) on GitHub was compiled with this XIAO's **Built**. That date is read from the file each time it reaches `main` and published with the simulator (`https://renatorgr.github.io/Boards/firmware.json`); without it, the page compares the version number only. -- **Install from GitHub** (with the password of the XIAO's network): +- **Install from GitHub** (a box shows the version on GitHub against the one running, with the password of the XIAO's network): - the browser downloads the `.bin` for this XIAO (in the version folder `vX.Y_AiO_WEB`: `vX.Y_XIAO_ESP32_bin/vX.Y_XIAO_ESP32C3.bin` or `...S3.bin`, chosen from the chip it reports); - it checks that the file is for this chip and that its size matches GitHub; - it sends it to the XIAO like a chosen file. @@ -125,10 +126,11 @@ No other libraries are needed: everything is in the esp32 package. ## Update over WiFi (from a file) 1. Arduino IDE: Sketch > **Export Compiled Binary**. It writes a `build` folder inside the sketch folder. -2. Use **`v4.5_XIAO_ESP32.ino.bin`**. Not the files with `merged`, `bootloader` or `partitions` in the name (the page refuses them). +2. Use **`v4.5_XIAO_ESP32.ino.bin`** (or `vX.Y_XIAO_ESP32C3.bin` / `S3.bin` from GitHub). Not the files with `merged`, `bootloader`, `partitions` or `_USB` in the name: those are for the first install over USB-C, and the page refuses them. - A `.bin` compiled for the XIAO ESP32C3 does not run on the ESP32S3, and the other way round. The page reads the start of the file and says so before sending it. - With both XIAOs, rename the files after exporting (for example `…_C3.bin` and `…_S3.bin`). -3. Phone or PC on the XIAO's network → page → **Firmware** → choose the file → password → **Install**. +3. Phone or PC on the XIAO's network → page → **Firmware** → **Install from a file…** → choose the file. A box says what is inside (version, build date) against what runs now → password → **Install**. + - A `.bin` without the XIAO firmware's name inside (another program) is shown with a warning, and **Install** waits for **Install it anyway**: this page goes with it, so the next update would be over USB-C. 4. It takes less than a minute and the XIAO restarts with the new program. The WiFi settings are kept. If the update fails halfway (WiFi lost), the old program keeps running: just try again. Messages then shows "Program update STOPPED after … kB: the browser's connection dropped". With a weak signal, connect the phone or PC to the XIAO's own network and install from http://192.168.4.1/: download the `.bin` first (Install from GitHub needs internet, and the XIAO's own network has none). @@ -138,11 +140,11 @@ If the update fails halfway (WiFi lost), the old program keeps running: just try For when the module's (Teensy's) own page does not open: its network cable or network, a fault in the page, the box closed, while this XIAO still answers on WiFi. Firmware tab → **Module (Teensy) firmware**. - The card shows the firmware the module runs and when it was built, the `.hex` on GitHub (newer, the same, or older than the module's), and the **previous firmware** the Teensy keeps (the one that ran before its last update; "none kept yet" until the module's first update with a firmware of 2 Nov 2026 or later). -- **Install from GitHub** downloads the Teensy `.hex` of the newest version folder in the browser (the phone needs internet, as for the XIAO's own update), **Choose .hex** takes a file from the phone or PC; the page reads it first and says what is inside (version, build date, whether it is a Teensy 4.1 AiO_WEB firmware). **Install on the module** sends it to the XIAO with the network password, and the XIAO passes it on to the Teensy over the serial link in pieces, each one confirmed by the Teensy before the next: about a minute for the 2 MB file. The progress bar is the file leaving the phone; then the Teensy checks the whole file as it does one from its own page, installs it and restarts. -- **Go back to the previous firmware** asks the Teensy to put its kept copy back: no file and no internet needed. The copy is used up by it. +- **Install from GitHub** downloads the Teensy `.hex` of the newest version folder in the browser (the phone needs internet, as for the XIAO's own update), **Install from a file…** takes a file from the phone or PC. Either way one box says what is inside (version, build date, whether it is a Teensy 4.1 AiO_WEB firmware) against what the module runs, and asks the network password; **Install** sends it to the XIAO, and the XIAO passes it on to the Teensy over the serial link in pieces, each one confirmed by the Teensy before the next: about a minute for the 2 MB file. The progress bar is the file leaving the phone; then the Teensy checks the whole file as it does one from its own page, installs it and restarts. +- **Go back to the previous firmware** (at the bottom of the card, confirmed in the same box) asks the Teensy to put its kept copy back: no file and no internet needed. The copy is used up by it. - Only with **autosteer off and the tractor stopped**: the Teensy refuses otherwise, and keeps autosteer off while it receives. If anything fails the module's current firmware keeps running and the card says why; a Teensy that does not answer (an older firmware, or the link down) is reported after a few seconds. - The card then waits for the module to come back (its time on starts again, or another build runs) and says which firmware it runs. The module's own messages are on the Messages tab. -- **Other firmware** installs a `.hex` without the update page inside (another firmware for the Teensy 4.1); the next update is then by USB. +- A `.hex` without the update page inside (another firmware for the Teensy 4.1) waits in the box for **Install it anyway**; the next update is then by USB. - Not yet tried on a board (2 Nov 2026): try it first on the bench with the box open and the USB cable at hand. ## USB serial commands diff --git a/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/xPage.h b/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/xPage.h index 63a5894..a733bed 100644 --- a/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/xPage.h +++ b/Firmware/v4.5_AiO_WEB/v4.5_XIAO_ESP32/xPage.h @@ -94,8 +94,27 @@ a{color:var(--acc)} .askBox{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px;width:100%;max-width:440px;max-height:100%;overflow:auto;box-shadow:0 8px 30px rgba(0,0,0,.35)} .askBox p{margin:0 0 12px;white-space:pre-line} .askBox input{display:block;width:100%;font:inherit;padding:9px 10px;border:1px solid var(--line);border-radius:8px;background:var(--card);color:var(--ink);margin:0 0 12px} -.askBtns{display:flex;gap:10px;justify-content:flex-end} +/* the buttons stay in sight at the bottom of a box taller than the screen (a web card of 480 x 320): the rest scrolls under + them, and the password field, when it has the focus, is scrolled above them */ +.askBox{scroll-padding-bottom:76px} +.askBtns{display:flex;gap:10px;justify-content:flex-end;position:sticky;bottom:-16px;background:var(--card);padding:8px 0 16px;margin:-8px 0 -16px} .askBtns button{min-height:44px;min-width:96px} +/* the question box's other parts (askShow): a title, rows of what is in a file, the verdict, a tick, the password's label */ +.askBox h3{margin:0 0 10px;font-size:17px} +.askBox dl{margin:0 0 10px} +.askBox p.verdict{font-weight:650} +.askBox label.opt{display:flex;gap:10px;align-items:center;margin:0 0 12px;padding:0;font-weight:600} +.askBox label.opt input{display:inline-block;width:22px;height:22px;margin:0} +#askPwL{display:block;color:var(--mute);font-size:13.5px;margin:0 0 3px} +/* the Firmware tab: a card per device (this XIAO, the module behind it), Check now / See on GitHub in a line, Restart and Go + back at the card's foot */ +.fwgrid{grid-template-columns:repeat(auto-fit,minmax(min(400px,100%),1fr))} +.card h2 small{display:block;text-transform:none;letter-spacing:0;font-weight:400;font-size:12.5px;margin-top:2px} +label.sec{border:1px solid var(--line);background:var(--card);color:var(--ink);border-radius:8px;padding:8px 14px;font:inherit;cursor:pointer} +label.sec.off{opacity:.45;cursor:default} +button.lnk{border:0;background:none;padding:0;font:inherit;color:var(--acc);text-decoration:underline;cursor:pointer} +p.chk{text-align:right;margin:4px 0 0} +.foot{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:12px 0 0;padding-top:10px;border-top:1px solid var(--line)} @@ -173,59 +192,65 @@ a{color:var(--acc)} - + diff --git a/Sprayer/Sprayer_ESP32/README.md b/Sprayer/Sprayer_ESP32/README.md index 97b8ce1..0aecc2e 100644 --- a/Sprayer/Sprayer_ESP32/README.md +++ b/Sprayer/Sprayer_ESP32/README.md @@ -4,7 +4,7 @@ Section control for an 8 m sprayer boom with 8 sections of 1 m, driven by **AgOp **AgOpenGPS** over Wi-Fi, on an **ESP32 8-relay board**. It also measures boom pressure and flow, and has its own web page. -Version 0.10.7 (successor of [Sprayer_Nano](../Sprayer_Nano) v0.3): runs on the bench, not yet +Version 0.10.8 (successor of [Sprayer_Nano](../Sprayer_Nano) v0.3): runs on the bench, not yet tested on the sprayer. ## Changelog @@ -13,7 +13,7 @@ One row per day, in short; the details are in the sections of this file (the lin | Date | What changed | |---|---| -| 13 Nov 2026 | **0.10.7**: Enter in the password at the end of *Network settings* saves, as its button does; in the page's question box an empty password or a held Enter answers nothing ([How it works](#how-it-works)). | +| 13 Nov 2026 | **0.10.7**: Enter in the *Network settings* password saves; an empty password or a held Enter answers no question. **0.10.8**: the Firmware tab in one card, and one box that says what a `.bin` holds before it is installed ([How it works](#how-it-works)). | | 10 Nov 2026 | **0.10.6**: the tabs at the top of the page are 44 px high with 8 px corners, like the buttons of the page's question box: easier to hit on the cab's screen ([How it works](#how-it-works)). | | 9 Nov 2026 | **0.10.5**: the page's questions (save and restart, install, password) in its own box: the browser's pop-ups show nothing inside an AgOpenWeb web card, so those buttons did nothing there ([How it works](#how-it-works)). | | 7 Nov 2026 | **0.10.2**: add-on card (`_aowcard._tcp`) under its Wi-Fi name; `_aow-ui` and `/aow/status` gone. **0.10.3**: alarms also as PGN 221 ([Messages](#messages)). **0.10.4**: Module tab: Module card, one Network settings card. Code shared with the seed drill marked ([Notes](#notes)). | @@ -72,14 +72,19 @@ ESP32_Relay_X8 board ──► 8 relays ──► 8 solenoid valves (NC), one pe own network's password, so nothing changes by a touch while driving. - **Module**: the link to AgOpenWeb, the relays, the Wi-Fi settings (laid out as on the XIAO page, with *Search for networks*) and the events. - - **Firmware**, as on the Teensy and XIAO pages: the program installed (version, build - date, board), the **version on GitHub** (the `Sprayer_ESP32.ino.bin` in this folder; - checked when the page opens, every 6 hours and with *Check now*) with **Install from - GitHub**, install a chosen `.bin` with a progress bar, Restart, and **Download the - report**: the module's state, settings and events in one `.json` file to send when - something goes wrong (no passwords in it). The phone or tablet asks GitHub, so it needs - internet: open the page over the tractor network, not over the module's own Wi-Fi. - A `.bin` for another board, another module's program or the `.merged.bin` is refused. + - **Firmware**, as on the Teensy and XIAO pages: one card with the program installed + (version, build date), the **version on GitHub** (the `Sprayer_ESP32.ino.bin` in this + folder; checked when the page opens, every 6 hours and with *Check now*) tagged *newer*, + *installed* or *older*, the two ways to install, **Install from GitHub** and **Install + from a file…**, the progress bar, and **Restart module** at the bottom of the card. A + second card, **Download the report**: the module's state, settings and events in one + `.json` file to send when something goes wrong (no passwords in it). The phone or tablet + asks GitHub, so it needs internet: open the page over the tractor network, not over the + module's own Wi-Fi. Each install and the restart are confirmed in one box: it says what + the file holds (version, build date, board) against what runs now, newer, the same or + older, and asks the own network's password (offered again while the page stays open). + A `.bin` for another board, another module's program or the `.merged.bin` is refused in + that box as soon as it is chosen, with the reason. Every question the page asks (save and restart, install a program, the password) opens in a box of the page itself, not a browser pop-up: inside an AgOpenWeb web card the browser's pop-ups show nothing, so those buttons did nothing there. Enter is its OK, but not in an empty @@ -154,7 +159,7 @@ divider (to-GND ÷ total) in the page's calibration. 4. *Tools → Port*: the adapter's COM port. 5. Hold **IO0**, press and release **EN**, release IO0. Click *Upload*. When it says "Hard resetting", press **EN** once. -6. Serial Monitor at **115200**: it prints `Sprayer_ESP32 v0.10.7` and `ready`. +6. Serial Monitor at **115200**: it prints `Sprayer_ESP32 v0.10.8` and `ready`. "Failed to connect": TX and RX are probably swapped, or step 5 was skipped. @@ -201,10 +206,11 @@ divider (to-GND ÷ total) in the page's calibration. them and shows what the module sends. Later program updates, on the page's **Firmware** tab: -- **Install from GitHub** when it says "newer than the installed one": the page downloads +- **Install from GitHub** when the version there is tagged *newer*: the page downloads `Sprayer_ESP32.ino.bin` from this folder on GitHub and sends it to the module. -- Or *Sketch → Export compiled binary* in the Arduino IDE, then *Choose .bin* - (`Sprayer_ESP32.ino.bin` in the sketch folder, not the `.merged.bin`) and *Install*. +- Or *Sketch → Export compiled binary* in the Arduino IDE, then **Install from a file…** + (`Sprayer_ESP32.ino.bin` in the sketch folder, not the `.merged.bin`) and *Install* in the + box that says what the file holds. The page knows which version is on GitHub from the `.bin` itself (its version, board and build date, published in `firmware.json` with the simulator). So after a code change, diff --git a/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino b/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino index 82a5392..42251db 100644 --- a/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino +++ b/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino @@ -55,7 +55,7 @@ #include "sPage.h" #define FW_NAME "Sprayer_ESP32" -#define FW_VERSION "0.10.7" +#define FW_VERSION "0.10.8" // ---------------------------------------------------------------- board and pins // BOARD says which board this is (change the line below, or compile with -DBOARD=...): diff --git a/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.bin b/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.bin index 7a2fa20..eb155fa 100644 Binary files a/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.bin and b/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.bin differ diff --git a/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.merged.bin b/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.merged.bin index 9f4344b..cb68d6f 100644 Binary files a/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.merged.bin and b/Sprayer/Sprayer_ESP32/Sprayer_ESP32.ino.merged.bin differ diff --git a/Sprayer/Sprayer_ESP32/sPage.h b/Sprayer/Sprayer_ESP32/sPage.h index bbcb23c..90dacb4 100644 --- a/Sprayer/Sprayer_ESP32/sPage.h +++ b/Sprayer/Sprayer_ESP32/sPage.h @@ -96,8 +96,26 @@ a{color:var(--acc)} .askBox{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px;width:100%;max-width:440px;max-height:100%;overflow:auto;box-shadow:0 8px 30px rgba(0,0,0,.35)} .askBox p{margin:0 0 12px;white-space:pre-line} .askBox input{display:block;width:100%;font:inherit;padding:9px 10px;border:1px solid var(--line);border-radius:8px;background:var(--card);color:var(--ink);margin:0 0 12px} -.askBtns{display:flex;gap:10px;justify-content:flex-end} +/* the buttons stay in sight at the bottom of a box taller than the screen (a web card of 480 x 320): the rest scrolls under + them, and the password field, when it has the focus, is scrolled above them */ +.askBox{scroll-padding-bottom:76px} +.askBtns{display:flex;gap:10px;justify-content:flex-end;position:sticky;bottom:-16px;background:var(--card);padding:8px 0 16px;margin:-8px 0 -16px} .askBtns button{min-height:44px;min-width:96px} +/* the question box's other parts (askShow): a title, rows of what is in a file, the verdict, a tick, the password's label */ +.askBox h3{margin:0 0 10px;font-size:17px} +.askBox dl{margin:0 0 10px} +.askBox p.verdict{font-weight:650} +.askBox label.opt{display:flex;gap:10px;align-items:center;margin:0 0 12px;font-weight:600} +.askBox label.opt input{display:inline-block;width:22px;height:22px;margin:0} +#askPwL{display:block;color:var(--mute);font-size:13.5px;margin:0 0 3px} +/* the Firmware tab: one card for the firmware, Check now / See on GitHub in a line, the restart at the card's foot */ +.fwgrid{grid-template-columns:repeat(auto-fit,minmax(min(400px,100%),1fr))} +label.sec{border:1px solid var(--line);background:var(--card);color:var(--ink);border-radius:8px;padding:8px 14px;font:inherit;cursor:pointer} +label.sec.off{opacity:.45;cursor:default} +button.lnk{border:0;background:none;padding:0;font:inherit;color:var(--acc);text-decoration:underline;cursor:pointer} +p.chk{text-align:right;margin:4px 0 0} +.foot{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:12px 0 0;padding-top:10px;border-top:1px solid var(--line)} +.pill.ok{background:color-mix(in srgb,var(--ok) 16%,transparent)}.pill.warn{background:color-mix(in srgb,var(--warn) 18%,transparent)} @@ -226,24 +244,16 @@ a{color:var(--acc)} - +