GPS Fix

marcel

Active Member
Licensed User
Longtime User
Hi,

I am looking for a way to check if the GPS is fixed.

B4X:
Sub GPS1_NMEA (timestamp As Long, Sentence As String)
  If Sentence.StartsWith("$GPGSA") Then 
     If Sentence.CharAt(9)=3 Then
     gpsFix=True
   Else
     gpsFix=False
   End If
  End If
End Sub
I tried this using the NMEA syntax. But this seems not working all the time...

Is this incorrect or are their better ways to do this?
 

derez

Expert
Licensed User
Longtime User
How about this:
B4X:
Sub GPS_LocationChanged (Location1 As Location)
If Location1.AccuracyValid Then  GPSFix = true else GPSFix = false
 
Upvote 0

Dario126

Member
Licensed User
Longtime User
LocationChanged method is easier, nut what about when device have GPS fix and loose it (like in tunnel)? Then LocationChanged event is not raised? How do I know that there is no more GPS signal?

Implementing some timeout variable since last fix might be some solution, but not like it too much. What if I have GPS setup not to fire up on interval, but on distance since last move then LocationChanged event will not be trigered while user is in same place. He could be there for days, but it thus not mean that there is no signal ..
 
Last edited:
Upvote 0

Dario126

Member
Licensed User
Longtime User
To optimize my code execution I had only GPS events when GPS position moved for 100 m. So I should add another GPS object with some fixed time interval to get access for regular check of status inside locationchanged event? Will this be additional battery consumer (significant)?
 
Upvote 0
Top