Commit Graph

713 Commits

Author SHA1 Message Date
TJ Downes fdbc85c926 fix: serialise radio TX and close duty-cycle TOCTOU race
Add self._tx_lock (asyncio.Lock) to RepeaterHandler and acquire it inside
delayed_send after the per-packet sleep completes.

Problem 1 — radio interleave: concurrent delayed_send coroutines (one per
queued packet) could both exit their sleep at nearly the same moment and call
dispatcher.send_packet simultaneously, interleaving SPI/serial register writes
to the half-duplex LoRa radio.

Problem 2 — TOCTOU gap: the upfront can_transmit() check in __call__ and the
record_tx() call in delayed_send are separated by the entire TX delay (up to
several seconds).  Under burst conditions two tasks both pass the check before
either has recorded its airtime, causing both to transmit and the duty-cycle
budget to be exceeded.

Fix: acquire _tx_lock after the sleep so delay timers still run concurrently
(matching firmware behaviour), then immediately re-check can_transmit() inside
the lock before sending.  Because only one task holds the lock at a time,
airtime state is stable; check and record_tx() are effectively atomic — no
TOCTOU window.  Airtime is recorded only on a successful send, so a radio
failure never inflates the budget.

Also move `import random` from inside _calculate_tx_delay to module level
(stdlib imports belong at the top; the lazy-import pattern is unnecessary here).

