10 Commits
Author SHA1 Message Date
swaits 0fbd8412c2 chore: release 1.3.1 2026-04-23 18:25:50 -06:00
swaits ebd576b4e2 fix(boards): invert LilyGo T-Beam (classic) LED polarity via InvertedPin wrapper
The classic T-Beam's red LED on GPIO4 is wired active-low (anode to V+,
cathode to GPIO). Release v1.3.0 drove it as active-high, so the LED sat
lit at idle and dimmed briefly on TX/RX instead of flashing on activity.

Express the polarity where it physically lives — at the pin — via a new
generic InvertedPin<P> wrapper that swaps set_high/set_low. SimpleLed
stays polarity-agnostic and every other board's code path is
byte-for-byte unchanged from v1.3.0.

Empirically verified against hardware on both T-Beam boards: classic red
LED is now dark at idle and flashes on TX/RX; Supreme blue LED behaves
unchanged.
2026-04-23 18:04:20 -06:00
swaits a2c611841b chore: release 1.3.0 2026-04-23 12:50:03 -06:00
swaits a1b92356b3 feat(boards): LilyGo T-Beam (classic) support
First classic-ESP32 (non-S3) board in the firmware, and first SX127x
radio. ESP32 + SX1276 + SSD1306 OLED + AXP192 PMIC, CP2102 USB-UART
bridge. Pin map verified from MeshCore variants/lilygo_tbeam_SX1276.

The AXP192 gates power to the LoRa chip and OLED. Its I²C bus is
shared with the display, so the firmware builds I²C0 in blocking mode
first for the PMIC init, then converts the same handle to async and
hands it to the display task — avoids double-consuming the peripheral.

Lora-phy's Sx127x support drives DIO0 as the sole IRQ (SX127x has no
BUSY line); the chip runs from a crystal, tx_boost routes +20 dBm
through PA_BOOST.

The `esp-hal` / `esp-rtos` / `esp-backtrace` / `esp-println` deps have
been restructured so the chip flavour (esp32 vs esp32s3) is selected
at the per-board feature level instead of baked into the dep lines.
This keeps the existing S3 boards building on esp32s3 while the new
T-Beam feature selects classic esp32 via the same dependency set.

LoRaBoard gains supported_sf_bitmap() / supported_bw_bitmap() methods
(with SX126x defaults) so the T-Beam can report SF6–SF12 via GET_INFO
— the SX1276 has no SF5. radio_chip_id() reports 0x0011 per
donglora-protocol RadioChipId::Sx1276. freq_range_hz widens to the
SX1276 datasheet span of 137 MHz–1020 MHz.

New modules:
- src/hal/esp32.rs           — classic-ESP32 MCU primitives
- src/board/esp32.rs         — Sx127x radio + SSD1306 display pipe
- src/board/lilygo_tbeam.rs  — the board file
- src/driver/axp.rs          — AXP192 init added alongside AXP2101
2026-04-23 10:42:42 -06:00
swaits 7fca5fcb50 feat(boards): LilyGo T-Beam S3 Supreme support
ESP32-S3 + SX1262 + SH1106 OLED + AXP2101 PMIC, native USB-C.

The AXP2101 PMIC gates power to the LoRa chip and the OLED. Without
its init sequence (ALDO3 = 3.3 V for LoRa, ALDO1 = 3.3 V for OLED)
the SX1262 never responds on SPI and radio init fails.

Pin map verified against MeshCore's variants/lilygo_tbeam_supreme_SX1262.
PMIC lives on a dedicated I²C1 bus (SDA=42, SCL=41) separate from the
SH1106 on I²C0 (SDA=17, SCL=18); I²C1 is used blocking for a one-shot
init and then dropped. TCXO at 1.6 V via DIO3.

New src/driver/axp.rs holds the AXP2101 init sequence — kept minimal
(only the LoRa + OLED rails), since DongLoRa is a LoRa-over-USB bridge
and every other rail (GPS, BME280, IMU, SD, batt ADC) is out of scope.
2026-04-23 10:29:48 -06:00
swaits 6867439044 chore: release 1.2.1 2026-04-22 23:59:44 -06:00
swaits bcfe736b30 fix(radio): preserve RX session across transient failures
Extends the v1.1.0 "SET_CONFIG during RX auto-re-arms" invariant to
every failure path that can fire while a client has RX active:

* `Receiving.on(RxFailed)` now transitions to `ResumingRx` instead of
  `Idle`. A transient `next_packet` error re-arms the chip rather than
  ending the session.
* `TransmittingFromRx.on(TransmitFailed)` now transitions to
  `ResumingRx` instead of `Idle`. TX failure during RX still responds
  `TX_FAILED` to the caller, then returns to RX — matching the shape
  of the adjacent `ChannelBusy` handler, which already did this.
* `ResumingRx.on(StartRxFailed)` is now a bounded retry (5 attempts,
  25 ms backoff) rather than an immediate drop to `Idle`. Only after
  the retry budget is exhausted does the chip actually land in `Idle`,
  at which point it's genuinely wedged and needs reconfiguring.

Observable effect: the OLED dashboard no longer bounces to Splash
when a client (e.g. ai-bot) TXes while bridges are receiving.
Previously any single hiccup in the RX/TX/ResumeRX cycle would
announce `RadioEvent::Idle`, bouncing the OLED, and the radio would
sit in Idle with no client aware enough to re-issue RX_START —
stranding the session. The invariant should have held for the whole
RX window between `CMD_RX_START` and `CMD_RX_STOP`; now it does.

Implementation notes:

* Two new internal `RadioInput` variants: `ResumeRxRetry` drives the
  `ResumingRx` self-transition; `ResumeRxExhausted` breaks out to
  Idle after too many failed tries.
* New `resume_retries: u8` field on `RadioContext`, reset to 0 on
  every successful `StartRxOk`, bumped by `bump_resume_retries`.
* Constants `MAX_RESUME_RETRIES = 5` and `RESUME_RX_RETRY_BACKOFF_MS
  = 25` at the top of `radio.rs`.
* Removed the dead `announce_rx_failed` helper — its only caller was
  the now-deleted `Receiving.on(RxFailed) => Idle` edge.

