Java Code Examples for android.location.GpsSatellite#getPrn()

The following examples show how to use android.location.GpsSatellite#getPrn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationState.java    From WhereYouGo with GNU General Public License v3.0 5 votes vote down vote up
static void onGpsStatusChanged(int event, GpsStatus gpsStatus) {
    if (mListeners == null || mListeners.size() == 0)
        return;

    if (event == GpsStatus.GPS_EVENT_STARTED || event == GpsStatus.GPS_EVENT_STOPPED) {
        for (int i = 0; i < mListeners.size(); i++) {
            mListeners.get(i).onStatusChanged(LocationManager.GPS_PROVIDER,
                    event == GpsStatus.GPS_EVENT_STARTED ? 2 : 1, null);
        }
    } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
        ArrayList<SatellitePosition> pos = null;
        if (gpsStatus != null) {
            pos = new ArrayList<>();
            Iterator<GpsSatellite> enuSat = gpsStatus.getSatellites().iterator();
            // clear sats count
            mSatsCount.x = 0;
            mSatsCount.y = 0;
            while (enuSat.hasNext()) {
                GpsSatellite sat = enuSat.next();
                // pos.add(enuPos.nextElement());
                SatellitePosition satPos = new SatellitePosition();
                satPos.azimuth = sat.getAzimuth();
                satPos.elevation = sat.getElevation();
                satPos.prn = sat.getPrn();
                satPos.snr = (int) sat.getSnr();
                satPos.fixed = sat.usedInFix();
                if (satPos.fixed)
                    mSatsCount.x++;
                mSatsCount.y++;
                pos.add(satPos);
            }
        }
        postGpsSatelliteChange(pos);
    }
}
 
Example 2
Source File: SatelliteDataCollector.java    From DataLogger with MIT License 5 votes vote down vote up
private void logSatelliteInfo(Iterable<GpsSatellite> gpsSatellites){
    int satCounter = 0;

    // System nanoseconds since boot, including time spent in sleep.
    long nanoTime = SystemClock.elapsedRealtimeNanos() + mNanosOffset;

    // System local time in millis
    long currentMillis = (new Date()).getTime();

    String message = String.format("%s", currentMillis) + ";"
            + String.format("%s", nanoTime) + ";"
            + String.format("%s", mNanosOffset);

    for(GpsSatellite satellite: gpsSatellites){
        satCounter++;

        // PRN (pseudo-random number) for the satellite.
        int prn = satellite.getPrn();

        // Signal to noise ratio for the satellite.
        float snr = satellite.getSnr();

        // Azimuth of the satellite in degrees.
        float azimuth = satellite.getAzimuth();

        // Elevation of the satellite in degrees.
        float elevation = satellite.getElevation();

        message += ";" + prn
                + ";" + snr
                + ";" + azimuth
                + ";" + elevation;
    }
    message += ";" + Integer.toString(satCounter);

    logger.log(message);
    logger.log(System.lineSeparator());
}
 
Example 3
Source File: GpsSnrView.java    From satstat with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initializes the SNR grid.
 * <p>
 * This method iterates through {@link #mSats} to determine which ranges of
 * NMEA IDs will be drawn. 
 */
protected void initializeGrid() {
	// iterate through list to find out how many bars to draw
	if (mSats != null)
		for (GpsSatellite sat : mSats) {
			int prn = sat.getPrn();
			if (prn < 1) {
				Log.wtf(TAG, String.format("Got satellite with invalid NMEA ID %d", prn));
			} else if (prn <= 32) {
				draw_1_32 = true;
			} else if (prn <= 54) {
				draw_33_54 = true;
			} else if (prn <= 64) {
				// most likely an extended SBAS range, display the lower range, too
				draw_33_54 = true;
				draw_55_64 = true;
			} else if (prn <= 88) {
				draw_65_88 = true;
			} else if (prn <= 96) {
				// most likely an extended GLONASS range, display the lower range, too
				draw_65_88 = true;
				draw_89_96 = true;
			} else if (prn <= 192) {
				draw_97_192 = true; // TODO: do we really want to enable this huge 96-sat block?
				Log.w(TAG, String.format("Got satellite with NMEA ID %d (from the huge unassigned 97-192 range)", prn));
			} else if (prn <= 195) {
				draw_193_195 = true;
			} else if (prn <= 200) {
				// most likely an extended QZSS range, display the lower range, too
				draw_193_195 = true;
				draw_196_200 = true;
			} else if (prn <= 235) {
				draw_201_235 = true;
			} else if (prn <= 300) {
				draw_236_300 = true; // TODO: same as above, do we really want to enable this?
			} else if (prn <= 336) {
				draw_301_336 = true;
			} else {
				Log.w(TAG, String.format("Got satellite with NMEA ID %d, possibly unsupported system", prn));
			}
		}
	/*
	 * If we didn't get any valid ranges, display at least the GPS range.
	 * No need to check for extended ranges here - if they get drawn, so
	 * will their corresponding base range.
	 */
	if (!(draw_1_32 || draw_33_54 || draw_65_88 || draw_97_192 || draw_193_195 || draw_201_235
			|| draw_236_300 || draw_301_336))
		draw_1_32 = true;
}