The postcard with a 239-byte limit
A LoRa mesh is like a chain of people passing postcards across a field. Every relay has to repeat every card, so a long message costs time not once but at every hop. On Meshtastic, the payload budget is at most 239 bytes. That is enough for a short update, but it gets tight quickly when a team is trying to send a location, a status report or an ordinary sentence over a crowded channel.
The question was deliberately small: could a model that fits on an ESP32 help text take less room, without ever changing the message? The decoder had to reproduce every byte exactly on iOS, Android and embedded hardware. A compressor that occasionally turns a coordinate into a different coordinate is not compression; it is a new kind of emergency.
Compression is prediction with a receipt
The basic idea is simpler than the word model makes it sound. If I tell you that a message begins with 'meet me at the', you can make a good guess about what comes next. A compressor writes down common, predictable continuations with fewer bits and makes rare surprises cost more. Arithmetic coding is the receipt: it turns the probabilities into a reversible stream of bits.
I started with an integer context mixer. It looks at a handful of recent bytes through several small context tables, combines their guesses with fixed-point arithmetic, and feeds that probability to an arithmetic coder. Everything is bounded and deterministic. The same bytes in must produce the same bits out, regardless of whether the decoder is a phone or a microcontroller.
The first benchmark was promising
On 1,000 held-out SMS messages, the full integer mixer reduced payload size by 2.41×, or 3.33 bits per byte. A plain order-2 n-gram plus arithmetic coding reached 2.21×. The difference matters, but it is also the first warning in this story: most of the gain was coming from classical context modeling, not from a mysterious learned architecture.
The smaller 80 KB-table version still reached 2.08×. Against the same test set, Unishox2 reached 1.54×, a zstd dictionary 1.49×, smaz2 1.44× and Brotli 1.19×. Those are payload-only numbers. Packet headers, a codec identifier and integrity checks reduce the end-to-end gain, so this was evidence for a codec, not evidence that a live mesh would suddenly carry 2.41 times as much traffic.
Held-out SMS payload compression ratio (larger is better)
Lossless means surviving the weird messages
A demo that only compresses ordinary English is a magician choosing the card. Mesh users can send emoji, accented text, corrupted-looking bytes and messages containing words the model has never seen. I rebuilt the codec at the byte level with an explicit end-of-message bit and a raw fallback for expansion cases.
That produced 3,506 exact round trips: 12 synthetic held-out messages, 3,000 random multilingual or emoji strings, 500 random binary strings and the SMS benchmark inputs. Some inputs got larger—random binary could expand by as much as 2.29×—which is why the raw fallback is part of the design. A checksum or authenticated tag detects corruption; it must reject a damaged stream rather than display a plausible but wrong message.
Bit-exactness is the unglamorous part that makes the rest real. A floating-point predictor can make a slightly different rounding choice on two devices, which gives the range coder a different next bit; from there the decoder is lost in the woods. This version kept the probabilities and mixer in integer arithmetic, recorded the model version, and checked CRC-16 over the version plus the original message before display. The little test above exposes the same boundaries: UTF-8 bytes, packet envelope and an integrity check—not a hand-wavy promise that two devices will probably agree.
The neural model did not clear the gate
The obvious next bet was a tiny learned byte model. A 313K-parameter GRU pilot reached 2.895 bits per byte, better than the large-table mixer, and weight-only int8 quantization barely changed the smaller pilot. That was encouraging, but it did not answer the engineering question yet.
The gate I wrote down was tougher: beat the 256 KB integer-mixer baseline by at least 15% while staying within 256 KB. The 313K GRU needed roughly 306 KB in int8 form, and its result was not enough to clear that target. It still needed a C99 port, device latency measurements and bit-exact cross-language tests. A float pilot on a small text set is not an embedded product.
The channel was not mostly text
Then the premise moved. A public Meshtastic capture showed that text was only about 0.7% of packets and airtime; node information, position and telemetry dominated. Even a perfect text compressor would leave most of a congested channel untouched. The more useful research direction became state-conditional coding: compress recurring position, telemetry and node fields against what a receiver already knows, with periodic keyframes and a safe fallback.
That is a much better systems problem, but it is also a different project. It needs trace replay, firmware integration, compatibility policy and real-device field trials. Treating a good text-codec prototype as proof of that whole program would have made the claim larger than the evidence.
What would have come next
The next milestone was not another prettier compression chart. It was a C99 core with the same bounded integer operations, plus Swift, Kotlin/JNI and ESP32 bindings. A cross-language harness would feed every implementation the same corpus and require byte-for-byte identical encoded streams and decoded outputs. Then come the unromantic tests: fuzzed packets, model-version mismatch, a flipped bit in the range-coded payload, a full composer limit, and the raw fallback whenever the envelope is not smaller than the original.
The learned-model route had its own gate. A ≤256 KB int8 model would have needed to beat the 256 KB classical mixer by at least 15%, then earn a place on hardware by reporting encode/decode latency, RAM, energy and binary size—not just bits per byte in a notebook. The meaningful result would have been a Pareto frontier: a clear picture of what each byte of model memory buys, and where it stops buying enough.
The ambitious path was whole-mesh coding. A receiver could use the last known NodeDB state to send a short delta for a position or telemetry update, with periodic full keyframes so dropped packets cannot poison later decoding. That needs a trace replay before a field trial, compatibility modes for mixed fleets, and delivery measurements on a deliberately congested mesh. The original target was at least a 10-point first-try delivery improvement for 100–200-byte messages and a ≥30% airtime cut from state-conditional broadcasts. Those were planned gates, not results.
Why it is archived
Mesh Messaging Codec is shelved, not because the first numbers were bad, but because they made the next decision clearer. The work established a lossless byte-level baseline, showed where a tiny learned model might help, and exposed that text alone is not the mesh bottleneck. The remaining work belongs with a larger on-device-model and whole-mesh research program, not as a half-finished app marketed as a breakthrough.
That makes this a useful write-up to keep: it records the measurements, the safety constraints and the point where the original question stopped being the right one. The explainer and research plan are preserved; no field-delivery, adoption or device-speed result is claimed here.