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

[Android] Add handling of phone gps data #2304

Merged
merged 4 commits into from Nov 28, 2022

Conversation

LukasEdl
Copy link
Contributor

In the Gadgedbridge PR, i add the possibility to use the gps data of the phone.

With this PR, the android app gets extended, so that it can handle the communication with the gadegtbridge part.
To enable to do that i changed the following.

  • I added a handler for a "gps" and a "is_gps_active" GB message.

    • The "gps" message retrieves the gps position of the phone and publishes it as a "gps" event onto the "Bangle" object.
    • The "is_gps_active" messages is a request of the phone to retrieve the current power status of the gps. This is used on the phone to stop sending GPS data if the gps is turned off on the bangle device to perserve the battery of the phone.
  • I added a logic to overwrite the "setGPSPower" method and the "isGPSOn" method. This is needed so that, if the phone gps data is being used, the gps of the banglejs device is turned off.

  • I added a setting to enable the overwrite. This must be set or other wise the messages from the phone will be ignored.

  • The received gps data will be provided under the "gps" event, like if you would use the normal gps chip of the banglejs. However if the phone data is being used, the event "GPS-raw" will not be fired. (I don't know how to convert the gps data to raw data, if anyone can and want to do it, feel free to add this)

  • The phone gps also dose not provide the amount of satelites and the course. Those two values will be set to the NaN value. Also the fix value will be set to 1 ( If someone knows how to set the correct "fix" value, feel free to add it)

  • GPS data, which was provided through the phone will have an extra flag called "externalSource".

@myxor
Copy link
Contributor

myxor commented Nov 22, 2022

Looks good but i suggest to add some description for the "Overwrite GPS" setting to the README file.


function onGpsOverwriteChange(newValue) {
if (newValue) {
Bangle.setGPSPower(false, 'android');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is needed... The way setGPSPower works this would only ever turn off the GPS if it had been turned on with Bangle.setGPSPower(true, 'android'); - if any other app requested it, it'd stay turned on

@gfwilliams
Copy link
Member

This looks great, thanks! And I really appreciate you adding the setting for this - as until we get this all merged and in the app store we don't want users finding their GPS stops working ;)

Just a thought, but since when the setting is changed we end up restarting and reloading the boot.js file, maybe we should check currentSettings.overwriteGps and then only overwrite the existing GPS power functions if that is set?

Do you see a problem with doing that? If not I'm happy to merge this and make the change here

@gfwilliams
Copy link
Member

@LukasEdl just checking on what I said above - is it ok if I do that?

@LukasEdl
Copy link
Contributor Author

Sorry for the late response, i was away the last few days. If you want to do that, please go ahead.

gfwilliams added a commit that referenced this pull request Nov 28, 2022
@gfwilliams gfwilliams merged commit cac0c30 into espruino:master Nov 28, 2022
@LukasEdl LukasEdl deleted the android-gps-updater branch December 29, 2022 12:20
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

Successfully merging this pull request may close these issues.

None yet

3 participants