Docs: docs/pr_tx_serialization.md — problem statement, root-cause analysis,
alternative approaches considered, invariant table, full unit + field test plan,
and proof of correctness for the asyncio.Lock approach.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 18:37:56 -07:00
Lloyd c82f0cfce6 feat:add ui websockets teardown. 2026-04-21 14:47:18 +01:00
Lloyd be56e919fd feat: add server-side airtime bucket aggregation for optimized chart rendering 2026-04-21 14:46:30 +01:00
Lloyd 81a3b70415 feat: implement graceful shutdown handling and version cache optimizations 2026-04-21 12:07:08 +01:00
Lloyd 9797e08421 feat: implement background scheduling for deferred network publishing tasks, tidy shutdown process 2026-04-21 10:07:15 +01:00
Lloyd 3df4b03fd9 feat: implement deferred network publishing for packets, adverts, and noise floor records 2026-04-21 09:49:12 +01:00
Lloyd c5fd41f28a feat: enhance task management in handlers with tracking and error logging 2026-04-21 09:38:03 +01:00
Lloyd 1883bc47be refactor: centralize database connection handling with WAL mode and busy timeout 2026-04-20 16:17:34 +01:00
Lloyd b26ebeb807 fix: optimize memory tracing by reducing overhead and filtering snapshots 2026-04-20 16:04:19 +01:00
Lloyd 68a461b965 feat: add memory debug to gui 2026-04-20 15:41:27 +01:00
Lloyd 5eb1fc47ca feat: add memory_debug endpoint for memory leak diagnostics and improve SSL context handling for GitHub requests 2026-04-20 14:51:48 +01:00
Rigear 096c5a8f07 fix: Do not connect a disabled broker 2026-04-19 22:18:35 -07:00
Rigear 11f749e0e9 fix: Initialize tls_verified and properly handle when mqtt_broker is None 2026-04-19 18:04:36 -07:00
Rightup 799a85ddf9 fix: remove --no-index from R2 pip install so pyyaml resolves from PyPI 2026-04-19 19:34:26 +01:00
Rigear 093ebc2873 feat: Web assets build after rebasing from dev 2026-04-18 20:53:39 -07:00
Rigear 2e1d19ab80 Merge remote-tracking branch 'origin/dev' into feat/mqtt_merge
# Conflicts:
#	config.yaml.example
#	repeater/data_acquisition/__init__.py
#	repeater/data_acquisition/storage_collector.py
#	repeater/web/html/assets/CADCalibration-319vQEzv.js
#	repeater/web/html/assets/CADCalibration-Cwr0Kq49.js
#	repeater/web/html/assets/CADCalibration-DWusgblB.js
#	repeater/web/html/assets/Companions-DU19yZyB.js
#	repeater/web/html/assets/Companions-cufpceKN.js
#	repeater/web/html/assets/Companions-zmTexa6a.js
#	repeater/web/html/assets/Configuration-BmDpq7bV.js
#	repeater/web/html/assets/ConfirmDialog-BafURQpE.js
#	repeater/web/html/assets/ConfirmDialog-C9Yf394V.js
#	repeater/web/html/assets/ConfirmDialog-h2bJ_WKJ.js
#	repeater/web/html/assets/Dashboard-CnQfG826.js
#	repeater/web/html/assets/Login-BDsVY-me.js
#	repeater/web/html/assets/Logs-BpG7T8_d.js
#	repeater/web/html/assets/Logs-CVZ1ZqH8.js
#	repeater/web/html/assets/Logs-sxcWuUjs.js
#	repeater/web/html/assets/MessageDialog-B-qWtO0z.js
#	repeater/web/html/assets/MessageDialog-Cp4W1enq.js
#	repeater/web/html/assets/MessageDialog-D2OlpbZ7.js
#	repeater/web/html/assets/Neighbors-BAwKrJdF.js
#	repeater/web/html/assets/Neighbors-BamkiPcU.js
#	repeater/web/html/assets/Neighbors-WHAK_7hU.js
#	repeater/web/html/assets/RoomServers-DbCgmJ6x.js
#	repeater/web/html/assets/RoomServers-i32N0iwv.js
#	repeater/web/html/assets/RoomServers-o3kDed-S.js
#	repeater/web/html/assets/Sessions-B8ZVRIGt.js
#	repeater/web/html/assets/Sessions-B9uqWGaO.js
#	repeater/web/html/assets/Sessions-O3vBapMM.js
#	repeater/web/html/assets/Setup-DyJMgh0L.js
#	repeater/web/html/assets/Statistics-BbiQtXdu.js
#	repeater/web/html/assets/Statistics-CeTg6NYy.js
#	repeater/web/html/assets/Statistics-QSH8GjMX.js
#	repeater/web/html/assets/SystemStats-B7qxcRYp.js
#	repeater/web/html/assets/SystemStats-BmXJQonl.js
#	repeater/web/html/assets/SystemStats-DVaA1ybj.js
#	repeater/web/html/assets/Terminal-CUqcF84y.js
#	repeater/web/html/assets/Terminal-D1kRkrmc.js
#	repeater/web/html/assets/Terminal-Dq6FyjMj.js
#	repeater/web/html/assets/api-CiSov_eM.js
#	repeater/web/html/assets/api-DegLD39Y.js
#	repeater/web/html/assets/api-DjLVJkR1.js
#	repeater/web/html/assets/index-cutq4vvY.js
#	repeater/web/html/assets/packets-Bg0pkGLO.js
#	repeater/web/html/assets/packets-CPLd89q8.js
#	repeater/web/html/assets/packets-DmoWuBlc.js
#	repeater/web/html/assets/system-Bocs8bSU.js
#	repeater/web/html/assets/system-CsY7_jKa.js
#	repeater/web/html/assets/system-qCwV23PE.js
#	repeater/web/html/assets/useSignalQuality-DQTATYAm.js
#	repeater/web/html/assets/useSignalQuality-DlXA7j0p.js
#	repeater/web/html/assets/useSignalQuality-u0_rDpC6.js
#	repeater/web/html/index.html
2026-04-18 20:25:30 -07:00
Rigear 92f9fe77ae fix: user/pass nor loading from config 2026-04-18 20:15:58 -07:00
Rightup dfe9ba20f3 Fix R2 wheels installation path for improved dependency resolution 2026-04-18 23:15:34 +01:00
Rightup d336c72625 Enhance installation process with R2 wheels support for ARM devices 2026-04-18 23:15:13 +01:00
Lloyd 083ad2bc7a Merge pull request #184 from zindello/feat/luckfoxInstallSupport 2026-04-18 13:00:09 +01:00
Joshua Mesilane a9590fac01 Fix the headless install option 2026-04-18 21:09:01 +10:00
Lloyd 8f2888f2d5 Merge pull request #183 from zindello/feat/luckfoxInstallSupport
Fix for polkit version detection
2026-04-18 09:05:12 +01:00
Joshua Mesilane 7ba26b72cb Fix for polkit version detection 2026-04-18 17:39:35 +10:00
Lloyd 56e5a93699 Merge pull request #182 from zindello/feat/luckfoxInstallSupport 2026-04-18 08:32:30 +01:00
Joshua Mesilane 8ebcb09eff Headless install fix 2026-04-18 17:12:06 +10:00
Joshua Mesilane 62d6627fab Fix readme 2026-04-18 17:09:26 +10:00
Joshua Mesilane 4e3b2bbc9a Updates to support installs on the LuckFox platform 2026-04-18 16:50:44 +10:00
Rigear d6681ab407 feat: Update UI files from fc223397df8e5681e886752b279bc25ed34938b8 hash in Rigear/pyMC-RepeaterUI 2026-04-17 21:12:15 -07:00
Rigear 3f09e910d9 fix(QOL): reordered mqtt yaml config so names are first. 2026-04-17 21:09:23 -07:00
Rigear 79d40afc71 fix: Force TLS when loading in existing Letsmesh configs from yaml 2026-04-17 21:08:43 -07:00
Rightup 9442c51225 feat: update logo in ui 2026-04-17 23:51:43 +01:00
Rightup ffaaa76ea0 feat: add glass to repeater. 2026-04-17 23:51:04 +01:00
Rigear f641761b05 feat: UI updated from https://github.com/Rigear/pyMC-RepeaterUI/commit/4a24b6d2c7699294c9f90ea3f0d05b0456b8b3e2 2026-04-16 14:54:30 -07:00
Rigear 6d133efdbe fix: If we're using websockets, default to tls enabled = true if we're using port 443 2026-04-16 13:23:46 -07:00
Rigear 6b531e85e7 feat: TLS pass 2026-04-15 22:32:22 -07:00
Rigear 4569ff8653 feat: publish crc_records to mqtt 2026-04-15 22:05:54 -07:00
Rigear 06573d2373 Merge remote-tracking branch 'origin/dev' into feat/mqtt_merge 2026-04-15 21:22:10 -07:00
Rigear 01aed0db2b docs: Added retain_status message to example config 2026-04-15 21:22:02 -07:00
Rigear 27fa2381ea feat:
* Added retain status message bool
* Added back old templates
* Added migration path from old mqtt and letsmesh configs to new mqtt_broker config
2026-04-15 21:20:11 -07:00
Lloyd 4d9c560b11 Merge pull request #178 from rightup/feat-remove-sys-packages
feat: migrate to virtual environment and clean up system-level packages
2026-04-15 10:40:58 +01:00
Lloyd f2a72eb203 feat: migrate to virtual environment and clean up system-level packages 2026-04-15 09:37:26 +01:00
Lloyd 4d49eb701b feat: add owner_info field to repeater configuration and add getter for protocol request handling 2026-04-13 16:49:02 +01:00
Rigear f18e5909fb refactor: Clear out dead code 2026-04-11 22:27:01 -07:00
Rigear 3b7de6061b docs: Updated example config 2026-04-11 22:26:40 -07:00
Rigear 64530a623e refactor: Updated letsmesh references 2026-04-11 21:44:26 -07:00
Rigear 7256807fdd feat: Bring back disallowed types 2026-04-11 20:46:42 -07:00
Rigear ba942ca1b7 Merge remote-tracking branch 'origin/dev' into feat/mqtt_merge 2026-04-11 16:09:20 -07:00
Rigear acf8079761 feat: Merge mqtt handler and letsmesh handlers 2026-04-11 16:09:14 -07:00
Lloyd 9d971d03b7 UI fix for air time 2026-04-11 21:14:39 +01:00
Lloyd 110d7c2aec feat: add airtime data retrieval functionality with API endpoint 2026-04-11 20:42:04 +01:00