Skip to content

Conversation

@jinglemansweep
Copy link
Contributor

No description provided.

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.
Copilot AI review requested due to automatic review settings November 24, 2025 16:16
@jinglemansweep jinglemansweep merged commit e718e0c into main Nov 24, 2025
@jinglemansweep jinglemansweep deleted the claude/fix-meshbot-message-delivery-01TEWb6CdXB8SmUJjAVaHb8A branch November 24, 2025 16:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

3 participants