LoRa chat application for M5Stack CardputerZero and the SX1262 radio built into the Cap LoRa-1262 accessory.
- Send and receive LoRa text messages
- Show radio status, RSSI/SNR, SPI probe results, and initialization diagnostics
- Use an SDL desktop display for UI development without Cap hardware
Run the bootstrap script once after cloning this repository:
./bootstrap.shIt fetches lvgl, spdlog, smooth_ui_toolkit, RadioLib, and pigweed under
dependencies/. RadioLib supplies the SX1262 driver. Device builds compile
Pigweed's pw_spi_linux, pw_i2c_linux, and pw_digital_io_linux Linux
userspace drivers (with their Pigweed dependencies) into the binary; SDL builds
do not use Pigweed.
SDL builds require SDL2 development files.
For SDL desktop testing:
cmake -S . -B build/sdl -DCAP_LORA_USE_SDL=ON
cmake --build build/sdl -j8For a native CardputerZero build:
cmake -S . -B build/cp0 -DCAP_LORA_USE_SDL=OFF
cmake --build build/cp0 -j8The desktop and device binaries are written to dist/sdl/ and dist/device/
respectively.
Run the SDL tests locally with:
cmake -S . -B build/tests -DCAP_LORA_USE_SDL=ON -DBUILD_TESTING=ON
cmake --build build/tests -j8
ctest --test-dir build/tests --output-on-failureGitHub Actions runs only the device test suite (CAP_LORA_USE_SDL=OFF) and
builds the Debian package. SDL builds and tests are reserved for local development.
Startup and shutdown logs are flushed immediately so they survive the forced
shutdown deadline. LVGL warnings and assertion failures include their source
location. The shutdown signal test enables SPDLOG_LEVEL=debug to log each
main-loop phase and prints the process exit code and captured logs on failure.
Set SPDLOG_LEVEL=debug when running manually to collect the same diagnostics.
Run the SDL build with:
CAP_LORA_SDL_ZOOM=2 ./dist/sdl/Cap-LoRa-1262The radio regulations notice defaults to Decline, which exits the app.
Press C or Right to select Accept, then Enter to confirm. Press 7 or
Space to toggle Don't show again before accepting. Select a radio region
to enable LoRa. If you skip setup, the app opens with the radio off.
Open Info and press S to return to the region picker. After upgrading from a
version with individual frequency and power settings, select your region again.
The updated notice appears once on upgrade before it can be dismissed again.
Use Z/C or Left/Right to cycle through regions. The picker shows the
frequency, conducted TX power, duty cycle, and bandwidth before you save.
Press Enter to save or Esc to skip or cancel. Other Cap Chat devices must use
the same region to communicate.
The picker lists the Meshtastic region table through NP_865 in table order.
Regions that cannot fit a full channel in the Cap's 868–923 MHz hardware
range show the table's frequency range, power limit, and duty cycle with Save
disabled. For supported regions, the carrier is centered in the overlap and
power is capped at the Cap's 22 dBm maximum. The app tracks
transmit airtime over a rolling hour while it is running. Choose the region
for your location and follow the applicable rules for point-to-point
operation. Meshtastic region table · Cap specifications
Key controls:
Z/Cor Left/Right: switch between Messages and InfoF/Xor Up/Down: select a message or scroll Info;Fn+F/Fn+Xselects messages- Enter: compose a message or reply to the selected message
Ctrl+C/Ctrl+V: copy the selected message or paste into the editorFn+H(Hon desktop): open Help; Esc closes it- Esc: close a dialog or exit
The SDL build displays the complete LoRa UI and uses a simulated backend for initialization, send, and receive/echo testing. It does not access SPI, GPIO, or I2C; real hardware initialization is performed only by a device build on a CardputerZero with the Cap attached.
The device build initializes the Cap's SX1262 over SPI and controls reset, busy, IRQ, and power through the CardputerZero GPIO/I2C interfaces. The backend accepts these optional environment-variable overrides (the defaults match the CardputerZero Cap wiring):
| Variable | Purpose |
|---|---|
LORA_SPI_DEV |
Explicit SPI device path (otherwise probes /dev/spidev0.1, then /dev/spidev0.0) |
LORA_RST_CHIP, LORA_RST_OFFSET |
GPIO chip and line for SX1262 reset |
LORA_BUSY_CHIP, LORA_BUSY_OFFSET |
GPIO chip and line for SX1262 BUSY |
LORA_IRQ_CHIP, LORA_IRQ_OFFSET |
GPIO chip and line for SX1262 IRQ |
HAT_5VOUT_CHIP, HAT_5VOUT_OFFSET |
Explicit active-low GPIO override for the 5V rail; both values must be set |
The Debian package launches the app as the APPLaunch user. That user must be a
member of the video, input, gpio, spi, and i2c groups, as configured
by the CardputerZero image. A package udev rule grants the gpio group write
access only to ext_5v_out/brightness; the UI and radio protocol code do not
run as root.
Radio initialization errors and SPI/GPIO diagnostics are shown in the app.
The executable is installed below /usr/share/Cap-LoRa-1262/. The package
installs its icon in APPLaunch's shared image directory and its desktop entry
under /usr/share/APPLaunch/applications/; these are the paths used by the
CardputerZero launcher for dynamic applications. Keeping only these launcher
integration files in APPLaunch preserves separation from the LoRa source and
executable.
When removing the legacy built-in LoRa page from APPLaunch, keep the
launcher's lora display-order token. The desktop entry uses Name=LoRa, and
that token keeps this external application in the same position as the former
built-in entry. Disable APPLaunch's CONFIG_CP0_LVGL_INIT_LORA (and its
RadioLib component if no other consumer remains) before deleting the shared
cp0 LoRa sources.
Build the CardputerZero arm64 Debian package on an x86 Linux or WSL2 host with
the Docker wrapper:
./packaging/docker/package_deb.shThe Docker packager downloads the CardputerZero BSP over HTTPS and verifies the
published SHA-256 for v0.0.4. For another BSP release, set both
BSP_VERSION/BSP_URL and its 64-character BSP_SHA256 before running the
wrapper. An unverified archive is refused by default; only a trusted local
mirror should use CAP_LORA_ALLOW_UNVERIFIED_BSP=1.
To package natively on a CardputerZero instead, run:
./packaging/deb/package_deb.shThe generated package is written to dist/:
dist/m5cardputerzero-cap-lora-1262_<version>_m5stack1_arm64.deb
See THIRD_PARTY_NOTICES.md for dependency licenses.