-
-
Notifications
You must be signed in to change notification settings - Fork 906
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
Add DFU support for PWA #3949
Add DFU support for PWA #3949
Conversation
✅ Deploy Preview for origin-betaflight-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This comment has been minimized.
This comment has been minimized.
Good work @haslinghuis |
Will grab a look tomorrow morning. Have few ideas about the webdfu parts |
.then(result => { | ||
if (result.status === 'ok') { | ||
const _length = result.data.getUint8(0); | ||
let _descriptor = ''; | ||
for (let i = 2; i < _length; i += 2) { | ||
const charCode = result.data.getUint16(i, true); | ||
_descriptor += String.fromCharCode(charCode); | ||
} | ||
callback(_descriptor, 0); |
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.
I'm not familiar with usb so have a noob question probably.
What populates result.data
? Like do we write into that thing, are first 8 bits which represent the length something we write or something standard?
Asking because we could potentially avoid the whole for
loop here for string parsing and use TextDecoder instead.
Even if we just cut off the length
and pass in the rest text decoder should be able to handle that.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Sorry to request this, but I feel like since it's a new file we should aim to get rid of at least the most obvious problems with the old code.
Something to start with:
- Removing commented out blocks of code in webdfu.
- Removing
self = this
pattern, it's not relevant anymore with classes and arrow functions.
There is defo more but these would at least put us up for better coding conventions in new code.
EDIT: refactored whole function and now it works. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Don't know what was the culprit, but it might be that there was Main reason for that pattern in the past was because |
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.
LGTM
https://build.betaflight.com/api/builds/220ec26ced03bc9893d4d0f48ee9f9ac/log & /hex valid. Chrome Version 124.0.6367.201 (Official Build) (64-bit) / Debian 12 |
@nerdCopter how did you test? Works locally (yarn dev). Have not checked on Netlify. This code needs to run in secure context. Screencast.from.14-05-24.18.18.48.webm |
Netlify |
Okay, i get the DFU via your described process. it does not erase/flash, but the DFU is there. |
Quality Gate failedFailed conditions |
@nerdCopter should work now. Removed flash protection as it does not work on F4 or F7 |
|
@nerdCopter this is to be expected as PortHandler did all the hard work but currently is disabled for PWA. |
Testing using
yarn dev
On Ubuntu Firefox does not support these web APIs, as snap install of Chromium does not work either.
Need to install package like:
Tested flashing on: