Skip to content

Fix UART/BLE status reporting gate and test isolation - #9

Merged
retsimx merged 1 commit into
mainfrom
fix/uart-status-reporting-gate
Mar 16, 2026
Merged

Fix UART/BLE status reporting gate and test isolation#9
retsimx merged 1 commit into
mainfrom
fix/uart-status-reporting-gate

Conversation

@retsimx

@retsimx retsimx commented Mar 16, 2026

Copy link
Copy Markdown
Owner

Previously, process_mesh_operations() gated both BLE notifications and UART status sends on is_add_packet_buf_ready() && !uart_manager.started(). Once the UART daemon connected, started() returned true and ALL status reporting silently stopped — BLE included.

The fix separates the two reporting paths:

  • BLE: gated only on is_add_packet_buf_ready()
  • UART: gated only on uart_manager.uart_status_reporting_enabled()
  • Mesh status data collected once and shared between both sinks

Supporting changes:

  • mesh_node_report_status tagged #[cfg_attr(test, mry::mry)] to enable mocking
  • reset_global_state() in connection tests resets app().uart_manager to prevent mock state leaking into later tests
  • reset_app_uart_for_test() added to lib.rs as a direct-access helper that resets the global APP's uart_manager without going through the mockable app_mocker(), so it is safe to call from test helpers that run inside a mry::lock(app_mocker) scope
  • reset_test_state() in packet_processing tests calls reset_app_uart_for_test() to eliminate mock contamination from preceding connection tests
  • Two new tests: test_process_mesh_operations_ble_and_uart_are_independent and test_process_mesh_operations_ble_fires_without_uart

Previously, process_mesh_operations() gated both BLE notifications and UART
status sends on is_add_packet_buf_ready() && !uart_manager.started(). Once
the UART daemon connected, started() returned true and ALL status reporting
silently stopped — BLE included.

The fix separates the two reporting paths:
- BLE: gated only on is_add_packet_buf_ready()
- UART: gated only on uart_manager.uart_status_reporting_enabled()
- Mesh status data collected once and shared between both sinks

Supporting changes:
- mesh_node_report_status tagged #[cfg_attr(test, mry::mry)] to enable mocking
- reset_global_state() in connection tests resets app().uart_manager to prevent
  mock state leaking into later tests
- reset_app_uart_for_test() added to lib.rs as a direct-access helper that
  resets the global APP's uart_manager without going through the mockable
  app_mocker(), so it is safe to call from test helpers that run inside a
  mry::lock(app_mocker) scope
- reset_test_state() in packet_processing tests calls reset_app_uart_for_test()
  to eliminate mock contamination from preceding connection tests
- Two new tests: test_process_mesh_operations_ble_and_uart_are_independent and
  test_process_mesh_operations_ble_fires_without_uart
@github-actions

Copy link
Copy Markdown

📊 Coverage Report

Metric Coverage
Lines 99.96%
Functions 100.00%
Regions 99.84%
Branches 93.91%

@retsimx
retsimx merged commit 5a1efc6 into main Mar 16, 2026
5 checks passed
@retsimx
retsimx deleted the fix/uart-status-reporting-gate branch March 16, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant