betaflight / betaflight-configurator

Cross platform configuration tool for the Betaflight firmware
GNU General Public License v3.0
2.57k stars 909 forks source link

fix bluetooth support issue for chrome on android #4227

Open kikoqiu opened 3 weeks ago

kikoqiu commented 3 weeks ago

Fix bluetooth support issue for chrome on android Add usb otg serial support for chrome on android.

Bluetooth verified with speedybee bluetooth fc on android 14. Serial polyfill works on android 11, fails on android 14. The reason might be this. https://github.com/betaflight/betaflight-configurator/pull/4227#issuecomment-2441166791

netlify[bot] commented 3 weeks ago

Deploy Preview for origin-betaflight-app ready!

Name Link
Latest commit b11c3210a3f0ffc10b7896229135ae1e562e7a54
Latest deploy log https://app.netlify.com/sites/origin-betaflight-app/deploys/673c3bda63b0fd0008982072
Deploy Preview https://deploy-preview-4227.dev.app.betaflight.com
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

PSi86 commented 3 weeks ago

Thanks for working on this! Samsung S21 Chrome Browser: App shows up but no serial devices are shown and clicking the "Connect" button does nothing. Screenshot_20241026_151213_Chrome

nerdCopter commented 3 weeks ago

same result as @PSi86 (using OTG cable)

guowei681 commented 3 weeks ago

I use Samsung TAB S8+ and the connection is OK image image image Using this configurator to connect to Other Bluetooth at the same time also works fine: image image image image Under Windows, opening the connection through Google Chrome works fine image image image

kikoqiu commented 3 weeks ago

Thanks for working on this! Samsung S21 Chrome Browser: App shows up but no serial devices are shown and clicking the "Connect" button does nothing. Screenshot_20241026_151213_Chrome

@PSi86 @nerdCopter The original UI code has some issues for portrait mode on small screens. So just use landscape mode and the port select will display. I think it might be better leave it for the author of the ui code.

PSi86 commented 3 weeks ago

Using Portrait mode or a bigger screen, indeed the device selector shows up and an stm32f405 is correctly detected when plugged in via USB. The request for permission to access the device is shown. Upon accepting this and then clicking "Connect" the button again nothing happens. Same behaviour on Samsung Galaxy S21 and Galaxy Tab S9 FE. Screenshot_20241028_001036_Chrome

kikoqiu commented 3 weeks ago

Using Portrait mode or a bigger screen, indeed the device selector shows up and an stm32f405 is correctly detected when plugged in via USB. The request for permission to access the device is shown. Upon accepting this and then clicking "Connect" the button again nothing happens. Same behaviour on Samsung Galaxy S21 and Galaxy Tab S9 FE. !

That's an issue. The serial usb polyfill works on my old android phone but fails on my new android 14 phone. The problem i believe is because of this bug. https://issues.chromium.org/issues/40137537 Some driver claimed the serial usb interface. And the webserial polyfill failed to claim it anymore.

On my phone I have an workaround, by using a native app to open the serial port,and then close it. After that,I'm able to connect to the port using pwa configurator on chrome. It's not a good solution, so maybe I need to remove the serial polyfill.

The bluetooth is tested on android 14 with a speedybee bluetooth fc, and it works well.

LoakAudio commented 3 weeks ago

Hi all, I've found this PR yesterday and I'm very interested as I own a Samsung A9+ 5g tablet (Android 14). I've tested with a Speedybee V3 BT adapter on a Flywoo F405 AIO and connection is ok. I can modify settings, save & restart. Sometimes, playing with the 3D model in the "Setup" tab leads to a freeze of the 3D quad. Most of the time changing tab makes it working again, sometimes I have to close BFC, unplug the adapter and connect again. I don't know if this is related to this PR.

haslinghuis commented 3 weeks ago

This fix works for some Android devices but not all of them.

Was thinking capacitor was going to fix mobile usage of the app - but needs attention.

kikoqiu commented 2 weeks ago

This fix works for some Android devices but not all of them.

Was thinking capacitor was going to fix mobile usage of the app - but needs attention.

Yes, this fix gets some limitations. 1, it only works with chrome on Android. 2, the serial polyfill only woroks on old android devices, new devices need some tricks to work. 3, bluetooth should work on most android devices.

might be a candicate for the pwa. but should be better to use a native wrapper.

McGiverGim commented 2 weeks ago

This solution was tried here before https://github.com/betaflight/betaflight-configurator/pull/3948 and adding the library in the package file (here it has been manually added). But as you say it only works for some old devices and I think remember it didn't implement all the events we use so is not a complete solution neither.

We decided to go for a "complete" solution, with the use of Capacitor https://github.com/betaflight/betaflight-configurator/pull/3955 so the correct solution is to search for a library compatible with Capacitor and use it when executing in Android.

Was in my TODO list but I've no time at this moment.

kikoqiu commented 2 weeks ago

This solution was tried here before #3948 and adding the library in the package file (here it has been manually added). But as you say it only works for some old devices and I think remember it didn't implement all the events we use so is not a complete solution neither.

We decided to go for a "complete" solution, with the use of Capacitor #3955 so the correct solution is to search for a library compatible with Capacitor and use it when executing in Android.

Was in my TODO list but I've no time at this moment.

The bluetooth part works well on chrome on android. So I think it's not bad to make it available for the PWA, and leave the full feature as a Capacitor app.

McGiverGim commented 2 weeks ago

If bluetooth works in all / the major part of Android devices, it's ok for me to add this. I suppose that we will need to add the library later to be compatible with Apple devices, but this is a war for the future.

But for usb / serial devices, I think we need to add Capacitor for Android.

sonarcloud[bot] commented 3 days ago

Quality Gate Passed Quality Gate passed

Issues
16 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud