Skip to content
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

App interfaces don't work inside Gadgetbridge #55

Closed
thyttan opened this issue Sep 13, 2023 · 6 comments
Closed

App interfaces don't work inside Gadgetbridge #55

thyttan opened this issue Sep 13, 2023 · 6 comments

Comments

@thyttan
Copy link

thyttan commented Sep 13, 2023

...I have not tested them all, but this is generally my experience.

Example with Schedulers interface:

  1. Open app loader inside Bangle.js Gadgetbridge.
  2. Navigate to Scheduler app entry (make sure it's installed on the watch).
  3. Click the floppy disk icon of Scheduler app entry to try and access its interface.
  4. The interface starts loading and the UI is visible behind a dialog saying "Please wait Loading...".
  5. The dialog doesn't go away.
  6. Clicking the interface's x-button takes me back to the app loader window.

Logcat that starts on step 3 above is attached:
logcat-clicking-scheduler-floppy-disk-icon-in-app-loader-in-gadgetbridge.txt

I don't know what the approach should be. Maybe it's hard to implement e.g. Recorders interface inside Gadgetbridge. One could imagine the downloaded file being stored in Gadgetbridge's Export/Import directory - but I don't know how hard that would be to implement. But the Scheduler one shouldn't be too hard to get working I'd think - but I know hardly anything about webviews so maybe shouldn't say too much.

@gfwilliams
Copy link
Member

Just to be clear, this is the interface.html - not custom.html - those pretty much all work fine I think.

I encountered this before with openstmap and didn't have a chance to look into it fully, but as far as I could see it's some issue with how char code 255 (0xff) is received and pushed to JavaScript. Without it the functions in Comms that end up receiving files/data/etc don't know that the transmission has ended.

@thyttan
Copy link
Author

thyttan commented Sep 13, 2023

Thanks for clarifying! (Yes - I was under the impression those were the same thing 🙃)

@gfwilliams
Copy link
Member

You can debug by connecting your phone with adb, then going to chrome://inspect/#devices in Chrome once the app loader is loaded in Gadgetbridge.

Paste this into the console:

var oldBangleRx = bangleRx; bangleRx = function(d) { console.log("RX",JSON.stringify(d)); oldBangleRx(d); }
Android.bangleTx("\x10Bluetooth.println('Hello')\n")

Then you get "Hello\r\n" - great.

But:

Android.bangleTx("\x10Bluetooth.println('\\xff')\n")

Gives "�\r\n" and "�\r\n".charCodeAt() == 65533

The code is getting there ok though because:

Android.bangleTx("\x10Bluetooth.println('\\xff'.charCodeAt())\n")

gives "255\r\n" - so it's a Gadgetbridge issue about how char code 255 ends up translated to a JS a string. It's probably UTF8 related again :(

I think it's https://codeberg.org/Freeyourgadget/Gadgetbridge/src/branch/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/banglejs/AppsManagementActivity.java#L153-L156

The idea was we use the JSON library to create a JS string, but I wonder what Android thinks is in that String - whether it's char code 255 or 65533

@thyttan thyttan changed the title App customiser interfaces don't work inside Gadgetbridge App interfaces don't work inside Gadgetbridge Sep 13, 2023
@thyttan
Copy link
Author

thyttan commented Sep 13, 2023

I've had trouble using adb directly. But I can use wireless debugging with Android Studio to build and install to my phone. I'll try and read up on it again.

@gfwilliams
Copy link
Member

Ok, just fixed with https://codeberg.org/Freeyourgadget/Gadgetbridge/commit/e18a991b138d9097f053457ef156e48d78130608

@gfwilliams
Copy link
Member

I just added some code that should help with downloads too - although for it to work for must stuff I'll need to update the app loader (turns out we can't download Blob, so we have to download with base64 links instead)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants