GNSS
The GNSSS library allows you to get information from the phone's GNSSS device.
This library can be used as a drop-in replacement for the GPS library merely by changing the GPS type to GNSS.
Android devices, if capable, will report location information using all available constellations.
However only limited satellite information is available in the GpsStatus event.
This library is a strict superset of the original GPS library.
To access additional data on the satellites a new GnssStatus event is available in Android API 24 and later.
The GnssStatus event passes a single GnssStatus object as its only parameter.
The GnssStatus object contains information for the visible satellites of all the constellations available.
The GnssStatus event is only available on Android 7 devices and later that implement API 24 or higher.
The library can be used without problem on earlier devices but on these the GnssStatus event will never be raised.
The GNSS receivers in devices will vary in which constellations that they will recognize depending on when they were designed.
Devices from 2019 and later will probably recognise all four of GPS, GALILEO, GLONASS and BEIDOU.
GNSS
The main object that raises the GPS and GNSS events.
Events:
- GnssStatus (SatelliteInfo As GnssStatus) ' Only raised for API 24 and later devices.
- GpsStatus (Satellites As List)
- LocationChanged (Location1 As Location)
- NMEA (TimeStamp As Long, Sentence As String)
- UserEnabled (Enabled As Boolean)
Functions:
- Initialize (EventName As String)
- IsInitialized As Boolean
- Start (MinimumTime As Long, MinimumDistance As Float)
Starts listening for events.
MinimumTime - The shortest period (measured in milliseconds) between events. Pass 0 for highest frequency.
MinimumDistance - The shortest change in distance (measured in meters) for which to raise events. Pass 0 for highest frequency.
- Stop
Stops listening to the GNSS. You will usually want to call Stop inside Sub Activity_Pause.
Properties:
- GNSSEnabled As Boolean [read only]
Tests whether the user has enabled GNSS.
This is identical to GPSEnabled and provided to match the new GNSS class name.
- GPSEnabled As Boolean [read only]
Tests whether the user has enabled GNSS.
This is identical to GNSSEnabled which is provided to match the new GNSS class name.
This property is retained for backward compatibility with the original GPS library.
- LocationSettingsIntent As android.content.Intent [read only]
Returns the intent that is used to show the global locations settings.
Example:
If GNSS1.GNSSEnabled = False Then StartActivity(GNSS1.LocationSettingsIntent)
GPSSatellite
The GPSSatellite object holds various information about a satellite.
A List with the available satellites is passed to the GpsStatus event.
All visible satellites from all the available constellations are in this list.
Only limited information for each satellite is available in GPSSatellite.
Additional information on each satellite is available in the GnssStatus event.
Functions:
Properties:
- Azimuth As Float [read only]
Returns the satellite azimuth in degrees (0 - 360).
- Elevation As Float [read only]
Returns the satellite elevation in degrees (0 - 90).
- Prn As Int [read only]
Returns the PRN (pseudo-random number) for the satellite.
This number is the pseudo-random number for most constellations. It is FCN and OSN number for Glonass.
To avoid duplication the actual values has a constant added to indicate the satellite constellation.
The base values for each contellation are as returned by GnssStatus.Svid().
GPS PRNs are unadjusted and are in the range 1 to 32
Glonass FCNs/OSNs have 64 added and are in the range 65 to 88 or possibly 157 to 172.
Beidou PRNs have 200 added and are in the range 201 to 237.
Galileo PRNs have 300 added and are in the range 301 to 326.
- Snr As Float [read only]
Returns the signal to noise ratio for the satellite.
- UsedInFix As Boolean [read only]
Tests whether this satellite was used to calculate the most recent fix.
GnssStatus
The GnssStatus object holds the information for all the available GNSS satellites.
A single GnssStatus object is passed to the GnssStatus event.
GnssStatus holds information on all the visible satellites of all constallations.
Presenting the information in this way is more efficient than entirely parsing every satelllite into
a separate object as there can be many satellites available from several constellations.
This way only the information needed by the application needs to to be accessed when it is required
This is different to the GPSSatellite object which holds only the information for a single satellite.
A List of GPSSatellite objects for each available satellite is passed to the GpsStatus event.
Each GPSSatellite holds information for one satellite which can be from any available constellation.
Functions:
- Azimuth (satIndex As Int) As Float
Returns the satellite azimuth in degrees (0 - 360).
- CarrierFrequencyHz (satIndex As Int) As Float
Gets the carrier frequency of the signal tracked.
For example it can be the GPS central frequency
L1 = 1575.45 MHz, L2 = 1227.60 MHz, L5 = 1176.45 MHz, varying GLO channels, etc.
If the field is not set, it is the primary common use central frequency, e.g. L1 = 1575.45 MHz for GPS.
For an L1, L5 receiver tracking a satellite on L1 and L5 at the same time, two measurements will be reported for this same satellite,
in one all the values related to L1 will be filled, and in the other all of the values related to L5 will be filled.
The value is only available if hasCarrierFrequencyHz(int) is true.
- Cn0DbHz (satIndex As Int) As Float
Retrieves the carrier-to-noise density in dB-Hz at the antenna of the satellite at the specified index.
- ConstellationType (satIndex As Int) As Int
Retrieves the constellation type of the satellite at the specified index.
Compare this with one of the CONSTELLATION constants to identify the constellation.
- Elevation (satIndex As Int) As Float
Returns the satellite elevation in degrees (0 - 90).
- HasAlmanacData (satIndex As Int) As Boolean
Reports whether the satellite at the specified index has almanac data.
- HasCarrierFrequencyHz (satIndex As Int) As Boolean
Reports whether a valid CarrierFrequency is available for the satellite at the specified index.
- HasEphemerisData (satIndex As Int) As Boolean
Reports whether the satellite at the specified index has ephemeris data.
- IsInitialized As Boolean
- SatelliteCount As Int
Gets the total number of satellites in the satellite list.
- Svid (satIndex As Int) As Int
Gets the identification number for the satellite at the specific index.
This svid is the pseudo-random number for most constellations. It is FCN and OSN number for Glonass.
The distinction is made by looking at ConstellationType. Expected values are in the range of:
GPS: 1-32
SBAS: 120-151, 183-192
GLONASS: One of: OSN or FCN+100
1-24 as the orbital slot number (OSN) (preferred, if known)
93-106 as the frequency channel number (FCN) (-7 to +6) plus 100. i.e FCN of -7 is 93, 0 is 100, and +6 is 106
QZSS: 193-200
Galileo: 1-36
Beidou: 1-37
- UsedInFix (satIndex As Int) As Boolean
Tests whether the satellite at the specified index was used to calculate the most recent fix.
Properties:
- CONSTELLATION_BEIDOU As Int [read only]
- CONSTELLATION_GALILEO As Int [read only]
- CONSTELLATION_GLONASS As Int [read only]
- CONSTELLATION_GPS As Int [read only]
- CONSTELLATION_QZSS As Int [read only]
- CONSTELLATION_SBAS As Int [read only]
- CONSTELLATION_UNKNOWN As Int [read only]
Location
A Location object holds various information about a specific GNSS fix.
In most cases you will work with locations that are passed to the GNSS LocationChanged event.
The location object can also be used to calculate distance and bearing to other locations.
Functions:
- BearingTo (TargetLocation As android.location.Location) As Float
Returns the bearing to the given location.
- ConvertToMinutes (Coordinate As Double) As String
Converts the given coordinate to a string formatted with the following format:
[+-]DDD:MM.MMMMM (Minute = 1/60 of a degree)
- ConvertToSeconds (Coordinate As Double) As String
Converts the given coordinate to a string formatted with the following format:
[+-]DDD:MM:SS.SSSSS (Minute = 1/60 of a degree, Second = 1/3600 of a degree)
- DistanceTo (TargetLocation As android.location.Location) As Float
Returns the distance to the given location measured in meters.
- Initialize
Initializes an empty location object.
- Initialize2 (Latitude As String, Longitude As String)
Initializes the location object with the given Latitude and Longitude.
Values can be formatted in any of the three formats:
Degrees: [+-]DDD.DDDDD
Minutes: [+-]DDD:MM.MMMMM (Minute = 1 / 60 of a degree)
Seconds: [+-]DDD:MM:SS.SSSSS (Second = 1 / 3600 of a degree)
Example:
Dim L1 As Location
L1.Initialize2("45:30:30", "45:20:15")
- IsInitialized As Boolean
Properties:
- Accuracy As Float
Gets or sets the fix accuracy (meters).
- AccuracyValid As Boolean [read only]
Returns true if the fix includes an accuracy value.
- Altitude As Double
Gets or sets the fix altitude (meters).
- AltitudeValid As Boolean [read only]
Returns true if the fix includes altitude value.
- Bearing As Float
Gets or sets the fix bearing East of true North.
- BearingValid As Boolean [read only]
Returns true if the fix includes a bearing value.
- Latitude As Double
Gets or sets the fix latitude (degrees from -90 (South) to 90 (North)).
- Longitude As Double
Gets or sets the fix longitude (degrees from -180 to 180, positive values represent the eastern hemisphere).
- Speed As Float
Gets or sets the fix speed (meters/second).
- SpeedValid As Boolean [read only]
Returns true if the fix includes speed value.
- Time As Long
Gets or sets the UTC time of this fix, in milliseconds since January 1, 1970.