Skip to content

feat: batch nodeinfos#4984

Draft
jamesarich wants to merge 2 commits intomainfrom
feat/batch-nodeinfos
Draft

feat: batch nodeinfos#4984
jamesarich wants to merge 2 commits intomainfrom
feat/batch-nodeinfos

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

This pull request adds support for batch processing of node information, improving the efficiency and reliability of node info synchronization in the mesh network. The changes update the handshake to use a new batch nonce, introduce handling for NodeInfoBatch messages, and include comprehensive tests for both batch and legacy flows.

Batch node info handling and handshake updates:

  • Added support for receiving and processing NodeInfoBatch in FromRadioPacketHandlerImpl, routing it to the new handleNodeInfoBatch method and updating connection progress accordingly. [1] [2]
  • Updated MeshConfigFlowManagerImpl to accumulate nodes from batches, handle both legacy and batch nonces for config completion, and provide a new handleNodeInfoBatch method for bulk node addition. [1] [2] [3]
  • Modified MeshConnectionManagerImpl so that startNodeInfoOnly now requests the batch node info nonce (BATCH_NODE_INFO_NONCE) instead of the legacy one.

Testing improvements:

  • Added a new test suite MeshConfigFlowManagerImplTest covering batch and legacy node info flows, nonce handling, and edge cases like empty batches.
  • Enhanced FromRadioPacketHandlerImplTest to verify correct handling and status updates when receiving a NodeInfoBatch. [1] [2]
  • Improved MeshConnectionManagerImplTest to check that startNodeInfoOnly uses the correct batch nonce and to clean up redundant code. [1] [2] [3] [4]

Mock and utility updates:

  • Updated imports and mock implementations to support new batch-related types and constants, and refactored mock node info generation for clarity. [1] [2] [3]

@github-actions github-actions bot added the enhancement New feature or request label Apr 3, 2026
@jamesarich jamesarich marked this pull request as draft April 3, 2026 15:38
This commit introduces support for `NodeInfoBatch` messages, allowing the application to receive and process multiple node records efficiently during the second stage of the device handshake. This replaces the legacy approach of sending node information individually, improving synchronization performance.

Key changes include:

- **Handshake Protocol:**
    - Added `BATCH_NODE_INFO_NONCE` to `HandshakeConstants`.
    - Updated `MeshConnectionManagerImpl` to request batched node information by default during the handshake process.
    - Updated `MeshConfigFlowManagerImpl` to handle the batch-specific completion nonce, ensuring Stage 2 of the handshake finalizes correctly.

- **Packet Handling:**
    - Enhanced `FromRadioPacketHandlerImpl` to detect `node_info_batch` packets.
    - Implemented logic to iterate through batched items and process each `NodeInfo` record via the `MeshConfigFlowManager`.
    - Updated connection progress reporting to reflect the count of nodes received within a batch.

- **Testing and Simulation:**
    - Updated `MockInterface` to simulate batched node delivery, refactoring the mock response logic into distinct Stage 1 (config) and Stage 2 (node info) phases.
    - Added a unit test in `FromRadioPacketHandlerImplTest` to verify that batched items are correctly routed and that the UI connection status is updated.

Specific changes:
- Modified `HandshakeConstants` to document the transition to batched NodeInfo delivery in Stage 2.
- Updated `MeshConnectionManagerImpl.startNodeInfoOnly()` to use the new batch nonce.
- Added `nodeInfoBatch` processing branch to the `handleFromRadio` logic.
This commit optimizes the mesh handshake protocol by introducing explicit support for `NodeInfoBatch` messages. It updates the configuration flow to handle both primary batched node delivery and legacy single-node delivery for backwards compatibility with older firmware.

Key changes include:

- **Batch Processing Optimization:**
    - Added `handleNodeInfoBatch` to the `MeshConfigFlowManager` interface to allow bulk processing of node information, reducing per-item overhead during the initial handshake.
    - Updated `MeshConfigFlowManagerImpl` to accumulate batched nodes efficiently using `addAll`.
    - Refactored `FromRadioPacketHandlerImpl` to delegate batch processing directly to the manager instead of iterating through individual items.

- **Handshake Protocol Updates:**
    - Updated `HandshakeConstants` to distinguish between `BATCH_NODE_INFO_NONCE` (primary Stage 2) and `NODE_INFO_NONCE` (legacy Stage 2).
    - Modified `handleConfigComplete` logic to trigger Stage 2 completion for both batched and legacy nonces.
    - Ensured `MeshConnectionManager` prioritizes the batch nonce when requesting node information.

- **Testing & Simulation:**
    - Created `MeshConfigFlowManagerImplTest` to validate node accumulation, batch handling, and handshake nonce routing.
    - Improved `MockInterface` to better simulate real-world packet ordering by delaying live traffic until after the handshake completion coroutine has processed the node database.
    - Added verification tests to ensure the connection manager uses the correct batching nonces.

Specific changes:
- Added `handleNodeInfoBatch` implementation to `MeshConfigFlowManagerImpl`.
- Updated documentation in `HandshakeConstants` regarding two-stage mesh handshake protocol.
- Refactored `MockInterface.sendStage2NodeInfoResponse` to handle packet encoding and simulation delays.
- Added unit tests covering edge cases for empty and mixed node info batches.
@jamesarich jamesarich force-pushed the feat/batch-nodeinfos branch from aa6d47b to a74d5d4 Compare April 3, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant