betaflight-configurator icon indicating copy to clipboard operation
betaflight-configurator copied to clipboard

fix bluetooth support issue for chrome on android

Open kikoqiu opened this issue 1 year ago • 16 comments

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

kikoqiu avatar Oct 26 '24 04:10 kikoqiu

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.

netlify[bot] avatar Oct 26 '24 04:10 netlify[bot]

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 avatar Oct 26 '24 13:10 PSi86

same result as @PSi86 (using OTG cable)

nerdCopter avatar Oct 26 '24 22:10 nerdCopter

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

guowei681 avatar Oct 27 '24 04:10 guowei681

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.

kikoqiu avatar Oct 27 '24 05:10 kikoqiu

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

PSi86 avatar Oct 28 '24 09:10 PSi86

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.

kikoqiu avatar Oct 28 '24 10:10 kikoqiu

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.

LoakAudio avatar Oct 28 '24 13:10 LoakAudio

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.

haslinghuis avatar Oct 31 '24 23:10 haslinghuis

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.

kikoqiu avatar Nov 03 '24 05:11 kikoqiu

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.

McGiverGim avatar Nov 04 '24 09:11 McGiverGim

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.

kikoqiu avatar Nov 04 '24 11:11 kikoqiu

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.

McGiverGim avatar Nov 08 '24 11:11 McGiverGim

@kikoqiu are you still working on this ?

haslinghuis avatar Jan 28 '25 18:01 haslinghuis

Some background: https://github.com/GoogleChrome/developer.chrome.com/issues/7948

haslinghuis avatar Apr 13 '25 12:04 haslinghuis