Commit graph

43 commits

Author SHA1 Message Date
GlassOnTin
c6e2a282ab Fix LoRa RX: remove DC-DC regulator, restore demod reset after false preamble
Root cause: SetRegulatorMode(DC-DC+LDO) in begin() kills LoRa RX on
boards without the DC-DC inductor (T-Beam Supreme, T-Watch Ultra).
TX still works, preamble/RSSI detection works, but RX_DONE never
fires — mimics hardware failure.

Three regressions from 033ddd6 fixed:
- Remove SetRegulatorMode(0x01) from begin() — these boards use
  LDO-only, which is the SX1262 default after reset
- Restore receive() call in dcd() after false preamble timeout —
  upstream fix (3ae8982) we had removed; just clearing IRQ flags
  is insufficient to reset the demodulator chain
- Add lora_receive() after beacon_transmit() — radio was left in
  STDBY after TX, never returning to RX mode

Also reverts getPacketType check in receive(), TCXO-before-calibration,
clear-device-errors, and TX fallback mode changes that were not needed
and caused intermittent RX failures during testing.

Verified: bidirectional LoRa RX between watch and T-Beam Supreme
with IFAC authentication at 868 MHz SF7 BW125K.
2026-03-29 21:05:59 +01:00
GlassOnTin
926330253a Fix 950ms main loop bottleneck: beacon and radio init on every iteration
Root cause found via loop profiling: two functions called every loop
iteration on unprovisioned devices consumed 950ms:

1. beacon_update() called startRadio() every loop when GPS had fix
   but device wasn't provisioned (hw_ready=false). startRadio() does
   full radio init with SPI commands and delays (~600ms). Fix: gate
   beacon_update() on hw_ready.

2. stopRadio() called LoRa->end() (SPI sleep + SPI.end()) every loop
   in the !hw_ready path (~99ms). Fix: only call when radio_online
   is true (stop once, not repeatedly).

Result: loop time 950ms → 0.3ms (3200x improvement).

Also added:
- Main loop profiling (radio/serial/display/pmu/gps/bt/imu timing)
- Build timestamp in metrics command for version verification
- Visible-tile-only label updates (GPS float formatting skipped
  when GPS screen not shown)
- Reverted to hwcdc USB mode (TinyUSB adds ~900ms/loop overhead)
- USB MSC SD card code preserved but inactive (needs TinyUSB)
2026-03-29 10:52:50 +01:00
GlassOnTin
5e19294dea Add shared SPI bus mutex for LoRa + SD card coexistence
SharedSPI.h: FreeRTOS mutex protecting the shared SPI bus (pins
33/34/35) used by LoRa (SX1262), SD card, and future NFC.

sx126x.cpp: All 6 SPI transaction blocks wrapped with
shared_spi_mutex acquire/release. LoRa uses portMAX_DELAY
(always gets access, just delayed by SD if needed).

USBSD.h: USB MSC SD card access uses shared_spi_mutex with
200ms timeout. Deferred init (3s after boot) for SPI bus
readiness. Metrics: sd_ready, sd_reads, sd_fails counters.

IMULogger.h, Gui.h: SD card writes wrapped in shared_spi_mutex.

Status: SD card correctly reports 29.7GB via USB MSC. Reads
work intermittently (~50% success). Root cause: main loop
takes ~700ms per iteration, causing mutex timeout for MSC
callbacks. Needs loop time investigation to achieve reliable
USB mass storage.

The CO5300 display uses a separate SPI3 bus — not affected.
2026-03-28 20:59:52 +00:00
GlassOnTin
09d1f6409f Add R-Watch (T-Watch Ultra) board support with LoRa, GPS, PMU, RTC, and deep sleep
Board definition (BOARD_TWATCH_ULT = 0x45) for LilyGo T-Watch Ultra
with verified pin mapping from LilyGoLib hardware docs.

Working subsystems:
- SX1262 LoRa radio: online at 868 MHz, tested with rnsd/Reticulum
- AXP2101 PMU: all power rails configured, battery monitoring, charging
- MIA-M10Q GPS: UART at 38400 baud, TinyGPSPlus NMEA parsing
- PCF85063A RTC: time read/write, GPS sync infrastructure
- XL9555 GPIO expander: I2C driver, LoRa antenna switch
- BLE: initialized, KISS protocol responsive
- Deep sleep: button wake (PMU IRQ GPIO 7), timer wake for beacon
- Beacon sleep cycle: periodic wake for GPS beacon TX in standalone mode

New files:
- VISION.md: R-Watch product vision document
- XL9555.h: minimal I2C GPIO expander driver
- CO5300.h: QSPI AMOLED display driver (not yet functional)

Display driver (CO5300.h) is written but disabled (HAS_DISPLAY=false).
QSPI init succeeds but pixel writes don't reach the display controller.
Suspected XL9555/BHI260AP GPIO expander pin mapping issue under investigation.
2026-03-27 12:18:46 +00:00
GlassOnTin
033ddd6757 Add GPS beacon and LXMF telemetry for T-Beam Supreme and Heltec V4
Standalone GPS beacon mode: when no KISS host is connected for 15s,
the RNode transmits position and battery telemetry over LoRa.

Two beacon paths:
- LXMF (recommended): encrypted per-packet messages with announces,
  compatible with Sideband and any LXMF application. Supports IFAC
  network authentication.
- Legacy JSON: plaintext or encrypted raw packets for simple collectors.

Key changes:
- GPS support for T-Beam Supreme S3 (L76K) and Heltec V4 (external)
- SX1262 radio fixes: IQ polarity, DCD preamble lockup, RX reliability
- LXMF identity management with NVS-backed Ed25519/X25519 keys
- IFAC authentication (CMD_IFAC_KEY 0x89) for private networks
- Per-channel serial isolation (USB, BLE, WiFi)
- GPS status page in OLED display rotation
- Provisioning via rnlog: provision-lxmf, provision-ifac
- Documentation in Documentation/BEACON.md
2026-03-12 17:01:29 +00:00
Mark Qvist
7b0658b197 Handle GC1109 LNA gain variance properly 2025-11-22 00:04:56 +01:00
Mark Qvist
e2c1cd3766 Added support for LoRa PAs and output power mapping according to PA gain curve 2025-11-07 19:11:56 +01:00
Mark Qvist
2947df3349 Added Heltec v4 board defines and scaffold 2025-11-01 15:33:24 +01:00
Mark Qvist
7d868b4db6 Support for XIAO ESP32S3 2025-04-13 00:11:21 +02:00
Kevin Brosius
cbedd72993 Seeed ESP32S3 - enable button sleep, stopRadio at sleep
to sleep sx1262 also.
2025-02-23 18:52:17 -05:00
Kevin Brosius
bc97e513e8 Initial support for Seeed ESP32S3 with Wio-SX1262
Work in progress
Status: Boots, display works on Xiao espansion base,
radio is recognized
Todo:
  PMU
  Firmware hash fails even if generated and then written
  Radio testing
  Buttons / LEDs
  other?
2025-02-23 06:52:27 -05:00
Mark Qvist
919bddb703 Cleanup 2025-01-17 10:44:46 +01:00
Mark Qvist
458e40ce9a SX1262 register hang debug 2025-01-17 10:44:16 +01:00
Mark Qvist
3ae8982e93 False preamble detection on SX1262 2025-01-16 23:33:49 +01:00
Mark Qvist
48bce4ea15 Actually, use SPIM3 for SX1262 on T-Echo 2025-01-16 12:19:38 +01:00
Mark Qvist
733a792d72 Don't use SPIM3 for LoRa on T-Echo 2025-01-15 21:11:19 +01:00
Mark Qvist
2d2d90847a Initial T-Echo support 2025-01-15 18:38:14 +01:00
Mark Qvist
2119d381b3 Refactored T3S3 board name variable 2025-01-15 10:21:15 +01:00
Mark Qvist
254225e917 Cleanup 2025-01-08 16:50:29 +01:00
Mark Qvist
08651f92f7 Reworked SX1262 LoRa carrier detection 2025-01-07 15:14:44 +01:00
Mark Qvist
c39164e272 Accurate preamble and airtime calculations on SX1280. Fix airtime calculation on SX1262 when LDRO is enabled. 2025-01-05 22:55:32 +01:00
Mark Qvist
eb168d4734 Cleanup 2025-01-04 21:05:11 +01:00
Mark Qvist
421f2d5db3 Cleanup 2025-01-03 19:16:37 +01:00
liamcottle
f9234733e2 add support for heltec t114 2025-01-02 15:14:18 +13:00
Mark Qvist
d88f231332 Added ability to specify per-board transceiver OCP limit 2024-12-10 15:35:29 +01:00
Mark Qvist
76eaae8554 Cleanup 2024-10-11 16:39:38 +02:00
Mark Qvist
389745ad33 Attach packet RSSI and SNR to packet queue entry structs. Disable ISR spinlocks on ESP32 until tested. 2024-10-11 16:29:17 +02:00
Mark Qvist
d61d14e117 Detect modem communication timeouts for sx126x chips 2024-10-07 20:43:16 +02:00
Mark Qvist
6974a50d10 Added T-Beam Supreme support 2024-10-05 00:42:19 +02:00
Mark Qvist
8bdd85e648 Added T-Deck support 2024-10-03 00:38:49 +02:00
Mark Qvist
d742166a12 Cleanup 2024-09-29 21:59:24 +02:00
jacob.eva
94828d825b
Add firmware hash calculation to RAK4631 + more 2024-05-13 22:25:24 +01:00
Kevin Brosius
56a51fdafe Update to add product and model codes for Heltec V3, swap to
HELTEC32_V3 name for board ID.  Bluetooth still disabled.
2024-04-11 01:38:06 -04:00
Kevin Brosius
dc97de363b Need sx1262 SPI and tcxo setup for Lora32 V3 to work. 2024-03-13 19:18:27 -04:00
Mark Qvist
c31cba0fd8 SX126x board defines 2024-02-13 17:26:25 +01:00
Mark Qvist
cec979997e Added register values and op-codes. Cleanup. 2024-02-13 14:19:14 +01:00
Mark Qvist
184d228991 Fix low data-rate optimisation on SX1262 2024-02-13 13:14:13 +01:00
Mark Qvist
32424b91a6 Cleanup 2024-02-13 12:56:14 +01:00
Mark Qvist
bbc267ac80 SX1262 calibration in RC mode 2024-02-11 20:02:17 +01:00
Mark Qvist
6f62a5394b Reworked board defines, fixed RSSI and waterfall bugs for SX1262. 2024-02-11 18:27:47 +01:00
Mark Qvist
d9a982b876 ESP32 adjustments 2024-02-10 17:13:52 +01:00
jacob.eva
a1793043b2
Remove old debug code and add waitOnBusy timeout to SX1262 2024-02-10 11:56:58 +00:00
jacob.eva
78a02c5ae4
Add SX1280 driver and split driver in three parts 2024-02-09 20:56:26 +00:00