Repository navigation
Conversation
The six libraries (ArduinoJson 7.4.3, MultiButton 1.3.0, PubSubClient 2.8, Rdm6300 2.0.0, SSLClient 1.6.11, TinyGSM 0.12.0) are copied into All_in_One/src/ by tools/vendor-libraries.sh. The Arduino IDE and arduino-cli now build exactly the same code with nothing to install but the ESP32 board package; Rdm6300 is not in the Arduino library registry, so version pinning alone could not do this. The only change to the copies: includes of a library's own files are made relative to the including file. flash.bat (Windows, production) and tools/build.sh build with ESP32 board package 2.0.17 (installed if missing), flash and show the serial log. Checked: with no libraries installed, the sketch builds to the same size as before (924,381 bytes flash, 31,760 bytes static RAM). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Production now edits only All_in_One/config.h: machine ID, machine type, size, GSM or Wi-Fi (with this site's Wi-Fi name and password), installed modules and production or staging server. config_check.h stops the build with a message naming the setting when one is missing, misspelled, has a value that isn't allowed, or doesn't work with the others (e.g. a module switch typed as HAS_RFIDX, a machine ID with a space, Wi-Fi without a network name, two-group with cash). It also requires ESP32 board package 2.0.17. The committed config.h has MACHINE_ID "CHANGE_ME", which can't be built, so nothing is flashed with another machine's settings. The boot log prints the configuration; the Wi-Fi password is no longer printed. flash.bat shows config.h's settings and asks before flashing. tools/build-all.sh builds real machine configurations and checks that 13 kinds of config.h mistake are rejected. TYPE_TWO_GROUP_160 is refused until the two-group machine is merged in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…or pin SSLClient seeds BearSSL's random generator (its only seed) with 16 analogRead()s of the pin given to its constructor. The firmware passed A5, which on the ESP32 Dev Module is GPIO 33: the column-6 motor pin. So every TLS connection switched that motor pin to an analog input (the real reason for the "GPIO 33 is forced back to INPUT" workaround in Dispense.h), and the seed was readings of a pin held LOW, i.e. nearly constant: weak TLS keys. The library copy is patched (by tools/vendor-libraries.sh, so the patch survives a library upgrade or fails loudly) to use esp_fill_random(). The GPIO 33 OUTPUT safeguard stays, with the real reason in its comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- broker.h: broker address and the machines' shared login ("vms"); the
password is at the top of the file, not in config.h.
- IoT_Root_CA.h (from iot-mqtt/scripts/bearssl_trust_anchors.py): our main
and backup CA, valid 2020-2050, replacing Amazon Root CA 1. The broker
certificate is valid 2020-2045, so BearSSL's check against the build date
passes for any build from 2020 on; no clock needed.
- The AWS device certificate and private key (the same in every build) are
removed; client ID = machine ID, which the broker requires for a
machine's own topics.
- A failed connection logs PubSubClient's state (4 = wrong password).
- version.h: FIRMWARE_VERSION 2.0.0. The "online" status now carries it with
the machine type and build time ({"message":"online","fw":"2.0.0 STD
Nov 27 2026 10:15:00"}); the server ignores unknown fields. Also printed
at boot, with two heap diagnostics (from fix/ssl-and-timer).
- SSLClient no longer gets GPIO 33 as its "analog pin" (unused since the
previous commit).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The display kept a front and a back buffer of 336x240, allocated as 480 separate blocks: about 170 KB of the ESP32's ~300 KB heap, which left Wi-Fi machines close to the "free heap < 55 KB -> restart" guard before TLS. Only the logo (220x47) and one 168x124 message image are ever drawn; the rest of the screen is black. Now: - one framebuffer, drawn in place (an image takes about 1 ms to draw, so there is no visible flicker) - only the rows the logo and the image cover have memory, as one block; every other row shows one shared black row (the video interrupt reads each line through a row pointer). About 60 KB in total. - the logo is drawn once at boot; showImage() draws only when the picture changes, so the idle screen is no longer redrawn on every loop pass - each image's size is checked at build time (all must be 168x124) The boot log prints the free heap before and after the display starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MACHINE_TYPE TYPE_TWO_GROUP_160 in config.h now builds what All_in_One_Weird did, from the same code as every other machine: - buttons: top = BELT group, bottom = PANTY group (staging builds: long press top = reconnect, bottom = sync); then the customer taps the card within 15 s, and the request carries the group as "size" - motors: columns 1-2 two motors and two limit switches each, columns 3-6 one motor each, limit switches on GPIO 34/35 (board pull-ups needed) - per-group stock from the sync reply's "stock" object - screens "push button or scan QR" (idle) and "hold card" Standard machines are unchanged: their loop is the previous loop() under the name loopStandard (checked to be identical text), and the two-group loop is All_in_One_Weird's loop (identical text, apart from the sendDispenseRequest name). Code that only one type uses is built only for that type. Builds: two-group 890 KB flash, standard 160 763 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting - The server answers 405 when a card doesn't have enough points; the firmware had no case for it and showed "something went wrong / try again". It now shows the "limit crossed" screen (no image exists for "not enough points"; reusing one costs no memory), or "something went wrong" on machines without a card reader. - Two-group machine: when a card request was still unanswered after the 15 s group window, it rebooted 15 s after the request. It now does what standard machines do: shows "try again" after 25 s and keeps running; a late reply still dispenses and can't dispense twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n_One The two-group 160 machine is now All_in_One with MACHINE_TYPE TYPE_TWO_GROUP_160. All_in_One_Weird.ino starts with an #error so it can't be flashed by mistake; DEPRECATED.md explains the config.h settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README.md: what each folder is, one-time setup, editing config.h, flash.bat, what a good log looks like, what each build error and connection failure means, the Arduino IDE route, testing on staging. AGENTS.md: how All_in_One works (boot, loop, dispense with dispense-number history, bKash, two-group, recovery), the MQTT contract with VMS, memory budget and display design, TLS (BearSSL, certificate dates vs build date, our SSLClient patch), pins per machine type, gotchas, and the open questions for the hardware team. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/host/dispense_history_test.cpp runs Global.h on the computer with stand-ins for FreeRTOS mutexes, Preferences (NVS that survives a simulated reboot) and Serial: the last 100 numbers are kept, older ones forgotten, the history survives a reboot, a corrupted or wrong-size NVS record starts empty, and no path leaves a mutex taken (22 checks). tools/test-host.sh builds and runs it. GitHub Actions (firmware.yml) runs the host tests and tools/build-all.sh (every machine type + 13 config.h mistakes) on every PR and push to main, with ESP32 board package 2.0.17 cached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GCC on the CI runner warns that the two-group variables in Global.h are unused in the host test (they're used by the sketch); clang didn't. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- build-all.sh: stop if cd fails; check arduino-cli's result directly instead of through $? (SC2164, SC2181); the expected message is matched from a here-string, not a pipe. - vendor-libraries.sh: the library names are a bash array; the license file is found with find instead of ls | grep (SC2010, SC2086). A rerun produces a byte-identical All_in_One/src/. - CI runs ShellCheck on every *.sh before the host tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
All MQTT machines went offline on Nov 12: the firmware checks AWS IoT's certificate against its build date, and AWS rotated it. Machines are moving to our own broker (
iot-mqtt.headless.ltd, repoHeadlessTech/iot-mqtt) and get reflashed. This PR is that firmware, plus the memory problem, a simpler production setup, and merging the two-group machine in so one firmware covers every machine.Don't flash machines in the field from this before the board test passes (checklist below), and before production VMS has moved to the broker.
What changed (one commit each)
All_in_One/src(tools/vendor-libraries.sh), so the Arduino IDE andarduino-clibuild exactly the same code with nothing to install but ESP32 board package 2.0.17.flash.bat(Windows: build, flash, show log) andtools/build.sh.config.h: the only file production edits (ID, type, size, GSM/Wi-Fi + site Wi-Fi, modules, server).config_check.hrefuses missing/misspelled/conflicting settings with a message naming the setting.flash.batshows the settings and asks before flashing.analogRead(A5)= GPIO 33 = the column-6 motor pin: it switched that pin to analog before every connection (the real cause of the "GPIO 33 forced to INPUT" workaround) and gave almost no entropy. Patched to use the ESP32 hardware RNG.broker.h(address + the machines' shared login, password at the top), our two CAs as trust anchors, AWS client certificate and private key removed. Certificates are valid from 2020, so no clock is needed (theClock.hwork onfix/ssl-and-timerisn't needed). Firmware version2.0.0sent in the "online" status; MQTT failure reasons logged.MACHINE_TYPE TYPE_TWO_GROUP_160). Standard machines' loop is the previousloop()unchanged (checked identical); the two-group loop isAll_in_One_Weird's (checked identical).All_in_One_Weirddeprecated: building it stops with a pointer toAll_in_One.README.md(production flashing),AGENTS.md(how it works, server contract, memory, pins, gotchas).Builds (
tools/build-all.sh: 20/20 pass)Before this PR (standard 20, all modules): 924 KB flash, 31.8 KB static RAM. Plus 13
config.hmistakes rejected with the right message.Not verified yet: board test against staging
Set
SERVER SERVER_STAGINGand a machine ID that exists in the staging DB, flash, keep the serial log:iot-mqtt.headless.ltd(BearSSL with our CAs) and MQTT login; "online" appears onvms-newNotes
SSL.hwas the only file with Windows line endings; it now has Unix ones like the rest.broker.hholds the shared machine password on purpose (every machine carries it in flash anyway).fix/ssl-and-timerasarchive/clock-ntpand delete the branch.🤖 Generated with Claude Code