No behavior change for the three paths where `Idle` remains the
correct landing state: initial `CmdRxStart` failure in `StartingRx`,
`CmdRxStop` in `Receiving`, and all three `TransmittingFromIdle`
outcomes (where RX wasn't running to begin with).
2026-04-22 23:59:12 -06:00
swaits 0033bbb941 chore: release 1.2.0 2026-04-22 20:50:11 -06:00
swaits 42a6b1142d feat(display): OLED dims a few seconds after last activity
Splash holds bright for 10 s on (re-)entry, then drops to dim while
LearnMore/Info keep alternating. The dashboard stays bright for 3 s
after the last packet or mode change, then dims in place without
disturbing the Listening/Transmitting state or the 1 s sparkline
timer. Cross-leaf TX↔RX hops stay bright throughout — `set_dim` is
fired by the 3 s timer handler as an action rather than as a sibling
`exit:` action, so mode-change leaf-crossings no longer flash
dim→bright on every swap.

Two driver families (`ssd1306::Ssd1306Async` and the in-tree
`Sh1106`) wrapped behind a single `DisplayBrightness` trait in
`src/driver/mod.rs`; the board trait's `DisplayDriver` associated
type now requires it. Dim/bright contrast values centralized as
`CONTRAST_BRIGHT` / `CONTRAST_DIM` constants — tune in one place.

`On.on(CmdReset)` now targets `LearnMore` directly rather than the
ancestor `Splash`. Under hsmc 0.2 up-transition semantics, targeting
an already-active ancestor unwinds only below it without re-descent;
the USB-disconnect reset path was previously relying on the old
re-enter-and-descend behavior and would have parked at `Splash`
with a dead alternation timer.

Bumps `hsmc` 0.1.0 → 0.2 for the up-transition semantic fix.
2026-04-22 19:38:42 -06:00
swaits fa1eeceb7c fix(boards): Elecrow ThinkNode-M2 uses CH340K, not CP2102
The shipping revision of this board has a WCH CH340K USB-UART bridge
(1a86:7522), not a Silicon Labs CP2102 as the original board-module
comment claimed. Update the doc header, and add the CH340K +
CH340-standard VID:PIDs to the `just flash` port list so we stop
falling through to espflash auto-detect on these boards.
2026-04-22 19:32:34 -06:00
20 changed files with 1111 additions and 46 deletions

No files matched your search

+157
View File
@@ -7,6 +7,163 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased]
## [1.3.1] - 2026-04-23
### Fixed
- **LilyGo T-Beam (classic) red LED now flashes on TX/RX** instead of
dimming off. The red LED under the OLED is wired active-LOW on this
board (anode to V+, cathode to GPIO4); v1.3.0 drove it as active-HIGH,
so the LED sat lit at idle and briefly dimmed during activity.
- Empirically verified on hardware against both T-Beam variants.
- Introduces `src/driver/inverted_pin.rs::InvertedPin<P>`, a generic
`OutputPin` wrapper that swaps `set_high`/`set_low`. Polarity is
expressed at the pin (where the physical wiring lives), so
`SimpleLed` stays polarity-agnostic and every other board's code
path is byte-for-byte unchanged.
- Classic T-Beam now constructs its LED as
`SimpleLed(InvertedPin(led_pin))` with pin init at `Level::High`
(dark at boot).
## [1.3.0] - 2026-04-23
### Added
- LilyGo T-Beam S3 Supreme board support (ESP32-S3 + SX1262 + SH1106
OLED + AXP2101 PMIC, native USB-C).
- Pin map verified against MeshCore's
`variants/lilygo_tbeam_supreme_SX1262`.
- New `src/driver/axp.rs` module with an AXP2101 init sequence
(ALDO3 = 3.3 V LoRa, ALDO1 = 3.3 V OLED). The PMIC gates LoRa and
display power — without it the SX1262 never responds on SPI.
- PMIC lives on a dedicated I²C1 bus (SDA=42, SCL=41), separate
from the SH1106 on I²C0 (SDA=17, SCL=18). I²C1 is used blocking
for a one-shot init and then dropped.
- TCXO driven at 1.6 V via DIO3 (MeshCore uses the same).
- LilyGo T-Beam (classic) board support (ESP32 + SX1276 + SSD1306
OLED + AXP192 PMIC, CP2102 USB-UART bridge). This is the first
board in the firmware on classic ESP32 (non-S3) and the first on
the SX127x radio family.
- Pin map verified against MeshCore's `variants/lilygo_tbeam_SX1276`.
- New `src/hal/esp32.rs` (classic-ESP32 MCU primitives, peripheral
DMA via `DMA_SPI2`) and `src/board/esp32.rs` (SX1276 radio helper
+ SSD1306 display pipe).
- AXP192 init added to `src/driver/axp.rs`: DCDC1 = 3.3 V for the
OLED, LDO2 = 3.3 V for the SX1276 PA_BOOST rail. Shares the
OLED I²C bus (SDA=21, SCL=22); the I²C instance is built in
blocking mode for PMIC init and converted to async for the
display task.
- SX127x support via lora-phy 3's `Sx127x<Sx1276>` +
`GenericSx127xInterfaceVariant` (DIO0 as the sole IRQ; no
BUSY line on SX127x). XTAL clocked (no TCXO), `tx_boost = true`
for the PA_BOOST path.
- `LoRaBoard` trait gains `supported_sf_bitmap()` and
`supported_bw_bitmap()` methods with SX126x defaults
(`0x1FE0`, `0x03FF`). T-Beam classic overrides SF to `0x1FC0`
(SF6–SF12) — the SX1276 has no SF5.
- `radio_chip_id()` reports `0x0011` (`RadioChipId::Sx1276`) and
`freq_range_hz()` widens to 137 MHz–1020 MHz per the SX1276
datasheet.
### Changed
- `Cargo.toml`: the `esp32s3` chip feature has been moved out of
the `esp-hal` / `esp-rtos` / `esp-backtrace` / `esp-println`
dependency lines and into each ESP board's feature list (as
`esp-hal/esp32s3`, etc.). This lets `lilygo_tbeam` select the
classic `esp32` chip flavour from the same dependency set.
## [1.2.1] - 2026-04-23
### Fixed
- **Radio no longer drops to Idle mid-RX-session on transient failures.**
Extends the v1.1.0 invariant ("`SET_CONFIG` during RX auto-re-arms")
to all failure paths that can occur while a client has RX active:
- `Receiving.on(RxFailed) => Idle` now transitions to `ResumingRx`
instead of `Idle`. A transient `next_packet` error re-arms the chip
rather than ending the RX session.
- `TransmittingFromRx.on(TransmitFailed) => Idle` now transitions to
`ResumingRx`. TX failure during an active RX session returns
`TX_FAILED` to the caller and resumes RX, matching the shape of the
adjacent `ChannelBusy` handler.
- `ResumingRx.on(StartRxFailed) => Idle` is now a bounded retry
(5 × 25 ms backoff via a new `bump_resume_retries` action and a
`ResumeRxRetry` / `ResumeRxExhausted` pair of internal events).
The chip only lands in `Idle` after exhausting the retry budget —
which means it's genuinely wedged and needs reconfiguring.
Visible effect: the OLED dashboard no longer bounces to Splash when
`ai-bot` (or any other client that TXes while RX is running) sends a
packet. Previously any of the three transitions above would fire
`RadioEvent::Idle`, which the display uses as its `Dashboard → Splash`
trigger; the radio would land in `Idle` with no client aware enough
to re-send `RX_START`, stranding the dashboard until the session was
manually torn down and restarted.
- Removed `announce_rx_failed` helper action: its only purpose was
emitting `RadioEvent::Idle` on the now-deleted `Receiving.on(RxFailed)
=> Idle` edge. No replacement needed — `ResumingRx` handles recovery
silently.
## [1.2.0] - 2026-04-22
### Added
- **OLED auto-dim after inactivity.** The display is bright on any
activity — splash entry, mode change into a dashboard leaf, packet
RX/TX — and dims after a short idle window. Splash holds bright for
10 s, then drops to dim while the LearnMore / Info carousel keeps
alternating. The dashboard stays bright for 3 s after the last
packet or mode change, then dims in place without changing
Listening/Transmitting state. Cross-leaf TX↔RX hops transition
bright→bright with no intermediate dim — `set_dim` is fired as an
action by the 3 s timer handler rather than as a sibling `exit:`
action, so mode-change leaf-crossings never see a flash.
- `DisplayBrightness` trait in `src/driver/mod.rs` unifies the
two-level backlight API across the `ssd1306` crate's `Ssd1306Async`
and the in-tree `Sh1106` driver. Contrast values centralized as
`CONTRAST_BRIGHT` (`0xFF`) and `CONTRAST_DIM` (`0x08`) constants so
the two levels can be tuned in one place.
### Changed
- `src/display.rs` statechart restructured:
- `Splash` gains `entry: set_bright` plus an action-only
`on(after 10s) => set_dim` handler so the splash bright window
is time-scoped without disturbing the LM↔Info alternation.
- `Dashboard` `Listening` and `Transmitting` each gain a nested
`*Bright` substate owning the `entry: set_bright` action. Packet
handlers moved into the leaves and target the leaf's `*Bright` —
sibling-to-sibling within the leaf restarts the 3 s timer without
re-entering the leaf itself (paint / 1 s sparkline timer
preserved). The 3 s timeout handler fires `set_dim` as an action
and up-transitions to the leaf, parking the machine at the leaf
with no active child.
- `On.on(CmdReset)` now targets `LearnMore` directly rather than
`Splash`. Under hsmc 0.2 up-transition semantics, targeting
`Splash` from within `Splash.LearnMore` (USB-disconnect race path)
would only unwind below `Splash` and park with no active child,
leaving the LM↔Info alternation timer dead and the QR frozen on
screen.
- `LoRaBoard::DisplayDriver` trait bound extended with
`+ DisplayBrightness` so brightness is part of the board contract
alongside `DrawTarget<Color = BinaryColor>`.
### Fixed
- Elecrow ThinkNode-M2 board doc corrected: the shipping revision
carries a WCH CH340K USB-UART bridge (USB `1a86:7522`), not a
Silicon Labs CP2102. `just flash elecrow_thinknode_m2` now matches
the CH340K / CH340 VID:PIDs directly instead of falling through
to espflash auto-detect.
### Dependencies
- `hsmc` bumped to `0.2` to pick up the up-transition fix (transition
to an already-active ancestor unwinds only the subtree strictly
below the target; no exit/entry on the target; no default descent).
## [1.1.0] - 2026-04-22
Small but high-value behavior change: `SET_CONFIG` issued while the
Generated
+30 -5
View File
@@ -486,7 +486,7 @@ dependencies = [
[[package]]
name = "donglora"
version = "1.1.0"
version = "1.3.1"
dependencies = [
"cfg-if",
"cortex-m",
@@ -1060,6 +1060,8 @@ dependencies = [
"rand_core 0.6.4",
"rand_core 0.9.5",
"riscv",
"sha1",
"sha2",
"strum",
"ufmt-write",
"xtensa-lx",
@@ -1116,6 +1118,7 @@ dependencies = [
"cfg-if",
"document-features",
"esp-metadata-generated",
"esp32",
"esp32s3",
]
@@ -1404,9 +1407,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hsmc"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d8cb8820e7ff5fa4fa4b5dbb78b9f59d26ccc8e3bcf69d8f4c4ce29ee01b93a"
checksum = "960effec6ded897c013d5cde8fb7f09bf0137e783efc4c2e0346092a2941c46e"
dependencies = [
"embassy-futures",
"embassy-sync 0.8.0",
@@ -1417,9 +1420,9 @@ dependencies = [
[[package]]
name = "hsmc-macros"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4fa4dad2c05309fae4f6d15b74d9b37c1fd7325a96701972fdad89637635160"
checksum = "3e1933eea1e95edb4fa03688f969f0a1ffabc4f16fc396b40ead6bedd5c4bdff"
dependencies = [
"proc-macro2",
"quote",
@@ -2204,6 +2207,28 @@ dependencies = [
"unsafe-libyaml",
]
[[package]]
name = "sha1"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sha2"
version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sha2-const-stable"
version = "0.1.0"
+44 -8
View File
@@ -3,7 +3,7 @@ members = ["."]
[package]
name = "donglora"
version = "1.1.0"
version = "1.3.1"
edition = "2021"
build = "build.rs"
authors = ["Stephen Waits <steve@waits.net>"]
@@ -30,8 +30,8 @@ embassy-usb = { version = "0.6", features = ["defmt"] }
embassy-usb-driver = "0.2"
ucobs = { version = "0.3", features = ["legacy-msrv"] }
heapless = "0.9"
donglora-protocol = "1.1.0"
hsmc = { version = "0.1.0", default-features = false, features = ["embassy"] }
donglora-protocol = "1"
hsmc = { version = "0.2", default-features = false, features = ["embassy"] }
lora-phy = "3.0"
portable-atomic = { version = "1", optional = true, default-features = false, features = ["critical-section"] }
static_cell = "2.1"
@@ -45,22 +45,20 @@ ssd1306 = { version = "0.10", features = ["async"] }
embedded-io-async = "0.7"
embassy-futures = "0.1"
# ESP32-S3 (Heltec V3) — requires esp toolchain (espup)
# Xtensa ESP crates — requires esp toolchain (espup). The chip feature
# (esp32 / esp32s3) is selected per board via the board-level feature flag
# below, so the same dep lines support both classic ESP32 and ESP32-S3.
esp-backtrace = { version = "0.18", optional = true, features = [
"esp32s3",
"panic-handler",
"defmt",
] }
esp-hal = { version = "1.0", optional = true, features = [
"esp32s3",
"unstable",
] }
esp-println = { version = "0.16", optional = true, features = [
"esp32s3",
"defmt-espflash",
] }
esp-rtos = { version = "0.2", optional = true, features = [
"esp32s3",
"embassy",
] }
@@ -110,6 +108,10 @@ heltec_v3 = [
"dep:esp-hal",
"dep:esp-println",
"dep:esp-rtos",
"esp-backtrace/esp32s3",
"esp-hal/esp32s3",
"esp-println/esp32s3",
"esp-rtos/esp32s3",
]
heltec_v3_uart = [
"embassy",
@@ -117,6 +119,10 @@ heltec_v3_uart = [
"dep:esp-hal",
"dep:esp-println",
"dep:esp-rtos",
"esp-backtrace/esp32s3",
"esp-hal/esp32s3",
"esp-println/esp32s3",
"esp-rtos/esp32s3",
]
heltec_v4 = [
"embassy",
@@ -124,6 +130,10 @@ heltec_v4 = [
"dep:esp-hal",
"dep:esp-println",
"dep:esp-rtos",
"esp-backtrace/esp32s3",
"esp-hal/esp32s3",
"esp-println/esp32s3",
"esp-rtos/esp32s3",
]
elecrow_thinknode_m2 = [
"embassy",
@@ -131,6 +141,32 @@ elecrow_thinknode_m2 = [
"dep:esp-hal",
"dep:esp-println",
"dep:esp-rtos",
"esp-backtrace/esp32s3",
"esp-hal/esp32s3",
"esp-println/esp32s3",
"esp-rtos/esp32s3",
]
lilygo_tbeam_supreme = [
"embassy",
"dep:esp-backtrace",
"dep:esp-hal",
"dep:esp-println",
"dep:esp-rtos",
"esp-backtrace/esp32s3",
"esp-hal/esp32s3",
"esp-println/esp32s3",
"esp-rtos/esp32s3",
]
lilygo_tbeam = [
"embassy",
"dep:esp-backtrace",
"dep:esp-hal",
"dep:esp-println",
"dep:esp-rtos",
"esp-backtrace/esp32",
"esp-hal/esp32",
"esp-println/esp32",
"esp-rtos/esp32",
]
rak_wisblock_4631 = [
"embassy",
+2
View File
@@ -24,6 +24,8 @@ All commands are run from the `firmware/` directory.
| Heltec V3 (UART) | `heltec_v3_uart` | ESP32-S3 | SX1262 | CP2102 bridge | xtensa-esp32s3-none-elf |
| Heltec V4 | `heltec_v4` | ESP32-S3 | SX1262 | Native CDC-ACM | xtensa-esp32s3-none-elf |
| ELECROW ThinkNode-M2 | `elecrow_thinknode_m2` | ESP32-S3 | SX1262 | CP2102 bridge | xtensa-esp32s3-none-elf |
| LilyGo T-Beam | `lilygo_tbeam` | ESP32 | SX1276 | CP2102 bridge | xtensa-esp32-none-elf |
| LilyGo T-Beam S3 Supreme | `lilygo_tbeam_supreme` | ESP32-S3 | SX1262 | Native CDC-ACM | xtensa-esp32s3-none-elf |
| RAK WisBlock 4631 | `rak_wisblock_4631` | nRF52840 | SX1262 | Native CDC-ACM | thumbv7em-none-eabihf |
| Waveshare RP2040-LoRa | `waveshare_rp2040_lora` | RP2040 | SX1262 | Native CDC-ACM | thumbv6m-none-eabi |
| Wio Tracker L1 | `wio_tracker_l1` | nRF52840 | SX1262 | Native CDC-ACM | thumbv7em-none-eabihf |
+6 -2
View File
@@ -10,6 +10,8 @@ heltec_v3 := "heltec_v3 xtensa-esp32s3-none-elf esp32s3"
heltec_v3_uart := "heltec_v3_uart xtensa-esp32s3-none-elf esp32s3"
heltec_v4 := "heltec_v4 xtensa-esp32s3-none-elf esp32s3"
elecrow_thinknode_m2 := "elecrow_thinknode_m2 xtensa-esp32s3-none-elf esp32s3"
lilygo_tbeam := "lilygo_tbeam xtensa-esp32-none-elf esp32"
lilygo_tbeam_supreme := "lilygo_tbeam_supreme xtensa-esp32s3-none-elf esp32s3"
rak_wisblock_4631 := "rak_wisblock_4631 thumbv7em-none-eabihf nRF52840_xxAA"
wio_tracker_l1 := "wio_tracker_l1 thumbv7em-none-eabihf nRF52840_xxAA"
waveshare_rp2040_lora := "waveshare_rp2040_lora thumbv6m-none-eabi rp2040"
@@ -18,7 +20,7 @@ builds_dir := "builds"
version := `sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml`
# All known boards
boards := "heltec_v3 heltec_v3_uart heltec_v4 elecrow_thinknode_m2 rak_wisblock_4631 waveshare_rp2040_lora wio_tracker_l1"
boards := "heltec_v3 heltec_v3_uart heltec_v4 elecrow_thinknode_m2 lilygo_tbeam lilygo_tbeam_supreme rak_wisblock_4631 waveshare_rp2040_lora wio_tracker_l1"
# Install all required tools and toolchains
setup:
@@ -77,7 +79,7 @@ flash board:
@read -r feat target chip <<< "$(just _info {{board}})"; \
case "$target" in \
xtensa-*) \
port=$(just _find_port "303a:1001" "1209:5741" "10c4:ea60"); \
port=$(just _find_port "303a:1001" "1209:5741" "10c4:ea60" "1a86:7522" "1a86:7523"); \
if [ -n "$port" ]; then \
echo "Using $port"; \
espflash flash -p "$port" "{{builds_dir}}/donglora-{{board}}-v{{version}}.elf"; \
@@ -214,6 +216,8 @@ _info name:
elif [ "{{name}}" == "heltec_v3_uart" ]; then echo "{{heltec_v3_uart}}"; \
elif [ "{{name}}" == "heltec_v4" ]; then echo "{{heltec_v4}}"; \
elif [ "{{name}}" == "elecrow_thinknode_m2" ]; then echo "{{elecrow_thinknode_m2}}"; \
elif [ "{{name}}" == "lilygo_tbeam" ]; then echo "{{lilygo_tbeam}}"; \
elif [ "{{name}}" == "lilygo_tbeam_supreme" ]; then echo "{{lilygo_tbeam_supreme}}"; \
elif [ "{{name}}" == "rak_wisblock_4631" ]; then echo "{{rak_wisblock_4631}}"; \
elif [ "{{name}}" == "waveshare_rp2040_lora" ]; then echo "{{waveshare_rp2040_lora}}"; \
elif [ "{{name}}" == "wio_tracker_l1" ]; then echo "{{wio_tracker_l1}}"; \
+3 -3
View File
@@ -1,8 +1,8 @@
//! ELECROW ThinkNode-M2 — ESP32-S3 Meshtastic handset with SH1106 OLED.
//!
//! Tamagotchi-form-factor handheld: ESP32-S3-WROOM-1-N4 + SX1262 + 1.3" SH1106
//! OLED + CP2102 UART bridge + 1000 mAh Li-Po. Sold pre-loaded with Meshtastic;
//! this firmware turns it into a DongLoRa radio bridge.
//! OLED + WCH CH340K UART bridge + 1000 mAh Li-Po. Sold pre-loaded with
//! Meshtastic; this firmware turns it into a DongLoRa radio bridge.
//!
//! Pin map (verified from Meshtastic's variants/esp32s3/ELECROW-ThinkNode-M2
//! and PR meshtastic/firmware#6354):
@@ -11,7 +11,7 @@
//! LoRa pwr: GPIO48 (must be HIGH before any SPI traffic)
//! OLED: I2C0 SDA=16, SCL=15, SH1106 @ 0x3C
//! VEXT: GPIO46 (active HIGH — gates OLED supply)
//! UART: TX=43, RX=44 via CP2102 bridge
//! UART: TX=43, RX=44 via CH340K bridge (USB 1a86:7522)
//! LED: GPIO6 (active HIGH indicator)
//!
//! Notable differences from the Heltec ESP32-S3 boards:
+103
View File
@@ -0,0 +1,103 @@
//! Shared types and peripheral wiring for classic-ESP32 SX1276 boards.
//!
//! Counterpart to `board::esp32s3` for the SX126x line. Builds an
//! `Sx127x<Sx1276>` driver from an already-initialized SPI bus plus the
//! board's reset and DIO0 pins. SX127x has no `BUSY` line — DIO0 carries
//! every IRQ (TX done, RX done, header valid, …) and lora-phy's
//! `GenericSx127xInterfaceVariant` waits on it directly.
use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice;
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_time::Delay;
use esp_hal::gpio::{Input, InputConfig, InputPin, Level, Output, OutputConfig, OutputPin, Pull};
use lora_phy::iv::GenericSx127xInterfaceVariant;
use lora_phy::sx127x::{self, Sx127x};
use crate::hal::esp32 as mcu;
// ── Re-export MCU types ─────────────────────────────────────────────
pub use mcu::{I2cBus as DisplayI2c, SpiBus};
// ── Concrete peripheral types ───────────────────────────────────────
type Nss = Output<'static>;
type Iv = GenericSx127xInterfaceVariant<Output<'static>, Input<'static>>;
type RadioSpiDevice = SpiDevice<'static, NoopRawMutex, SpiBus, Nss>;
pub type RadioDriver = Sx127x<RadioSpiDevice, Iv, sx127x::Sx1276>;
// ── Peripheral bundles ──────────────────────────────────────────────
pub struct RadioParts {
pub driver: RadioDriver,
pub delay: Delay,
}
pub struct DisplayParts {
pub i2c: DisplayI2c,
}
// ── Display driver ──────────────────────────────────────────────────
pub type DisplayDriver = ssd1306::Ssd1306Async<
ssd1306::prelude::I2CInterface<DisplayI2c>,
ssd1306::size::DisplaySize128x64,
ssd1306::mode::BufferedGraphicsModeAsync<ssd1306::size::DisplaySize128x64>,
>;
/// Construct and initialize an SSD1306 display from raw I²C.
pub async fn create_display(i2c: DisplayI2c) -> Option<DisplayDriver> {
use ssd1306::mode::DisplayConfigAsync;
use ssd1306::prelude::{Brightness, DisplayRotation};
use ssd1306::size::DisplaySize128x64;
use ssd1306::{I2CDisplayInterface, Ssd1306Async};
let interface = I2CDisplayInterface::new(i2c);
let mut display = Ssd1306Async::new(interface, DisplaySize128x64, DisplayRotation::Rotate0)
.into_buffered_graphics_mode();
embassy_time::Timer::after_millis(100).await;
if display.init().await.is_err() {
defmt::error!("SSD1306 display init failed");
return None;
}
let _ = display.set_brightness(Brightness::BRIGHTEST).await;
Some(display)
}
// ── Shared peripheral init helpers ──────────────────────────────────
/// Construct an SX1276 radio from an initialized SPI bus.
///
/// `dio0` is the primary IRQ (TX/RX done). The SX1276 module on the T-Beam
/// runs from a crystal oscillator, not a TCXO, and power comes from the
/// AXP192's PA_BOOST rail — `tx_boost = true` routes TX through the PA
/// output for +20 dBm.
pub fn init_radio(
spi_bus: &'static embassy_sync::mutex::Mutex<NoopRawMutex, SpiBus>,
nss_pin: impl OutputPin + 'static,
reset_pin: impl OutputPin + 'static,
dio0_pin: impl InputPin + 'static,
) -> RadioParts {
let nss = Output::new(nss_pin, Level::High, OutputConfig::default());
let spi_device = SpiDevice::new(spi_bus, nss);
let reset = Output::new(reset_pin, Level::High, OutputConfig::default());
let dio0 = Input::new(dio0_pin, InputConfig::default().with_pull(Pull::Down));
let iv = GenericSx127xInterfaceVariant::new(reset, dio0, None, None)
.expect("SX1276 interface init");
let sx_config = sx127x::Config {
chip: sx127x::Sx1276,
tcxo_used: false,
tx_boost: true,
rx_boost: false,
};
RadioParts {
driver: Sx127x::new(spi_device, iv, sx_config),
delay: Delay,
}
}
+140
View File
@@ -0,0 +1,140 @@
//! LilyGo T-Beam (classic) — ESP32 + SX1276 + SSD1306 OLED + AXP192 PMIC.
//!
//! First-generation T-Beam. ESP32 (dual-core Xtensa LX6, no native USB),
//! SX1276 module with XTAL (no TCXO), 128×64 SSD1306 OLED, AXP192 PMIC
//! gating the LoRa and OLED rails, CP2102 USB-UART bridge for host I/O.
//!
//! The AXP192 shares an I²C bus with the OLED (SDA=21, SCL=22). PMIC init
//! runs blocking on that bus first, then the same pins are re-initialized
//! in async mode for the display task.
//!
//! Pin map (verified from MeshCore variants/lilygo_tbeam_SX1276/):
//! LoRa SPI: SCK=5, MOSI=27, MISO=19, CS=18
//! LoRa ctl: RESET=23, DIO0=26 (primary IRQ — SX127x has no BUSY)
//! OLED I²C: SDA=21, SCL=22, SSD1306 @ 0x3C (shared with AXP192 @ 0x34)
//! UART host: TX=1, RX=3 via CP2102 bridge (USB 10c4:ea60)
//! LED: GPIO4 (active LOW — red LED under the OLED, wrapped in
//! InvertedPin so SimpleLed sees normal polarity)
//!
//! GPS / battery / IMU / PCF8563 RTC are populated on the board but unused
//! by this firmware.
use esp_hal::gpio::{Level, Output, OutputConfig};
use esp_hal::i2c::master::{Config as I2cConfig, I2c};
use super::esp32;
use super::traits::{BoardParts, LoRaBoard};
use crate::driver::axp;
use crate::driver::inverted_pin::InvertedPin;
use crate::driver::simple_led::SimpleLed;
use crate::hal::esp32 as mcu;
use crate::protocol::RadioChipId;
pub use super::esp32::{create_display, DisplayDriver, DisplayParts, RadioDriver, RadioParts};
// ── Concrete peripheral types ───────────────────────────────────────
pub type UartDriver = esp_hal::uart::Uart<'static, esp_hal::Async>;
pub type LedDriver = SimpleLed<InvertedPin<Output<'static>>>;
// ── Peripheral bundles ──────────────────────────────────────────────
pub struct UartParts {
pub driver: UartDriver,
}
// ── Board init ──────────────────────────────────────────────────────
pub struct Board {
p: esp_hal::peripherals::Peripherals,
}
impl LoRaBoard for Board {
const NAME: &'static str = "LilyGo T-Beam";
// SX1276 PA_BOOST range per the datasheet: +2 dBm min, +20 dBm max.
const TX_POWER_RANGE: (i8, i8) = (2, 20);
type RadioParts = RadioParts;
type CommParts = UartParts;
type DisplayParts = DisplayParts;
type DisplayDriver = DisplayDriver;
type LedDriver = LedDriver;
fn init() -> Self {
let p = esp_hal::init(esp_hal::Config::default());
Self { p }
}
fn mac_address() -> [u8; 6] {
mcu::mac_address()
}
fn radio_chip_id() -> u16 {
RadioChipId::Sx1276.as_u16()
}
fn freq_range_hz() -> (u32, u32) {
// SX1276 tuning window per datasheet (LF + HF bands combined).
(137_000_000, 1_020_000_000)
}
fn supported_sf_bitmap() -> u16 {
// SX127x supports SF6–SF12 (no SF5 like the SX126x).
0x1FC0
}
fn into_parts(self) -> BoardParts<RadioParts, UartParts, DisplayParts, LedDriver> {
let p = self.p;
mcu::start_timer(p.TIMG0, p.SW_INTERRUPT);
// AXP192 and SSD1306 share I²C0 (SDA=21, SCL=22). Build the bus
// once as blocking, drive the PMIC init, then convert to async for
// the display task — avoids re-consuming the I²C0 peripheral.
// PMIC failure isn't fatal to boot: log and proceed so the rest of
// the firmware can still emit diagnostics.
let mut i2c_blocking = I2c::new(p.I2C0, I2cConfig::default())
.expect("I2C0 init")
.with_sda(p.GPIO21)
.with_scl(p.GPIO22);
if let Err(_e) = axp::axp192_init_lora_oled(&mut i2c_blocking) {
defmt::error!("AXP192 init failed — LoRa rail may be dead");
}
// Let DCDC1 / LDO2 settle before SPI or display traffic.
esp_hal::delay::Delay::new().delay_millis(20);
// SPI2 for SX1276: SCK=5, MOSI=27, MISO=19
let spi_bus = mcu::init_spi(p.SPI2, p.DMA_SPI2, p.GPIO5, p.GPIO27, p.GPIO19);
// SX1276: CS=18, RESET=23, DIO0=26 (primary IRQ)
let radio = esp32::init_radio(spi_bus, p.GPIO18, p.GPIO23, p.GPIO26);
// UART0 via CP2102 bridge: TX=1, RX=3 (ESP32 default console)
use esp_hal::uart::{Config as UartConfig, Uart};
let host = UartParts {
driver: Uart::new(p.UART0, UartConfig::default())
.expect("UART init")
.with_tx(p.GPIO1)
.with_rx(p.GPIO3)
.into_async(),
};
// Hand the (now async) I²C bus to the SSD1306 display task.
let display = Some(DisplayParts {
i2c: i2c_blocking.into_async(),
});
// TX activity LED on GPIO4 (active LOW — pin idles HIGH = LED off).
// InvertedPin flips set_high/set_low so SimpleLed stays polarity-agnostic.
let led_pin = Output::new(p.GPIO4, Level::High, OutputConfig::default());
let led = SimpleLed(InvertedPin(led_pin));
BoardParts {
radio,
host,
display,
led,
mac: Self::mac_address(),
}
}
}
+153
View File
@@ -0,0 +1,153 @@
//! LilyGo T-Beam S3 Supreme — ESP32-S3 + SX1262 + SH1106 OLED + AXP2101 PMIC.
//!
//! Big-brother of the classic T-Beam: ESP32-S3-WROOM-1 module, SX1262 with a
//! TCXO, 128×64 SH1106 OLED, AXP2101 PMIC on a dedicated I²C1 bus. Native USB
//! (no UART bridge chip).
//!
//! The AXP2101 gates power to the SX1262 and OLED. Without its init sequence
//! the LoRa chip never responds on SPI and `LoRa::new` fails.
//!
//! Pin map (verified from MeshCore variants/lilygo_tbeam_supreme_SX1262/):
//! LoRa SPI: SCK=12, MOSI=11, MISO=13, CS=10
//! LoRa ctl: RESET=5, DIO1=1, BUSY=4 (TCXO @ 1.6 V via DIO3)
//! OLED I²C: SDA=17, SCL=18, SH1106 @ 0x3C (I²C0)
//! PMIC I²C: SDA=42, SCL=41, AXP2101 @ 0x34 (I²C1, blocking, PMIC-only)
//! USB: native USB-C on GPIO19/20 (fixed ESP32-S3 D+/D-)
//! LED: GPIO6 (active HIGH indicator, reuses MeshCore's P_LORA_TX_LED)
//!
//! GPS / battery / IMU / SD / BME280 are unused — DongLoRa is a transparent
//! LoRa-over-USB bridge. The PMIC init only enables ALDO1 (OLED) and ALDO3
//! (LoRa); other rails are left at their AXP2101 power-on defaults.
use esp_hal::gpio::{Level, Output, OutputConfig};
use esp_hal::i2c::master::{Config as I2cConfig, I2c};
use static_cell::StaticCell;
use super::esp32s3;
use super::traits::{BoardParts, LoRaBoard};
use crate::driver::axp;
use crate::driver::sh1106::Sh1106;
use crate::driver::simple_led::SimpleLed;
use crate::hal::esp32s3 as mcu;
pub use super::esp32s3::{DisplayI2c, RadioDriver, RadioParts};
// ── Concrete peripheral types ───────────────────────────────────────
pub type DisplayDriver = Sh1106<DisplayI2c>;
pub type UsbDriver = esp_hal::otg_fs::asynch::Driver<'static>;
pub type LedDriver = SimpleLed<Output<'static>>;
// ── Peripheral bundles ──────────────────────────────────────────────
pub struct UsbParts {
pub driver: UsbDriver,
}
pub struct DisplayParts {
pub i2c: DisplayI2c,
}
// ── Display init ────────────────────────────────────────────────────
pub async fn create_display(i2c: DisplayI2c) -> Option<DisplayDriver> {
let mut display = Sh1106::new(i2c, 0x3C);
embassy_time::Timer::after_millis(100).await;
if display.init().await.is_err() {
defmt::error!("SH1106 display init failed");
return None;
}
let _ = display.set_brightness(0xFF).await;
Some(display)
}
// ── Board init ──────────────────────────────────────────────────────
pub struct Board {
p: esp_hal::peripherals::Peripherals,
}
impl LoRaBoard for Board {
const NAME: &'static str = "LilyGo T-Beam S3 Supreme";
const TX_POWER_RANGE: (i8, i8) = (-9, 22);
type RadioParts = RadioParts;
type CommParts = UsbParts;
type DisplayParts = DisplayParts;
type DisplayDriver = DisplayDriver;
type LedDriver = LedDriver;
fn init() -> Self {
let p = esp_hal::init(esp_hal::Config::default());
Self { p }
}
fn mac_address() -> [u8; 6] {
mcu::mac_address()
}
fn into_parts(self) -> BoardParts<RadioParts, UsbParts, DisplayParts, LedDriver> {
let p = self.p;
mcu::start_timer(p.TIMG0, p.SW_INTERRUPT);
// AXP2101 PMIC on I²C1 (SDA=42, SCL=41). Blocking, one-shot: we only
// need to flip the LoRa/OLED rails on, then the bus can be dropped.
// If this fails the LoRa chip stays unpowered — log and keep going so
// the rest of the boot path can still produce diagnostics.
{
let mut pmic = I2c::new(p.I2C1, I2cConfig::default())
.expect("I2C1 init")
.with_sda(p.GPIO42)
.with_scl(p.GPIO41);
if let Err(_e) = axp::axp2101_init_lora_oled(&mut pmic) {
defmt::error!("AXP2101 init failed — LoRa rail may be dead");
}
}
// Let ALDO1/ALDO3 settle before touching the LoRa SPI or OLED I²C.
esp_hal::delay::Delay::new().delay_millis(20);
// SPI2 for SX1262: SCK=12, MOSI=11, MISO=13
let spi_bus = mcu::init_spi(p.SPI2, p.DMA_CH0, p.GPIO12, p.GPIO11, p.GPIO13);
// SX1262: CS=10, RESET=5, DIO1=1, BUSY=4, TCXO @ 1.6 V via DIO3.
let radio = esp32s3::init_radio(
spi_bus,
p.GPIO10,
p.GPIO5,
p.GPIO1,
p.GPIO4,
lora_phy::sx126x::TcxoCtrlVoltage::Ctrl1V6,
);
// Native USB-C on GPIO19/20. Switches the internal USB PHY from
// Serial-JTAG to OTG.
let usb_inst = esp_hal::otg_fs::Usb::new(p.USB0, p.GPIO20, p.GPIO19);
static EP_OUT_BUF: StaticCell<[u8; 1024]> = StaticCell::new();
let ep_out_buf = EP_OUT_BUF.init([0u8; 1024]);
let host = UsbParts {
driver: esp_hal::otg_fs::asynch::Driver::new(
usb_inst,
ep_out_buf,
esp_hal::otg_fs::asynch::Config::default(),
),
};
// I2C0 for SH1106 OLED: SDA=17, SCL=18 (async, handed to display task).
let i2c = mcu::init_i2c(p.I2C0, p.GPIO17, p.GPIO18);
let display = Some(DisplayParts { i2c });
// Activity LED on GPIO6 (active HIGH).
let led_pin = Output::new(p.GPIO6, Level::Low, OutputConfig::default());
let led = SimpleLed(led_pin);
BoardParts {
radio,
host,
display,
led,
mac: Self::mac_address(),
}
}
}
+4
View File
@@ -3,7 +3,11 @@ pub mod traits;
pub use traits::*;
{% for helper, helper_features in helpers|items -%}
{% if helper_features|length == 1 -%}
#[cfg(feature = "{{ helper_features[0] }}")]
{% else -%}
#[cfg(any({% for f in helper_features %}feature = "{{ f }}"{% if not loop.last %}, {% endif %}{% endfor %}))]
{% endif -%}
mod {{ helper }};
{% endfor %}
cfg_if::cfg_if! {
+20 -2
View File
@@ -9,6 +9,8 @@
use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::pixelcolor::BinaryColor;
use crate::driver::DisplayBrightness;
/// Async RGB LED control. Boards without an LED use `()` which is a no-op.
pub trait RgbLed {
fn set_rgb(&mut self, r: u8, g: u8, b: u8) -> impl core::future::Future<Output = ()>;
@@ -35,8 +37,9 @@ pub trait LoRaBoard: Sized {
/// Display peripheral bundle (I2C bus for display init).
type DisplayParts;
/// Concrete display driver type (must implement DrawTarget for rendering).
type DisplayDriver: DrawTarget<Color = BinaryColor>;
/// Concrete display driver type (must implement DrawTarget for rendering
/// and DisplayBrightness for the two-level dim control).
type DisplayDriver: DrawTarget<Color = BinaryColor> + DisplayBrightness;
/// RGB LED driver. Boards without an LED use `()`.
type LedDriver: RgbLed;
@@ -62,6 +65,21 @@ pub trait LoRaBoard: Sized {
(150_000_000, 960_000_000)
}
/// Bitmap of supported LoRa spreading factors — bit N = SF N. Defaults
/// to SX126x's SF5–SF12 (`0x1FE0`). SX127x boards must override to
/// `0x1FC0` (SF6–SF12); LLCC68 boards to `0x0FE0` (SF5–SF11).
fn supported_sf_bitmap() -> u16 {
0x1FE0
}
/// Bitmap of supported LoRa bandwidths. Bit positions match
/// `LoRaBandwidth::as_u8()` (sub-GHz BW enum values 0..9). Defaults
/// to all sub-GHz BWs (`0x03FF`). SX128x boards flip the 2.4 GHz
/// bits when we add them.
fn supported_bw_bitmap() -> u16 {
0x03FF
}
/// Decompose initialized board into peripheral bundles for each task.
fn into_parts(
self,
+66 -7
View File
@@ -37,6 +37,7 @@ use embassy_time::Timer;
use hsmc::statechart;
use crate::board::{self, Board, DisplayDriver, DisplayParts, LedDriver, LoRaBoard, RgbLed};
use crate::driver::DisplayBrightness;
use crate::channel::{DisplayCommand, DisplayCommandChannel, RadioEvent, RadioEventChannel};
use crate::protocol::LoRaConfig;
@@ -220,6 +221,14 @@ impl DisplayContext {
Timer::after_millis(50).await;
self.peripherals.led.set_rgb(0, 0, 0).await;
}
async fn oled_bright(&mut self) {
self.peripherals.display.set_bright().await;
}
async fn oled_dim(&mut self) {
self.peripherals.display.set_dim().await;
}
}
// ── Statechart ─────────────────────────────────────────────────────
@@ -243,16 +252,26 @@ statechart! {
on(CmdOff) => Off;
// `CmdReset` + `RadioIdle` race on USB disconnect; this handler
// makes either ordering land in the same place. Reset the run
// state, turn off any blink-in-progress, and re-enter Splash —
// descend_defaults lands us in LearnMore with a fresh 5 s timer.
on(CmdReset) => reset_run_state, turn_led_off, Splash;
// state, turn off any blink-in-progress, and land in LearnMore
// with a fresh 5 s timer. We target `LearnMore` (not `Splash`)
// because under hsmc 0.2 up-transition semantics, targeting a
// state that's already on the active path would only unwind
// below it — we'd park at `Splash` with no active child and
// the alternation timer would never restart.
on(CmdReset) => reset_run_state, turn_led_off, LearnMore;
// Config can arrive before the dashboard is up; cache it anywhere.
on(ConfigChanged(cfg: LoRaConfig)) => save_new_config;
// Splash is bright for the first 10 s of (re-)entry, then the
// action-only `on(after 10s)` handler drops the OLED to dim.
// LearnMore ↔ Info keep alternating underneath — their own
// timers are independent of the 10 s window.
state Splash {
entry: set_bright;
default(LearnMore);
on(EnteredRx) => Listening;
on(EnteredTx) => Transmitting;
on(after Duration::from_secs(10)) => set_dim;
state LearnMore {
entry: paint_learn_more;
@@ -265,24 +284,56 @@ statechart! {
}
}
// Dashboard brightness pattern: each mode-leaf holds a `Bright`
// substate. `entry: set_bright` owns the backlight going on;
// `set_dim` is fired **as an action** by the 3 s timeout
// handler, immediately before the up-transition that parks
// the machine at the leaf. The symmetric `exit: set_dim`
// would also fire on mode-change leaf-crossings (e.g.
// ListeningBright → TransmittingBright via EnteredTx), and
// the subsequent default descent would fire `set_bright`
// again — producing a visible dim/bright flash on every
// TX↔RX swap. Anchoring dim to the *timer* handler instead
// means leaf-crossings go bright→bright with no intermediate
// dim action. CmdOff/CmdReset exit paths don't fire set_dim
// either, which is fine — the display is blanked or walked
// back to Splash, which re-asserts its own brightness.
state Dashboard {
default(Listening);
on(RadioIdle) => Splash;
// Packet events are pure data + one-shot LED feedback.
on(PacketRx { rssi: i16, snr: Option<i16> }) => record_rx_packet, blink_rx_led;
on(PacketTx) => record_tx_packet, blink_tx_led;
state Listening {
entry: paint_listening;
default(ListeningBright);
on(EnteredTx) => Transmitting;
on(every Duration::from_millis(1000)) => advance_sparkline, paint_listening;
// Split from the transition below because hsmc rejects
// payload bindings on transition-bearing handlers.
on(PacketRx { rssi: i16, snr: Option<i16> }) => record_rx_packet, blink_rx_led;
on(PacketRx) => ListeningBright;
on(PacketTx) => record_tx_packet, blink_tx_led;
on(PacketTx) => ListeningBright;
state ListeningBright {
entry: set_bright;
on(after Duration::from_secs(3)) => set_dim, Listening;
}
}
state Transmitting {
entry: paint_transmitting;
default(TransmittingBright);
on(EnteredRx) => Listening;
on(every Duration::from_millis(1000)) => advance_sparkline, paint_transmitting;
on(PacketRx { rssi: i16, snr: Option<i16> }) => record_rx_packet, blink_rx_led;
on(PacketRx) => TransmittingBright;
on(PacketTx) => record_tx_packet, blink_tx_led;
on(PacketTx) => TransmittingBright;
state TransmittingBright {
entry: set_bright;
on(after Duration::from_secs(3)) => set_dim, Transmitting;
}
}
}
}
@@ -355,6 +406,14 @@ impl DisplayActions for DisplayActionContext<'_> {
async fn advance_sparkline(&mut self) {
self.run.advance_slot();
}
async fn set_bright(&mut self) {
self.oled_bright().await;
}
async fn set_dim(&mut self) {
self.oled_dim().await;
}
}
// ── Task entry point ───────────────────────────────────────────────
+121
View File
@@ -0,0 +1,121 @@
//! AXP PMIC init — turn on the rails that feed LoRa and the OLED.
//!
//! T-Beam–class boards gate LoRa, OLED (and GPS/sensors, which this firmware
//! does not use) through an X-Powers PMIC on I²C. Until the PMIC is told to
//! enable the right LDOs/DCDCs, the SX126x/SX127x chip sits unpowered and
//! `LoRa::new` fails. This module's only job is to flip those switches.
//!
//! Two PMICs are covered:
//!
//! * [`axp2101_init_lora_oled`] — LilyGo T-Beam S3 Supreme. ALDO3 = 3.3 V
//! feeds the SX1262; ALDO1 = 3.3 V feeds the SH1106 OLED. Both live on a
//! dedicated I²C1 bus (separate from the display).
//! * [`axp192_init_lora_oled`] — LilyGo T-Beam (classic). LDO2 = 3.3 V feeds
//! the SX1276; DCDC1 = 3.3 V feeds the SSD1306 OLED. PMIC shares the
//! display I²C bus.
//!
//! Everything unrelated to LoRa + OLED (GPS, sensors, SD, batt ADC) is left
//! alone. Out-of-scope for a transparent LoRa-over-USB bridge.
//!
//! Init is blocking on purpose. It runs once during `into_parts`, which is a
//! synchronous function called before task spawning. Using the blocking
//! `embedded_hal` trait keeps the PMIC wiring out of the async machinery and
//! lets the caller drop the I²C bus immediately after init (no bus handoff).
use embedded_hal::i2c::I2c;
/// Both chips respond at this 7-bit I²C address.
const PMIC_ADDR: u8 = 0x34;
// ── AXP2101 (T-Beam S3 Supreme) ──────────────────────────────────────
#[cfg(feature = "lilygo_tbeam_supreme")]
mod axp2101 {
use super::{I2c, PMIC_ADDR};
/// LDO on/off control register. Bits:
/// 0 = ALDO1, 1 = ALDO2, 2 = ALDO3, 3 = ALDO4, 4 = BLDO1, 5 = BLDO2.
const REG_LDO_ONOFF: u8 = 0x90;
/// ALDO1 voltage register (OLED rail on T-Beam Supreme).
const REG_ALDO1_V: u8 = 0x92;
/// ALDO3 voltage register (LoRa rail on T-Beam Supreme).
const REG_ALDO3_V: u8 = 0x94;
/// Voltage code for 3.3 V on ALDOx: 0.5 V + 28 × 100 mV.
const V_3V3: u8 = 28;
/// Mask enabling ALDO1 + ALDO3 in [`REG_LDO_ONOFF`].
const ALDO1_ALDO3: u8 = 0b0000_0101;
/// Bring up LoRa (ALDO3) and OLED (ALDO1) rails at 3.3 V.
///
/// Voltage registers are set before the enable bits to avoid glitching
/// the rails through the reset-default voltage. Other rails are left
/// untouched (read-modify-write on the enable register) so any
/// board-specific OTP defaults stay intact.
pub fn init_lora_oled<I: I2c>(i2c: &mut I) -> Result<(), I::Error> {
i2c.write(PMIC_ADDR, &[REG_ALDO3_V, V_3V3])?;
i2c.write(PMIC_ADDR, &[REG_ALDO1_V, V_3V3])?;
let mut onoff = [0u8; 1];
i2c.write_read(PMIC_ADDR, &[REG_LDO_ONOFF], &mut onoff)?;
i2c.write(PMIC_ADDR, &[REG_LDO_ONOFF, onoff[0] | ALDO1_ALDO3])?;
Ok(())
}
}
#[cfg(feature = "lilygo_tbeam_supreme")]
pub use axp2101::init_lora_oled as axp2101_init_lora_oled;
// ── AXP192 (T-Beam classic) ──────────────────────────────────────────
#[cfg(feature = "lilygo_tbeam")]
mod axp192 {
use super::{I2c, PMIC_ADDR};
/// DCDC/LDO enable register. Bit layout:
/// 0 = DCDC1, 1 = DCDC3, 2 = LDO2, 3 = LDO3, 4 = DCDC2, 6 = EXTEN.
const REG_ONOFF: u8 = 0x12;
/// DCDC1 output voltage register (OLED rail on T-Beam classic).
/// 7-bit code, 25 mV step, 0.7 V offset → 3.3 V = 104 = `0x68`.
const REG_DCDC1_V: u8 = 0x26;
/// LDO2/LDO3 voltage register. Upper nibble = LDO2 (LoRa), lower nibble
/// = LDO3 (GPS). 100 mV step, 1.8 V offset → 3.3 V = 15 = `0xF`.
const REG_LDO23_V: u8 = 0x28;
/// DCDC1 code for 3.3 V.
const DCDC1_3V3: u8 = 0x68;
/// LDO2 nibble for 3.3 V in the upper half of [`REG_LDO23_V`].
const LDO2_3V3_UPPER: u8 = 0xF0;
/// Mask enabling DCDC1 + LDO2 in [`REG_ONOFF`].
const DCDC1_LDO2: u8 = 0b0000_0101;
/// Bring up LoRa (LDO2) and OLED (DCDC1) rails at 3.3 V on the
/// classic T-Beam's AXP192.
///
/// GPS (LDO3) and EXTEN are not touched — this firmware has no GPS,
/// and any board-default for LDO3 voltage is preserved by
/// read-modify-write. Voltage is programmed before the enable bit
/// flips so the rail doesn't glitch through its reset default.
pub fn init_lora_oled<I: I2c>(i2c: &mut I) -> Result<(), I::Error> {
let mut ldo23 = [0u8; 1];
i2c.write_read(PMIC_ADDR, &[REG_LDO23_V], &mut ldo23)?;
i2c.write(
PMIC_ADDR,
&[REG_LDO23_V, (ldo23[0] & 0x0F) | LDO2_3V3_UPPER],
)?;
i2c.write(PMIC_ADDR, &[REG_DCDC1_V, DCDC1_3V3])?;
let mut onoff = [0u8; 1];
i2c.write_read(PMIC_ADDR, &[REG_ONOFF], &mut onoff)?;
i2c.write(PMIC_ADDR, &[REG_ONOFF, onoff[0] | DCDC1_LDO2])?;
Ok(())
}
}
#[cfg(feature = "lilygo_tbeam")]
pub use axp192::init_lora_oled as axp192_init_lora_oled;
+30
View File
@@ -0,0 +1,30 @@
//! Generic `OutputPin` wrapper that inverts logic levels.
//!
//! When a peripheral is wired active-low (LED anode to V+, cathode to GPIO;
//! reset line idle-high, etc.) the physical polarity is a property of the
//! board, not of the driver. Wrapping the pin in `InvertedPin` lets drivers
//! keep "set_high = assert" semantics while the board file expresses the
//! wiring reality at construction time.
//!
//! ```ignore
//! let pin = Output::new(p.GPIO4, Level::High, OutputConfig::default()); // off
//! let led = SimpleLed(InvertedPin(pin)); // driver sees normal polarity
//! ```
use embedded_hal::digital::{ErrorType, OutputPin};
pub struct InvertedPin<P>(pub P);
impl<P: ErrorType> ErrorType for InvertedPin<P> {
type Error = P::Error;
}
impl<P: OutputPin> OutputPin for InvertedPin<P> {
fn set_low(&mut self) -> Result<(), Self::Error> {
self.0.set_high()
}
fn set_high(&mut self) -> Result<(), Self::Error> {
self.0.set_low()
}
}
+70 -1
View File
@@ -1,12 +1,81 @@
#[cfg(any(feature = "wio_tracker_l1", feature = "elecrow_thinknode_m2"))]
#[cfg(any(
feature = "wio_tracker_l1",
feature = "elecrow_thinknode_m2",
feature = "lilygo_tbeam_supreme"
))]
pub mod sh1106;
#[cfg(any(feature = "lilygo_tbeam_supreme", feature = "lilygo_tbeam"))]
pub mod axp;
#[cfg(feature = "lilygo_tbeam")]
pub mod inverted_pin;
#[cfg(any(
feature = "heltec_v3",
feature = "heltec_v3_uart",
feature = "heltec_v4",
feature = "elecrow_thinknode_m2",
feature = "lilygo_tbeam_supreme",
feature = "lilygo_tbeam",
feature = "wio_tracker_l1",
feature = "waveshare_rp2040_lora"
))]
pub mod simple_led;
// ── Display brightness ────────────────────────────────────────────────
//
// The display statechart dims the OLED a few seconds after the last
// activity. Our two driver families (`ssd1306` crate and our in-tree
// `sh1106`) expose incompatible brightness APIs, so we wrap them in a
// single async trait that the state-machine actions can call uniformly.
/// Two-level backlight control used by the display dashboard.
pub trait DisplayBrightness {
fn set_bright(&mut self) -> impl core::future::Future<Output = ()>;
fn set_dim(&mut self) -> impl core::future::Future<Output = ()>;
}
// Contrast values for the two brightness levels, picked to be common across
// both driver families. `0xFF` is the SSD1306/SH1106 maximum; `0x08` is ~3%
// of max — visible in a dim room, barely noticeable in daylight. Tune here.
const CONTRAST_BRIGHT: u8 = 0xFF;
const CONTRAST_DIM: u8 = 0x08;
impl<DI, SIZE, MODE> DisplayBrightness for ssd1306::Ssd1306Async<DI, SIZE, MODE>
where
DI: display_interface::AsyncWriteOnlyDataCommand,
SIZE: ssd1306::size::DisplaySizeAsync,
{
async fn set_bright(&mut self) {
// `Brightness::custom(precharge, contrast)`. Matches the shape of
// the crate's BRIGHTEST preset (precharge 0x2) at max contrast.
let _ = self
.set_brightness(ssd1306::prelude::Brightness::custom(0x2, CONTRAST_BRIGHT))
.await;
}
async fn set_dim(&mut self) {
// Low precharge pairs with low contrast — same combination the
// crate's DIMMEST preset uses.
let _ = self
.set_brightness(ssd1306::prelude::Brightness::custom(0x1, CONTRAST_DIM))
.await;
}
}
#[cfg(any(
feature = "wio_tracker_l1",
feature = "elecrow_thinknode_m2",
feature = "lilygo_tbeam_supreme"
))]
impl<I> DisplayBrightness for sh1106::Sh1106<I>
where
I: embedded_hal_async::i2c::I2c,
{
async fn set_bright(&mut self) {
let _ = self.set_brightness(CONTRAST_BRIGHT).await;
}
async fn set_dim(&mut self) {
let _ = self.set_brightness(CONTRAST_DIM).await;
}
}
+80
View File
@@ -0,0 +1,80 @@
//! ESP32 (classic / non-S3) MCU initialization primitives.
//!
//! Mirror of `hal::esp32s3` with a single delta: the classic ESP32 uses a
//! peripheral-bound DMA (`DMA_SPI2`) rather than the S3's channel-addressed
//! GDMA (`DMA_CH0`). Timer, I²C, and eFuse access are otherwise identical
//! between the two Xtensa parts in this esp-hal vintage.
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use esp_hal::dma::{DmaRxBuf, DmaTxBuf};
use esp_hal::gpio::interconnect::{PeripheralInput, PeripheralOutput};
use esp_hal::i2c::master::I2c;
use esp_hal::spi::master::{Config as SpiConfig, Spi, SpiDmaBus};
use esp_hal::spi::Mode as SpiMode;
use esp_hal::time::Rate;
use esp_hal::timer::timg::TimerGroup;
use static_cell::StaticCell;
// ── MCU-level types ─────────────────────────────────────────────────
pub type SpiBus = SpiDmaBus<'static, esp_hal::Async>;
pub type I2cBus = I2c<'static, esp_hal::Async>;
// ── Timer ───────────────────────────────────────────────────────────
/// Start the ESP-RTOS scheduler and Embassy time driver.
pub fn start_timer(
timg0: esp_hal::peripherals::TIMG0<'static>,
sw_int: esp_hal::peripherals::SW_INTERRUPT<'static>,
) {
let timg0 = TimerGroup::new(timg0);
let sw_ints = esp_hal::interrupt::software::SoftwareInterruptControl::new(sw_int);
esp_rtos::start(timg0.timer0, sw_ints.software_interrupt0);
}
// ── SPI bus ─────────────────────────────────────────────────────────
/// Initialize SPI2 with peripheral-bound DMA and wrap in a shared bus
/// (`StaticCell` + `Mutex`).
///
/// Generic over pin type. The classic ESP32's matrix of GPIO → peripheral
/// routes lets any GPIO serve as any SPI signal — same as the S3.
pub fn init_spi(
spi2: esp_hal::peripherals::SPI2<'static>,
dma_spi2: esp_hal::peripherals::DMA_SPI2<'static>,
sck: impl PeripheralOutput<'static>,
mosi: impl PeripheralOutput<'static>,
miso: impl PeripheralInput<'static>,
) -> &'static embassy_sync::mutex::Mutex<NoopRawMutex, SpiBus> {
let spi = Spi::new(
spi2,
SpiConfig::default()
.with_frequency(Rate::from_mhz(1))
.with_mode(SpiMode::_0),
)
.expect("SPI init")
.with_sck(sck)
.with_mosi(mosi)
.with_miso(miso)
.with_dma(dma_spi2);
let (rx_buf, rx_desc, tx_buf, tx_desc) = esp_hal::dma_buffers!(256);
let dma_rx = DmaRxBuf::new(rx_desc, rx_buf).expect("DMA RX buf");
let dma_tx = DmaTxBuf::new(tx_desc, tx_buf).expect("DMA TX buf");
let spi = spi.with_buffers(dma_rx, dma_tx).into_async();
static SPI_BUS: StaticCell<embassy_sync::mutex::Mutex<NoopRawMutex, SpiBus>> =
StaticCell::new();
SPI_BUS.init(embassy_sync::mutex::Mutex::new(spi))
}
// ── MAC address ─────────────────────────────────────────────────────
/// Read the factory-programmed MAC address from eFuse.
pub fn mac_address() -> [u8; 6] {
esp_hal::efuse::base_mac_address()
.as_bytes()
.try_into()
.expect("MAC is 6 bytes")
}
+5 -1
View File
@@ -7,10 +7,14 @@
feature = "heltec_v3",
feature = "heltec_v3_uart",
feature = "heltec_v4",
feature = "elecrow_thinknode_m2"
feature = "elecrow_thinknode_m2",
feature = "lilygo_tbeam_supreme"
))]
pub mod esp32s3;
#[cfg(feature = "lilygo_tbeam")]
pub mod esp32;
#[cfg(any(feature = "rak_wisblock_4631", feature = "wio_tracker_l1"))]
pub mod nrf52840;
+5 -1
View File
@@ -6,7 +6,11 @@
pub mod framing;
cfg_if::cfg_if! {
if #[cfg(any(feature = "heltec_v3_uart", feature = "elecrow_thinknode_m2"))] {
if #[cfg(any(
feature = "heltec_v3_uart",
feature = "elecrow_thinknode_m2",
feature = "lilygo_tbeam"
))] {
mod uart;
pub use uart::host_task;
} else {
+6 -8
View File
@@ -48,7 +48,7 @@ cfg_if::cfg_if! {
if #[cfg(any(feature = "rak_wisblock_4631", feature = "wio_tracker_l1", feature = "waveshare_rp2040_lora"))] {
use defmt_rtt as _;
use panic_probe as _;
} else if #[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart", feature = "heltec_v4", feature = "elecrow_thinknode_m2"))] {
} else if #[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart", feature = "heltec_v4", feature = "elecrow_thinknode_m2", feature = "lilygo_tbeam_supreme", feature = "lilygo_tbeam"))] {
use esp_backtrace as _;
use esp_println as _;
}
@@ -72,7 +72,7 @@ cfg_if::cfg_if! {
async fn main(spawner: Spawner) {
run(spawner).await;
}
} else if #[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart", feature = "heltec_v4", feature = "elecrow_thinknode_m2"))] {
} else if #[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart", feature = "heltec_v4", feature = "elecrow_thinknode_m2", feature = "lilygo_tbeam_supreme", feature = "lilygo_tbeam"))] {
#[esp_rtos::main]
async fn main(spawner: Spawner) {
run(spawner).await;
@@ -140,6 +140,8 @@ fn build_info(mac: [u8; 6]) -> Info {
let (fmin, fmax) = <board::Board as LoRaBoard>::freq_range_hz();
let chip_id = <board::Board as LoRaBoard>::radio_chip_id();
let (tx_min, tx_max) = board::Board::TX_POWER_RANGE;
let supported_sf = <board::Board as LoRaBoard>::supported_sf_bitmap();
let supported_bw = <board::Board as LoRaBoard>::supported_bw_bitmap();
let mut mcu_uid = [0u8; MAX_MCU_UID_LEN];
mcu_uid[..6].copy_from_slice(&mac);
@@ -152,12 +154,8 @@ fn build_info(mac: [u8; 6]) -> Info {
fw_patch: parse_u8_or(env!("CARGO_PKG_VERSION_PATCH"), 0),
radio_chip_id: chip_id,
capability_bitmap: cap::LORA | cap::CAD_BEFORE_TX,
// SX126x supports SF5–SF12 (LLCC68 tops out at SF11 — that board
// can override this via a board-level trait method later).
supported_sf_bitmap: 0x1FE0,
// Sub-GHz BW enum values 0..9. SX128x would flip 10..13; add as
// boards come online.
supported_bw_bitmap: 0x03FF,
supported_sf_bitmap: supported_sf,
supported_bw_bitmap: supported_bw,
max_payload_bytes: crate::protocol::MAX_OTA_PAYLOAD as u16,
// Real channel depths from channel.rs.
rx_queue_capacity: 32,
+66 -8
View File
@@ -102,8 +102,26 @@ pub enum RadioInput {
},
ChannelBusy,
TransmitFailed,
/// Internal: emitted by `bump_resume_retries` when another
/// `try_start_rx_hw` attempt is allowed. Drives a self-transition on
/// `ResumingRx` so the entry action runs again after a short backoff.
ResumeRxRetry,
/// Internal: emitted by `bump_resume_retries` after
/// `MAX_RESUME_RETRIES` attempts have failed — the chip is genuinely
/// wedged; fall through to `Idle` so the host can reconfigure.
ResumeRxExhausted,
}
/// How many back-to-back `try_start_rx_hw` failures to tolerate in
/// `ResumingRx` before giving up and parking in `Idle`. 5 × 25 ms ≈
/// 125 ms worst-case resume window, enough to ride out SX1262
/// post-TX timing flukes without pegging the CPU on a dead chip.
const MAX_RESUME_RETRIES: u8 = 5;
/// Backoff between `ResumingRx` retry attempts.
const RESUME_RX_RETRY_BACKOFF_MS: u64 = 25;
// ── Context ─────────────────────────────────────────────────────────
pub struct RadioContext {
@@ -130,6 +148,10 @@ pub struct RadioContext {
/// Tag of a pending `RX_START`, pulled by `respond_ok_start_rx` /
/// `respond_err_start_rx` once the chip reports back.
pub pending_rx_start_tag: Option<u16>,
/// Number of consecutive `try_start_rx_hw` failures while in
/// `ResumingRx`. Reset on any `StartRxOk`. See `MAX_RESUME_RETRIES`
/// for the limit before falling through to `Idle`.
pub resume_retries: u8,
}
impl RadioContext {
@@ -199,7 +221,12 @@ statechart! {
during: next_packet(lora, rx_buf, config);
on(CmdRxStart) => respond_ok;
on(PacketReceived(rx: RxPayload)) => record_packet;
on(RxFailed) => announce_rx_failed, Idle;
// Transient driver error during `next_packet` — re-arm
// the chip via ResumingRx rather than parking in Idle
// (which would bounce the OLED and leave the radio
// waiting for a client-initiated RX_START that will
// never come because clients already think RX is up).
on(RxFailed) => ResumingRx;
on(CmdRxStop) => stop_rx_hw, respond_ok;
on(CmdRxStop) => Idle;
on(CmdTx) => TransmittingFromRx;
@@ -212,10 +239,18 @@ statechart! {
on(ConfigApplied) => ResumingRx;
}
// Bounded-retry RX re-arm. Entered after every TX while
// already receiving, on RX driver errors, and on mid-session
// SET_CONFIG. If `try_start_rx_hw` succeeds we land cleanly
// in Receiving; if it fails we back off and retry, only
// conceding to Idle after MAX_RESUME_RETRIES attempts (chip
// is genuinely wedged at that point).
state ResumingRx {
entry: try_start_rx_hw;
on(StartRxOk) => Receiving;
on(StartRxFailed) => Idle;
on(StartRxOk) => reset_resume_retries, Receiving;
on(StartRxFailed) => bump_resume_retries;
on(ResumeRxRetry) => ResumingRx;
on(ResumeRxExhausted) => Idle;
}
state Transmitting {
@@ -235,8 +270,12 @@ statechart! {
during: perform_tx(lora, pending_tx);
on(TransmitDone { airtime_us: u32 }) => respond_tx_done;
on(TransmitDone) => ResumingRx;
// Even on failure, we were receiving before the TX —
// return to RX (the client still gets a TX_FAILED
// reply via respond_tx_failed). Dropping to Idle here
// would break the "RX session stays up" invariant.
on(ChannelBusy) => respond_tx_channel_busy, ResumingRx;
on(TransmitFailed) => respond_tx_failed, Idle;
on(TransmitFailed) => respond_tx_failed, ResumingRx;
}
}
}
@@ -465,6 +504,28 @@ impl RadioActions for RadioActionContext<'_> {
}
}
async fn reset_resume_retries(&mut self) {
self.resume_retries = 0;
}
async fn bump_resume_retries(&mut self) {
self.resume_retries = self.resume_retries.saturating_add(1);
if self.resume_retries >= MAX_RESUME_RETRIES {
warn!(
"ResumingRx: {} failed attempts, giving up to Idle",
self.resume_retries
);
self.resume_retries = 0;
let _ = self.emit(RadioInput::ResumeRxExhausted);
return;
}
// Short backoff before the next `try_start_rx_hw` cycle. The
// self-transition on ResumingRx (driven by ResumeRxRetry) will
// re-run the entry action.
embassy_time::Timer::after_millis(RESUME_RX_RETRY_BACKOFF_MS).await;
let _ = self.emit(RadioInput::ResumeRxRetry);
}
async fn respond_ok(&mut self) {
let tag = self.incoming_tag;
self.send(tag, DeviceMessage::Ok(OkPayload::Empty)).await;
@@ -530,10 +591,6 @@ impl RadioActions for RadioActionContext<'_> {
self.announce(RadioEvent::PacketTx);
}
async fn announce_rx_failed(&mut self) {
self.announce(RadioEvent::Idle);
}
// ── Packet bookkeeping ────────────────────────────────────────────
async fn record_packet(&mut self, rx: RxPayload) {
@@ -748,6 +805,7 @@ pub async fn radio_task(
incoming_tag: 0,
last_tx_tag: None,
pending_rx_start_tag: None,
resume_retries: 0,
};
static RADIO_INTERNAL_CH: embassy_sync::channel::Channel<