GPS through Gadgetbridge

Posted on
  • Hi everyone,

    i was looking into the GPS of the Banglejs 2 and it seems like it uses alot of energy if in use. I was wondering if it would be possible to get the GPS data through the gadgetbridge, since the phone has the needed battery capacity and a good enough GPS position?

    Also, it looks like that the Gadgetbridge already collects location data.

  • I'm not 100% sure if Gadgetbridge does collect location data. It has to ask for permissions, but that is actually what is required to access Bluetooth!

    But yes, that's a good idea. I feel like it's definitely something that could be added to Gadgetbridge. It could be an option in the 'Android Integration' app and when enabled, if the phone is connected it can override Bangle.setGPSPower so it uses the phone's GPS instead

  • I was thinking about a new method like

    Bangle.getExternalGPS
    

    but your idea sounds also good.

    In the settings of Gadgetbridge is an option to determine the current location and it has also an option "Keep location uptodate" so i thought there is already a way to get the location in gadgetbridge.

  • @Gordon do you have an idea when this could be implemented?

  • @Gordon do you have an idea when this could be implemented?

    Honestly at this point I'd be doing basically what anyone would - which is trawling through the source to find out what that "Keep location uptodate" menu option does.

    But when you know how to do it, just implement it in BanglejsDeviceSupport to send a gps event via uartTxJSON in the same way all the other events do...

  • Implementing this is beyond my skills, but it would make the watch far more useful for things like cycling, hiking, paragliding - basically all outdoor activities where you need constant location information. Constant onboard GPS usage shortens battery life from a few weeks to a few hours.

  • This would be great. During hiking I had my phone tracking the location anyway because of the much better GPS reception. Using that to cheaply (in terms of battery) providing a position to the bangle is a good thought.

    @user148386 having a new method would mean all apps would have to be changed to use this. Overriding the original method (possibly as a config option) solves this. This can also allow an automatic fallback to internal GPS should the watch get disconnected from the phone.

  • Just looking into this, the pref is called use_updated_location_if_available and there's a CurrentPosition class which tries to get the current location updated every 24 hours (but it seems it won't actually turn the GPS on if it's not needed): https://codeberg.org/Freeyourgadget/Gadg­etbridge/src/branch/master/app/src/main/­java/nodomain/freeyourgadget/gadgetbridg­e/service/devices/pebble/webview/Current­Position.java

    So this isn't something we can just hook on to. I guess the best solution is actually for the Bangle interface code to just check prefs.getBoolean("use_updated_location_i­f_available", false) and then turn the GPS on and request location direct from Android if GPS has been requested.

  • Hi,
    i had time this weekend and implemente a possible way to send the gps position. I send it as a "gps" event. How can i now use it on the banglejs device, do i have to adjust the android integration app aswell or is it handled automaticly?

    If you want have a look at the code, you can find it here. I have currently the problem, that the LocationManager dose not return the count of satellites or the current course(at least i didn't find a getter for that), so i set them to zero. I also send an extra flag to show that the gps data comes from an external source.

  • You would probably have to implement a handler for the gps event in boot.js#20 of the android bangle app, that then calls something like Bangle.emit("gps",data); do make the GPS info usable for other apps on the bangle. At least for a proof of concept that should work fine.
    Then there would need to be some handling of the internal GPS. Maybe switching it off as long as GB sends gps events or something similar.

  • Can you give me a path to that file, because i don't find it?

  • Hi, i would have an implementation that sends the gps data from the smathphone to the banglejs device. There it will be emitted with the "gps" event.
    Can i add the code to the officle Gadegtbridge and the android app for the banglejs? And if so what is the procedure for that?

  • Regarding the Gadgetbridge side of it:
    Open a new pull request on the official GB repository for pulling from your fork.

    Regarding the Banglejs side of it:
    Fork the BangleApps repository, if you haven't already.
    Add the code you need to the Android Integration app, but on your fork (primarily to boot.js, but maybe you want to add something to app.js or settings.js as well).
    Add a pull request on the official BangleApps repository for pulling from your fork.

  • Hi,
    the initial PR got broken so here is the new Gadgetbridge PR

    And here is the PR for the android intergration app

    Please take a look if you have time.
    Thank you

  • That's excellent - thanks! Let's hope this all gets merged soon :)

  • I had to repoen the Gadgetbride PR, since i broke the previous one by updating my branch. Do i have to do anything to merge it, or can only the maintainer merge the PR?

  • Yes, when the PR looks good to one/some of the maintainers it will be merged. I left a comment on your recently closed PR :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

GPS through Gadgetbridge

Posted by Avatar for user148386 @user148386

Actions