[Banglejs] Send phone location data to banglejs, which can be used as gps data #2961

Closed
LukasEdl wants to merge 6 commits from LukasEdl:banglejs-gps-updater into master
Contributor

With this PR, the gadgetbridge app sends the current locationd data, obtained from the gps or network provider, to a connected banglejs device as an "gps" event.

The bangle device can use this data instead of the internal gps data. Therefor saving battery energy, since the gps chip is one of the biggest energy consumers.

Furthermore it enables the banglejs device to use the location data, based on the network with which the phone is currently connected. This would be usefull if there is no gps signal.

With this PR, the gadgetbridge app sends the current locationd data, obtained from the gps or network provider, to a connected banglejs device as an "gps" event. The bangle device can use this data instead of the internal gps data. Therefor saving battery energy, since the gps chip is one of the biggest energy consumers. Furthermore it enables the banglejs device to use the location data, based on the network with which the phone is currently connected. This would be usefull if there is no gps signal.
LukasEdl added 5 commits 2022-11-07 13:28:13 +00:00
Member

Could you use the GBLocationManager? You can then override onSetGpsLocation with the logic you have on onLocationChanged. See how it is used in HuamiSupport.

We might need to update it to include network location updates, as right now it only uses GPS.

Also, I think you're missing some way to unregister the location updates - they will keep going after the device is disconnected.

Could you use the [GBLocationManager](https://codeberg.org/Freeyourgadget/Gadgetbridge/src/branch/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/gps/GBLocationManager.java)? You can then override `onSetGpsLocation` with the logic you have on `onLocationChanged`. See how it is used in [HuamiSupport](https://codeberg.org/Freeyourgadget/Gadgetbridge/src/branch/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java). We might need to update it to include network location updates, as right now it only uses GPS. Also, I think you're missing some way to unregister the location updates - they will keep going after the device is disconnected.
Member

One more note: this will keep the phone awake and continuously send the GPS updates to the watch - is that intended? What is the use-case? - (bear with me - I don't have a lot of context on the Bangle :) )

One more note: this will keep the phone awake and continuously send the GPS updates to the watch - is that intended? What is the use-case? - (bear with me - I don't have a lot of context on the Bangle :) )
Contributor
Just leaving [a related thread over at the espruino/Bangle.js forum here](https://forum.espruino.com/conversations/380297/).
Author
Contributor

I didn't know of the GBLocationManager i gonna take look on it. The network location would be quite usefull since it provides an alternative location, if there is no gps signal (which was the case during the development).

For the context, the banglejs is a smarth watch that is complety programmable. It has bluetooh capabilites and together with the gadgetbridge app it has even access to the internet.

My use case of the constant sending of gps data would be, that the banglejs could show different information based on the location of the device. For instance, it could show my current workout routine when i am at the gym, or the groccery list if i am in a supermarket.

The banglejs has its own gps chip, however it uses alot of energy and it only provides data based on the gps location. With this implementation it would have also access to the network gps data.

The energy consumption would be increased on the smarthphone, however smarthphons tend to have bigger batteries and are charged more often (at least that is in my case).

To improve the energy efficenty, we could maybe use an configurable interval, so that the gps is not always on.

I didn't know of the GBLocationManager i gonna take look on it. The network location would be quite usefull since it provides an alternative location, if there is no gps signal (which was the case during the development). For the context, the banglejs is a smarth watch that is complety programmable. It has bluetooh capabilites and together with the gadgetbridge app it has even access to the internet. My use case of the constant sending of gps data would be, that the banglejs could show different information based on the location of the device. For instance, it could show my current workout routine when i am at the gym, or the groccery list if i am in a supermarket. The banglejs has its own gps chip, however it uses alot of energy and it only provides data based on the gps location. With this implementation it would have also access to the network gps data. The energy consumption would be increased on the smarthphone, however smarthphons tend to have bigger batteries and are charged more often (at least that is in my case). To improve the energy efficenty, we could maybe use an configurable interval, so that the gps is not always on.
Member

Hi - this looks good - but as @joserebelo mentioned I'd be a bit concerned that this would permanently keep the phone's GPS on, and would drain the phone battery pretty quick.

Maybe you could add a line to handleUartRxJSON at e978cb7aa1/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java (L436) that will detect a message coming in of type gps and look at a power field to see if it should turn the phone GPS on or off.

The same function to handle on/off could also be called on disconnect to stop the GPS service.

... so then it'd report network location all the time (because that doesn't add to power consumption?) and then on Bangle.js we can have the option to basically override the internal GPS and use the phone's GPS.

Hi - this looks good - *but* as @joserebelo mentioned I'd be a bit concerned that this would permanently keep the phone's GPS on, and would drain the phone battery pretty quick. Maybe you could add a line to `handleUartRxJSON` at https://codeberg.org/Freeyourgadget/Gadgetbridge/src/commit/e978cb7aa16e5a44b8d3c1245aef83fe9c85d931/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java#L436 that will detect a message coming in of type `gps` and look at a `power` field to see if it should turn the phone GPS on or off. The same function to handle on/off could also be called on disconnect to stop the GPS service. ... so then it'd report network location all the time (because that doesn't add to power consumption?) and then on Bangle.js we can have the option to basically override the internal GPS and use the phone's GPS.
LukasEdl closed this pull request 2022-11-16 17:05:18 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Freeyourgadget/Gadgetbridge#2961
No description provided.