Fix Meshbot messages not reaching Meshcore network#27
Merged
jinglemansweep merged 2 commits intomainfrom Nov 24, 2025
Merged
Conversation
This change addresses the problem where the second or third message in a multi-chunk response was not being received, likely due to LoRa duty cycle restrictions and timing/flooding issues. Changes: - Add MESHCORE_MESSAGE_DELAY config (default: 3.0s) for inter-message delay - Add MESHCORE_MESSAGE_RETRY config (default: 1) for retry attempts - Increase delay between message chunks from 0.5s to configurable delay - Implement retry logic with exponential backoff for failed sends - Enhance error logging in meshcore_interface.py for better debugging - Update .env.example with new configuration options Technical details: - LoRa duty cycle restrictions (e.g., 1% in Europe) require ~50s wait after a 500ms transmission, but we use conservative 3s default - Retry logic uses exponential backoff (2s, 4s, 8s...) - All configuration is via environment variables or CLI arguments - Maintains backward compatibility with existing deployments References: - https://www.thethingsnetwork.org/docs/lorawan/duty-cycle/ - https://github.com/meshcore-dev/meshcore_py
Update the default MESHCORE_MESSAGE_DELAY from 3.0 to 5.0 seconds to provide better reliability for LoRa deployments, especially in Europe where 1% duty cycle restrictions are stricter. Changes: - Update config.py default: 3.0s -> 5.0s - Update agent.py default parameter: 3.0s -> 5.0s - Update .env.example with improved documentation - Add LoRa Duty Cycle Management section to AGENTS.md - Add configuration notes to README.md Message Behavior section The 5.0 second delay provides a safe balance between speed and reliability across different regulatory regions, while remaining configurable via environment variable for specific deployments.
There was a problem hiding this comment.
Pull request overview
This PR enhances message reliability for Meshbot by implementing retry logic with exponential backoff and configurable delays to comply with LoRa duty cycle restrictions. The changes address issues where messages were not successfully reaching the Meshcore network due to radio limitations like queue overflow or busy radio states.
Key Changes:
- Adds configurable retry mechanism with exponential backoff (2s, 4s, 8s...) for failed message sends
- Implements configurable delays between message chunks to respect LoRa duty cycle restrictions
- Enhances logging throughout the message sending pipeline for better debugging visibility
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/meshbot/config.py | Adds message_delay and message_retry_count configuration fields with environment variable support |
| src/meshbot/agent.py | Implements retry logic with exponential backoff and configurable inter-chunk delays in message handling |
| src/meshbot/meshcore_interface.py | Enhances logging for message send operations with detailed status information |
| src/meshbot/main.py | Passes new configuration parameters to MeshBotAgent initialization in both run and test modes |
| README.md | Documents new environment variables and explains LoRa duty cycle compliance requirements |
| AGENTS.md | Adds technical documentation for retry logic and duty cycle management features |
| .env.example | Provides example configuration with detailed comments for new settings |
Comments suppressed due to low confidence (3)
src/meshbot/meshcore_interface.py:811
- This import of module asyncio is redundant, as it was previously imported on line 3.
import asyncio
src/meshbot/agent.py:621
- 'except' clause does nothing but pass and there is no explanatory comment.
except Exception:
src/meshbot/agent.py:638
- This statement is unreachable.
except Exception as e:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.