meshtastic / Meshtastic-Android

Android application for Meshtastic
https://meshtastic.org
GNU General Public License v3.0
735 stars 209 forks source link

Feature: Acquire GPS location from phone first #337

Closed kokroo closed 2 years ago

kokroo commented 2 years ago

A lot of the Meshtastic boards have GPS antennas which aren't the best. In addition to that, a lot of times the GPS chip only detects one constellation. All of these lead to initial GPS locks which require 10-20 minutes.

I propose this: if a smartphone is connected to the board, and has an accurate position available, then the board should use and broadcast this location.

It is entirely possible that some hiker might get injured away from their group and their board might keep failing to get a GPS lock by itself but their phone might be able to get a lock. That way, even if the hiker is unconscious, the others will be able to find the injured person.

Modern smartphones almost always have multi-constellation detection including GPS, GLONASS, Galileo, BeiDou, NaVIC, QZSS, and have really amazing reception too.

I think it's a no-brainer to prioritize the phone's location if available, and if not, only then resort to the board's GPS.

mc-hamster commented 2 years ago

It's up to the connected device (phone, whatever) to send the position if connected. Moving to android.

kokroo commented 2 years ago

It's up to the connected device (phone, whatever) to send the position if connected. Moving to android.

It doesn't work like this. I've tested it with several phones and boards and I even read it on the forums. If there's on-board GPS, then the phone location is never used.

geeksville commented 2 years ago

This issue has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/no-sats-no-gps-lock-tried-a-few-different-things-already/4517/5

mc-hamster commented 2 years ago

It's up to the connected device (phone, whatever) to send the position if connected. Moving to android.

It doesn't work like this. I've tested it with several phones and boards and I even read it on the forums. If there's on-board GPS, then the phone location is never used.

Code for this is in PositionPlugin::handleReceivedProtobuf which also calls nodeDB.updatePosition.

Noting in there filters out GPS. Happily accept a PR if there's a fix needed.

andrekir commented 2 years ago

when "Provide location to mesh" is enabled, Google Play Services provides phone GPS location data to be used in Position packets sent from the app.

for the feature to work, besides Google Play Services and Android permissions, device settings can't have: LocationSharing.LocDisabled or fixedPosition.

Position packets with location data (lat, long & alt) are sent every positionBroadcastSecs (default 15 minutes); unless: the device sent a Position packet less than positionBroadcastSecs ago.


room for improvement:

kokroo commented 2 years ago

when "Provide location to mesh" is enabled, Google Play Services provides phone GPS location data to be used in Position packets sent from the app.

for the feature to work, besides Google Play Services and Android permissions, device settings can't have: LocationSharing.LocDisabled or fixedPosition.

Position packets with location data (lat, long & alt) are sent every positionBroadcastSecs (default 15 minutes); unless: the device sent a Position packet less than positionBroadcastSecs ago.

room for improvement:

  • app phone GPS data is not sent even if last Position packets from the device has empty fields (lat0, lon0, alt0), as long as it was less than positionBroadcastSecs ago;
  • sometimes device also sends Position packets every positionBroadcastSecs (even empty lat0, lon0, alt0) replacing any previous phone GPS data sent;

I think this might be the bug. Either way, I think changes will need to be made to both the Android app as well as the firmware.

A check like "if device has empty fields for GPS, use the ones from the phone".

My basic logic for acquiring location is:

  1. If board has location, use it. Which means, no empty fields either.
  2. If board doesn't have location, ask the phone for a location fix.

We can obviously make the phone location opt-in with a privacy warning.

What do you guys think?

geeksville commented 2 years ago

This issue has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/heltec-lora-32-issue/4414/16

andrekir commented 2 years ago

related #345

andrekir commented 2 years ago

many improvements were made to "provide location to mesh" feature in the latest 1.2.54 release. please verify if that solves this issue.

kokroo commented 2 years ago

@andrekir I will check it out and close the issue if it works. Will need more testers to confirm this.

kokroo commented 2 years ago

@andrekir Was this issue thoroughly checked before closing?

andrekir commented 2 years ago

sure, doesn't take much to check either. as always you're welcome to reopen if you find anything wrong.