Skip to content

Conversation

@Erics1337
Copy link
Contributor

Description

This PR improves the robustness of the CapacitorSerial protocol adapter. These changes were extracted from #4725 to be merged independently.

Changes

  • Robustness: Added checks for this.pluginAvailable in CapacitorSerial.js methods (loadDevices, connect, disconnect, send, requestPermissionDevice). This prevents crashes when the native BetaflightSerial plugin is missing, such as during browser-based development.
  • Validation: Enhanced hexStringToUint8Array to correctly strip optional "0x" prefixes and validate that the input string contains only valid hex characters before parsing.

Testing

  • Verified application stability when running in a browser environment without the native serial plugin.
  • Verified serial connection still works as expected on supported devices.

Ensure CapacitorSerial instance is fully initialized even without the native plugin,
preventing runtime errors when methods are called. All native calls are now guarded.
Validate input hex strings: strip '0x', enforce even length, and check character
validity before parsing, throwing descriptive errors on failure.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

Warning

Rate limit exceeded

@Erics1337 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fece39d and 61f5c65.

📒 Files selected for processing (1)
  • src/js/protocols/CapacitorSerial.js (8 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

@haslinghuis
Copy link
Member

Copy link
Member

@haslinghuis haslinghuis left a comment

Choose a reason for hiding this comment

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

IMO there is no need to add this change, the protocol cancels in the constructor if not available, as the data format has been established.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants