-
-
Notifications
You must be signed in to change notification settings - Fork 949
Serial refactor part 3 (BT) #4413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
haslinghuis
commented
Apr 6, 2025
•
edited
Loading
edited
- fix BT reboot and CRC issues (while switching protocols)
- in between connection operations needed better error and process handling
- noticed sometimes we need to ask for permission again after re-using BT connection
✅ Deploy Preview for origin-betaflight-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
4ae1af4
to
3022a94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/js/utils/AutoDetect.js:114
- [nitpick] For consistency with other event handlers, consider storing and using a bound reference for 'readSerialAdapter' to ensure reliable removal.
serial.removeEventListener("receive", readSerialAdapter);
src/js/serial.js
Outdated
return false; | ||
} | ||
|
||
// This will only execute for the already disconnected case or if an error occurred | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a synchronous value 'result' in an asynchronous disconnect callback can lead to inconsistent behavior; consider refactoring this method to return a Promise or otherwise handle the asynchronous state more reliably.
Copilot uses AI. Check for mistakes.
0950ecd
to
5225cbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/js/protocols/WebBluetooth.js:268
- Ensure tests cover error scenarios in getCharacteristics, such as when the characteristics array is empty or when expected characteristics are missing.
} catch (error) {
src/js/serial.js:261
- Consider adding tests to verify that disconnect behaves correctly when the protocol is already disconnected and that the callback is invoked appropriately.
if (!this._protocol.connected) {
5225cbb
to
3666732
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/js/serial.js:234
- [nitpick] The error message 'Failed to disconnect before reconnecting' may benefit from more detailed context (e.g., indicating which protocol is involved) to aid in debugging.
return false;
src/js/protocols/WebBluetooth.js:276
- [nitpick] While empty notifications are logged with a warning, it may be useful to add handling for a zero-length ArrayBuffer to ensure downstream consumers of the notification event receive consistent data.
if (!event.target.value) {
3d5a461
to
4d118cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
4d118cb
to
5bbb95c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/js/protocols/WebBluetooth.js:46
- The event name 'gatserverdisconnected' appears to be misspelled compared to the standard 'gattserverdisconnected'. Please verify and correct the event name to ensure proper handling.
this.bluetooth.addEventListener("gatserverdisconnected", (e) => this.handleRemovedDevice(e.target));
src/js/utils/AutoDetect.js:19
- The global 'mspHelper' variable may lead to conflicts if multiple AutoDetect instances are created; consider converting it to an instance property.
let mspHelper = null;
5bbb95c
to
1aa735f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (4)
src/js/protocols/WebBluetooth.js:173
- [nitpick] Consider renaming 'boundHandleReceiveBytes' to 'handleReceiveBytesBound' to make it clearer that this is a bound method.
this.addEventListener("receive", this.boundHandleReceiveBytes);
src/js/serial.js:233
- [nitpick] Consider providing additional context in the error message to aid in diagnosing the protocol state during reconnection failures.
console.error(`${this.logHead} Failed to disconnect before reconnecting`);
src/js/utils/AutoDetect.js:120
- Verify that clearing MSP listeners before calling 'MSP.disconnect_cleanup()' does not interfere with necessary cleanup operations; if order matters, consider reversing the sequence.
MSP.clearListeners();
src/js/protocols/WebBluetooth.js:260
- [nitpick] Consider standardizing this error message to ensure consistency with other error messages across the codebase.
throw new Error(`Write characteristic not found: ${this.deviceDescription.writeCharacteristic}`);
5228b45
to
7bed6c5
Compare
a522e54
to
979a0ee
Compare
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Preview URL: https://86b7318f.betaflight-configurator.pages.dev |
fe05faf
to
cb5bd86
Compare
Preview URL: https://98cb9bcc.betaflight-configurator.pages.dev |
Preview URL: https://665b5770.betaflight-configurator.pages.dev |
Preview URL: https://cab69153.betaflight-configurator.pages.dev |
|
Preview URL: https://ab1fcd9f.betaflight-configurator.pages.dev |