Commit Graph

93 Commits

Author SHA1 Message Date
Björkan f1e860d17e feat(presets): add Meshat.se broker preset 2026-06-24 07:51:28 +02:00
Lloyd c761c425d1 Merge branch 'pr-294' into dev 2026-06-23 08:56:33 +01:00
Lloyd 018f425dc1 feat: data redaction in log messages and update related tests 2026-06-23 08:52:41 +01:00
Lloyd 4a8876a95e feat: implement login throttling with exponential backoff and enforce minimum admin password length 2026-06-23 08:52:40 +01:00
agessaman cd763e2cac feat: implement threaded stats broadcasting in StorageCollector
- Introduced a dedicated thread for broadcasting aggregate statistics to WebSocket clients, improving performance by offloading heavy queries from the packet write path.
- Updated the _publish_packet_sync method to ensure only fast, per-packet operations are executed, while the stats are handled separately.
- Added methods for broadcasting stats at intervals and managing the lifecycle of the stats thread.
- Enhanced unit tests to validate the new stats broadcasting behavior and ensure correct functionality under various conditions.
2026-06-18 21:38:20 -07:00
Yellowcooln 211fa51cd6 merge: sync PR branch with upstream dev 2026-06-16 11:42:36 -04:00
Yellowcooln b557116fdf fix: move modem CRC baseline into radio wrapper 2026-06-16 11:22:34 -04:00
Yellowcooln 1881ad9b93 feat: derive modem battery percent from voltage 2026-06-15 20:39:22 -04:00
Yellowcooln 1c186d7feb fix: throttle only pyMC modem sensor polling 2026-06-15 18:34:05 -04:00
Yellowcooln f2b7d254a7 fix: slow sensor polling to 60 seconds 2026-06-15 18:32:12 -04:00
Yellowcooln 642c019076 fix: preserve modem GPS satellites in view 2026-06-14 19:32:41 -04:00
agessaman dcaa4ac949 Refactor contact trimming logic for improved readability by consolidating function calls into single lines. Update related test cases for consistency. 2026-06-14 15:50:03 -07:00
Yellowcooln dde487bce3 fix: add generic PyMC modem stats sensor 2026-06-14 18:00:15 -04:00
Yellowcooln 77fc244895 fix: baseline PyMC modem CRC stats 2026-06-14 18:00:15 -04:00
agessaman 23078de78b Enhance contact import logic to respect max_contacts limit and trim excess entries. Update tests to validate trimming behavior and ensure correct handling of favourites during import. 2026-06-13 18:26:35 -07:00
Yellowcooln aeea4bb3f8 Format OpenAPI identity test 2026-06-09 16:10:37 -04:00
Yellowcooln 063c8eeb8c Fix companion identity OpenAPI contract 2026-06-09 15:50:09 -04:00
Lloyd 99a04295da Merge pull request #287 from agessaman/kiss/tuning-options 2026-06-09 19:33:47 +01:00
Lloyd 2b7b2b5b4e feat:add channel sender option to policy 2026-06-09 13:51:18 +01:00
agessaman 183650228e feat(config): add optional KISS CSMA tuning parameters
- Updated `config.yaml.example` to include optional KISS key-up and CSMA tuning parameters.
- Enhanced `get_radio_for_board` function in `config.py` to forward KISS tuning settings to the modem firmware when specified.
- Added tests to verify correct forwarding of KISS parameters and omission of unset values in `test_radio_config.py`.
2026-06-08 21:25:26 -07:00
Lloyd 00682e8086 Merge pull request #282 from agessaman/companion/advanced-settings 2026-06-06 18:09:00 +01:00
agessaman f3146ebc14 fix(companion): clean up ruff errors 2026-06-06 09:44:55 -07:00
agessaman ea6e660f34 refactor(api_endpoints): improve sqlite_handler retrieval logic
- Updated the logic for retrieving the sqlite_handler in APIEndpoints to use a safer approach with getattr, ensuring compatibility with the daemon_instance.
- Adjusted test case to include an additional parameter in the sqlite.companion_push_message assertion for consistency.
2026-06-06 09:39:30 -07:00
agessaman dac60443f0 feat(companion): implement contact trimming and retention policies
- Introduced `enforce_companion_contact_capacity` to manage contact limits during companion loading, with an option to trim non-favourite contacts when exceeding capacity.
- Updated `SQLiteHandler` to support message retention limits, allowing for automatic trimming of older messages based on `offline_queue_size`.
- Enhanced API endpoints to handle contact trimming on overflow, providing feedback on trimmed contacts during updates.
- Added utility functions for selecting and trimming contacts while preserving favourites.
- Improved logging for contact management actions and errors related to capacity.
2026-06-05 21:39:11 -07:00
Lloyd b3119f97f4 Merge branch 'pr-281' into dev 2026-06-05 16:25:15 +01:00
Lloyd da95c67cef fix: improve error logging for invalid policy entries and adjust test configuration 2026-06-05 16:23:18 +01:00
Yellowcooln 767c070384 Update broker host and audience in tests 2026-06-05 11:22:44 -04:00
Yellowcooln 8926b3d593 Fix URL in test_get_preset_meshmapper_is_single_broker_mc2mqtt
Update the URL in the MeshMapper preset test docstring.
2026-06-05 11:06:42 -04:00
Rightup 14b4804c26 feat: Enhance logging system and introduce policy management endpoints
- Updated LogBuffer to support log entry IDs, enhanced log entry structure with additional metadata, and implemented subscriber management for real-time log streaming.
- Added OpenAPI specifications for new endpoints related to policy management, including retrieval, updating, validation, and group management for network policies.
- Implemented comprehensive tests for new policy endpoints, ensuring correct behavior for creating, updating, validating, and deleting policy groups and entries.
- Introduced policy evaluation tests to validate the functionality of the PolicyEngine, including various scenarios for action decisions based on defined rules.
- Enhanced packet routing tests to ensure proper handling of policy decisions in packet processing.
2026-06-04 15:53:17 +01:00
agessaman 499f871262 Merge upstream/dev into companion/advanced-settings
Integrate latest dev while preserving per-companion bridge settings
and contact capacity validation. Resolve import conflicts in main.py
and api_endpoints.py.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 15:34:52 -07:00
Adam Gessaman 7d57b34a04 feat(companion): enhance contact capacity management and bridge settings
- Introduced `CompanionContactCapacityError` to handle cases where persisted contacts exceed configured limits.
- Added utility functions for parsing companion bridge settings and validating contact capacity.
- Updated `RepeaterDaemon` to check contact capacity during companion loading and initialization.
- Enhanced API endpoints to validate companion settings and manage contact limits effectively.
- Implemented logging for bridge limits and errors related to contact capacity.
2026-06-02 07:42:40 -07:00
Lloyd cd7058be99 fix: update packet router debugs for less noise and policy prep for advanced filters works 2026-06-02 12:18:17 +01:00
Lloyd 416310befd refactor: improve code readability 2026-06-02 10:31:47 +01:00
Lloyd d7e74e0a89 Merge pull request #278 from agessaman/feat/pre-1160-compatibility-sendfix
Feat/pre 1160 compatibility sendfix
2026-06-02 10:26:22 +01:00
agessaman e24cdca055 feat(companion): echo injected TX to companion clients as raw RX (0x88)
Push locally-injected TX packets to connected companion frame server
clients as PUSH_CODE_LOG_RX_DATA (0x88) with snr=0/rssi=0, so apps that
decrypt locally from raw RX (e.g. RemoteTerm) see companion-originated
channel traffic. The originating companion is excluded so a node never
hears its own transmission, matching physical firmware behavior.
inject_packet now takes an origin_hash (threaded per-companion via the
packet_injector partial); _on_raw_rx_for_companions gains exclude_hash
to skip that companion's frame server. OTA RX is unaffected.
2026-06-01 17:05:38 -07:00
Lloyd 2cacb7cfc0 Merge pull request #276 from pyMC-dev/feat-open-api
Feat open api updates
2026-05-31 10:08:03 +01:00
agessaman ee92f5b1a9 test: expect True from deferred local TX mock after companion send fix
The merged RepeaterHandler treats a falsy tx_success as failure; update
the duty-cycle deferral test to return True instead of None.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:43:00 -07:00
agessaman 5a9e1c87cc Merge branch 'fix/companion-message-send' into feat/pre-1160-compatibility-sendfix
Bring in companion transmission handling improvements from RepeaterHandler.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:42:26 -07:00
agessaman 778adb6917 feat: implement randomized response jitter in DiscoveryHelper to prevent packet collisions
- Added a default upper bound for randomized pre-send jitter in discovery responses to avoid collisions when multiple repeaters respond simultaneously.
- Introduced a new parameter `response_jitter_ms` in the `DiscoveryHelper` constructor to configure the jitter.
- Updated the `_send_packet_async` method to apply the jitter before sending responses.
- Added tests to verify the correct application of jitter and ensure functionality when jitter is disabled.
2026-05-30 18:07:23 -07:00
agessaman 5fcb6255d5 feat: enhance login handler with anonymous request support and region name formatting
- Updated the `LoginHelper` class to wrap the login handler in an `AnonRequestHandler`, allowing for proper handling of anonymous requests.
- Introduced methods for formatting region names based on flood policies and added support for retrieving transport keys from SQLite storage.
- Enhanced the constructor to accept additional parameters for SQLite handler and configuration, improving flexibility for owner-info and feature-flag replies.
- Added tests to validate the new functionality and ensure correct behavior of region name formatting and owner/features callbacks.
2026-05-30 16:19:52 -07:00
agessaman 6295f0fce1 feat: add utility function to restore bytes from JSON and enhance prefs handling in RepeaterCompanionBridge
- Introduced `_prefs_bytes_from_json` to convert JSON hex strings back to bytes for NodePrefs fields.
- Updated `_load_prefs` logic to handle bytes conversion when loading preferences.
- Improved the handling of preferences in the `RepeaterCompanionBridge` class to ensure proper type restoration.
2026-05-30 09:12:45 -07:00
Lloyd 0f6a7dc053 feat: support 64-byte identity keys in identity validation and tests 2026-05-28 10:29:35 +01:00
Rightup 60ca184dbd refactor: enhance security comments and error handling across multiple modules 2026-05-27 22:07:34 +01:00
Lloyd 45a44eb47b Refactor test cases and base code for consistency and readability
- Updated byte representations in tests to use lowercase hex format for consistency.
- Reformatted code for better readability, including line breaks and indentation adjustments.
- Consolidated multiple lines into single lines where appropriate to enhance clarity.
- Ensured that all test cases maintain consistent formatting and style across the test suite.
2026-05-27 20:15:10 +01:00
Lloyd faa3296a50 refactor: remove unused imports from test files for cleaner code 2026-05-27 14:56:01 +01:00
Lloyd 62f35c4b45 fix: update transport key generation to use 16-byte length and add corresponding test 2026-05-27 14:27:59 +01:00
Zindello d597ab2ea8 fix: replace datetime.UTC attribute access in repeater_cli
Also extend the compat scanner to catch datetime.UTC used as an
attribute (datetime.datetime.now(datetime.UTC)) in addition to
direct imports, so this form cannot be reintroduced undetected.

Co-Authored-By: Zindello <josh@zindello.com.au>
2026-05-27 12:16:56 +10:00
Zindello a1c66100f5 fix: remove datetime.UTC from mqtt_handler and add 3.10 compat test
Replace the try/except UTC shim in mqtt_handler.py with timezone.utc
directly, consistent with the api_endpoints.py fix. Add a static AST
scan that fails if datetime.UTC is reintroduced anywhere in the codebase,
guarding against future regressions on Python 3.10 (LuckFox Pico Ultra).

Co-Authored-By: Zindello <josh@zindello.com.au>
2026-05-27 11:57:45 +10:00
Lloyd 7b86716e06 Add unit tests for HTTP server, main daemon, service utilities, SQLite handler, and update endpoints 2026-05-26 14:59:31 +01:00
Lloyd 37ee0e892a Add more unit tests for handler helpers, identity manager, CLI, key generation, and main functionality
- Introduced tests for TraceHelper and DiscoveryHelper to validate packet forwarding and discovery request handling.
- Implemented tests for LoginHelper to ensure identity registration and login packet processing.
- Added tests for IdentityManager to cover identity registration, lookup, and filtering.
- Created tests for MeshCLI to verify command handling, configuration setting, and error paths.
2026-05-26 13:01:38 +01:00