GPS through Gadgetbridge

Posted on
of 2
/ 2
  • 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


    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):­etbridge/src/branch/master/app/src/main/­java/nodomain/freeyourgadget/gadgetbridg­e/service/devices/pebble/webview/Current­

    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 :)

  • Yeah i saw it, if i need to update the branch again, i gonna look at it

  • Yesterday, the Gadgetbridge PR was merged, so this should now be included in the next release of the app.

  • Realistically I'm probably not going to do a new Gadgetbridge app release before Christmas - Google added some extra requirements to the Play Store, and in the process of satisfying them things could get broken - and I don't want to do that just before Christmas when I won't be around to fix them.

    But the nightlies should have it in I hope.

  • Not sure I would want an automatic fallback to watch gps. Too dangerous in my view as you might not be aware and it could flaten the battery. Also there could be a long period of no fix whilst the gps powers on and gets a first fix. Would have to be an option IMO.

  • The phone delivering GPS data is done to save power when GPS is active on the bangle. It does not push GPS events all the time.
    The automatic fallback just restores the default Bangle GPS behaviour when some app is using that. So if you use GPS on the Bangle you usually are aware of the power use and in case the phone can help out you save power with this feature. It does not use additional power in any previously possible usecase.
    The nightly on fdroid already has these changes. Did not test a lot, but the location icon on the phone pops up if I start a GPS app on the Bangle.

  • I found some bugs in the Gadgetbridge app aswell as in the "Android" app on the banglejs device.

    The bug on the Gadgetbridge was, that the GPS_PROVIDER when the NETWORK_PROVIDER should have been used to get the gps data. Therefore the GPS data wasn't updated if you don't have a connection to some GPS sattelites. I fixed it and you can find the PR here

    The bug on the Banglejs "Android" App was that the received data was published on the "gps" event. However the normal event used by the build in gps chip is the "GPS" event. I changed therefore the event to match the event used by the build in gps chip.
    Also, the retrieved JSON object form the Gadgetbridge contained the longitude value under the key "long". To match the object structure of the gps data comming from the gps chip(which uses the key "lon"), i added a mapper to map the longitude correctly. You can find the PR for that here

    If you have time please take a look. @Gordon if it is not to late i would suggest to wait until the fix of the Gadgetbridge app is merge before releasing a new version of the Banglejs-Gadgetbridge app, so that this fix is also included.

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

GPS through Gadgetbridge

Posted by Avatar for user148386 @user148386